Skip to content

Commit 3d358ac

Browse files
committed
implement ttypescript transfomer plugin for rollup-plugin-typescript2
Plugin: https://www.npmjs.com/package/ttypescript The main benefit of this build plugin is the easy enabling of using TS "transformers" which are not a mainstream part of TypeScript core just yet. This includes ones like: https://github.com/Igorbek/typescript-plugin-styled-components
1 parent 12668b9 commit 3d358ac

File tree

3 files changed

+154
-144
lines changed

3 files changed

+154
-144
lines changed

package-lock.json

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 143 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,145 @@
11
{
2-
"name": "microbundle",
3-
"version": "0.12.4",
4-
"description": "Zero-configuration bundler for tiny JS libs, powered by Rollup.",
5-
"main": "dist/microbundle.js",
6-
"source": "src/index.js",
7-
"bin": "dist/cli.js",
8-
"scripts": {
9-
"build": "npm run -s build:babel && npm run -s build:self",
10-
"build:babel": "babel-node src/cli.js --target=node --format cjs src/{cli,index}.js",
11-
"build:self": "node dist/cli.js --target=node --format cjs src/{cli,index}.js",
12-
"prepare": "npm run -s build",
13-
"prepare:babel": "babel src/*.js -d dist && npm t",
14-
"lint": "eslint src",
15-
"test": "npm run -s lint && npm run -s build && cross-env BABEL_ENV=test jest",
16-
"jest": "cross-env BABEL_ENV=test jest",
17-
"format": "prettier --write \"{*,{src,test}/**/*}.+(js|css)\"",
18-
"changeset": "changeset",
19-
"release": "npm run -s prepare && npm test && changeset publish"
20-
},
21-
"repository": "developit/microbundle",
22-
"prettier": {
23-
"singleQuote": true,
24-
"trailingComma": "all",
25-
"useTabs": true,
26-
"arrowParens": "avoid",
27-
"overrides": [
28-
{
29-
"files": "package.json",
30-
"options": {
31-
"useTabs": false,
32-
"parser": "json-stringify"
33-
}
34-
}
35-
]
36-
},
37-
"lint-staged": {
38-
"{src,test}/**/*.js": [
39-
"eslint --fix",
40-
"prettier --write"
41-
],
42-
"{*,{src,test}/**/*}.+(js|css)": [
43-
"prettier --write"
44-
],
45-
"*.md": [
46-
"prettier --write"
47-
]
48-
},
49-
"jest": {
50-
"testEnvironment": "node",
51-
"testURL": "http://localhost"
52-
},
53-
"husky": {
54-
"hooks": {
55-
"pre-commit": "lint-staged"
56-
}
57-
},
58-
"greenkeeper": {
59-
"lockfiles": {
60-
"outOfRangeUpdatesOnly": true
61-
}
62-
},
63-
"keywords": [
64-
"bundle",
65-
"rollup",
66-
"micro library"
67-
],
68-
"files": [
69-
"src",
70-
"dist"
71-
],
72-
"author": "Jason Miller <jason@developit.ca> (http://jasonformat.com)",
73-
"license": "MIT",
74-
"dependencies": {
75-
"@babel/core": "^7.10.2",
76-
"@babel/plugin-proposal-class-properties": "7.7.4",
77-
"@babel/plugin-syntax-import-meta": "^7.10.1",
78-
"@babel/plugin-syntax-jsx": "^7.10.1",
79-
"@babel/plugin-transform-flow-strip-types": "^7.10.1",
80-
"@babel/plugin-transform-react-jsx": "^7.10.1",
81-
"@babel/plugin-transform-regenerator": "^7.10.1",
82-
"@babel/preset-env": "^7.11.0",
83-
"@babel/preset-flow": "^7.10.1",
84-
"@babel/preset-react": "^7.10.4",
85-
"@rollup/plugin-alias": "^3.1.1",
86-
"@rollup/plugin-babel": "^5.0.3",
87-
"@rollup/plugin-commonjs": "^13.0.0",
88-
"@rollup/plugin-json": "^4.1.0",
89-
"@rollup/plugin-node-resolve": "^6.1.0",
90-
"asyncro": "^3.0.0",
91-
"autoprefixer": "^9.8.0",
92-
"babel-plugin-macros": "^2.8.0",
93-
"babel-plugin-transform-async-to-promises": "^0.8.15",
94-
"babel-plugin-transform-replace-expressions": "^0.2.0",
95-
"brotli-size": "^4.0.0",
96-
"builtin-modules": "^3.1.0",
97-
"camelcase": "^5.3.1",
98-
"cssnano": "^4.1.10",
99-
"es6-promisify": "^6.1.1",
100-
"escape-string-regexp": "^4.0.0",
101-
"filesize": "^6.1.0",
102-
"gzip-size": "^5.1.1",
103-
"kleur": "^3.0.3",
104-
"lodash.merge": "^4.6.2",
105-
"module-details-from-path": "^1.0.3",
106-
"pretty-bytes": "^5.3.0",
107-
"rollup": "^1.32.1",
108-
"rollup-plugin-bundle-size": "^1.0.1",
109-
"rollup-plugin-es3": "^1.1.0",
110-
"rollup-plugin-postcss": "^2.9.0",
111-
"rollup-plugin-terser": "^5.3.0",
112-
"rollup-plugin-typescript2": "^0.25.3",
113-
"sade": "^1.7.3",
114-
"tiny-glob": "^0.2.6",
115-
"tslib": "^1.13.0",
116-
"typescript": "^3.9.5"
117-
},
118-
"devDependencies": {
119-
"@babel/cli": "^7.10.1",
120-
"@babel/node": "^7.10.1",
121-
"@babel/plugin-proposal-throw-expressions": "^7.10.1",
122-
"@changesets/changelog-github": "^0.2.6",
123-
"@changesets/cli": "^2.9.2",
124-
"babel-jest": "^24.8.0",
125-
"cross-env": "^6.0.3",
126-
"directory-tree": "^2.2.3",
127-
"eslint": "^6.8.0",
128-
"eslint-config-developit": "^1.2.0",
129-
"eslint-config-prettier": "^6.11.0",
130-
"eslint-plugin-prettier": "^3.1.4",
131-
"esm": "^3.2.22",
132-
"fs-extra": "^8.1.0",
133-
"husky": "^4.2.5",
134-
"jest": "^24.8.0",
135-
"lint-staged": "^10.2.10",
136-
"npm-merge-driver-install": "^1.1.1",
137-
"prettier": "^1.19.1",
138-
"regenerator-runtime": "^0.13.5",
139-
"rimraf": "^3.0.2",
140-
"shell-quote": "^1.6.1",
141-
"strip-ansi": "^6.0.0",
142-
"travis-size-report": "^1.1.0"
143-
}
2+
"name": "microbundle",
3+
"version": "0.12.4",
4+
"description": "Zero-configuration bundler for tiny JS libs, powered by Rollup.",
5+
"main": "dist/microbundle.js",
6+
"source": "src/index.js",
7+
"bin": "dist/cli.js",
8+
"scripts": {
9+
"build": "npm run -s build:babel && npm run -s build:self",
10+
"build:babel": "babel-node src/cli.js --target=node --format cjs src/{cli,index}.js",
11+
"build:self": "node dist/cli.js --target=node --format cjs src/{cli,index}.js",
12+
"prepare": "npm run -s build",
13+
"prepare:babel": "babel src/*.js -d dist && npm t",
14+
"lint": "eslint src",
15+
"test": "npm run -s lint && npm run -s build && cross-env BABEL_ENV=test jest",
16+
"jest": "cross-env BABEL_ENV=test jest",
17+
"format": "prettier --write \"{*,{src,test}/**/*}.+(js|css)\"",
18+
"changeset": "changeset",
19+
"release": "npm run -s prepare && npm test && changeset publish"
20+
},
21+
"repository": "developit/microbundle",
22+
"prettier": {
23+
"singleQuote": true,
24+
"trailingComma": "all",
25+
"useTabs": true,
26+
"arrowParens": "avoid",
27+
"overrides": [
28+
{
29+
"files": "package.json",
30+
"options": {
31+
"useTabs": false,
32+
"parser": "json-stringify"
33+
}
34+
}
35+
]
36+
},
37+
"lint-staged": {
38+
"{src,test}/**/*.js": [
39+
"eslint --fix",
40+
"prettier --write"
41+
],
42+
"{*,{src,test}/**/*}.+(js|css)": [
43+
"prettier --write"
44+
],
45+
"*.md": [
46+
"prettier --write"
47+
]
48+
},
49+
"jest": {
50+
"testEnvironment": "node",
51+
"testURL": "http://localhost"
52+
},
53+
"husky": {
54+
"hooks": {
55+
"pre-commit": "lint-staged"
56+
}
57+
},
58+
"greenkeeper": {
59+
"lockfiles": {
60+
"outOfRangeUpdatesOnly": true
61+
}
62+
},
63+
"keywords": [
64+
"bundle",
65+
"rollup",
66+
"micro library"
67+
],
68+
"files": [
69+
"src",
70+
"dist"
71+
],
72+
"author": "Jason Miller <jason@developit.ca> (http://jasonformat.com)",
73+
"license": "MIT",
74+
"dependencies": {
75+
"@babel/core": "^7.10.2",
76+
"@babel/plugin-proposal-class-properties": "7.7.4",
77+
"@babel/plugin-syntax-import-meta": "^7.10.1",
78+
"@babel/plugin-syntax-jsx": "^7.10.1",
79+
"@babel/plugin-transform-flow-strip-types": "^7.10.1",
80+
"@babel/plugin-transform-react-jsx": "^7.10.1",
81+
"@babel/plugin-transform-regenerator": "^7.10.1",
82+
"@babel/preset-env": "^7.11.0",
83+
"@babel/preset-flow": "^7.10.1",
84+
"@babel/preset-react": "^7.10.4",
85+
"@rollup/plugin-alias": "^3.1.1",
86+
"@rollup/plugin-babel": "^5.0.3",
87+
"@rollup/plugin-commonjs": "^13.0.0",
88+
"@rollup/plugin-json": "^4.1.0",
89+
"@rollup/plugin-node-resolve": "^6.1.0",
90+
"asyncro": "^3.0.0",
91+
"autoprefixer": "^9.8.0",
92+
"babel-plugin-macros": "^2.8.0",
93+
"babel-plugin-transform-async-to-promises": "^0.8.15",
94+
"babel-plugin-transform-replace-expressions": "^0.2.0",
95+
"brotli-size": "^4.0.0",
96+
"builtin-modules": "^3.1.0",
97+
"camelcase": "^5.3.1",
98+
"cssnano": "^4.1.10",
99+
"es6-promisify": "^6.1.1",
100+
"escape-string-regexp": "^4.0.0",
101+
"filesize": "^6.1.0",
102+
"gzip-size": "^5.1.1",
103+
"kleur": "^3.0.3",
104+
"lodash.merge": "^4.6.2",
105+
"module-details-from-path": "^1.0.3",
106+
"pretty-bytes": "^5.3.0",
107+
"rollup": "^1.32.1",
108+
"rollup-plugin-bundle-size": "^1.0.1",
109+
"rollup-plugin-es3": "^1.1.0",
110+
"rollup-plugin-postcss": "^2.9.0",
111+
"rollup-plugin-terser": "^5.3.0",
112+
"rollup-plugin-typescript2": "^0.25.3",
113+
"sade": "^1.7.3",
114+
"tiny-glob": "^0.2.6",
115+
"tslib": "^1.13.0",
116+
"typescript": "^3.9.5",
117+
"ttypescript": "^1.5.11"
118+
},
119+
"devDependencies": {
120+
"@babel/cli": "^7.10.1",
121+
"@babel/node": "^7.10.1",
122+
"@babel/plugin-proposal-throw-expressions": "^7.10.1",
123+
"@changesets/changelog-github": "^0.2.6",
124+
"@changesets/cli": "^2.9.2",
125+
"babel-jest": "^24.8.0",
126+
"cross-env": "^6.0.3",
127+
"directory-tree": "^2.2.3",
128+
"eslint": "^6.8.0",
129+
"eslint-config-developit": "^1.2.0",
130+
"eslint-config-prettier": "^6.11.0",
131+
"eslint-plugin-prettier": "^3.1.4",
132+
"esm": "^3.2.22",
133+
"fs-extra": "^8.1.0",
134+
"husky": "^4.2.5",
135+
"jest": "^24.8.0",
136+
"lint-staged": "^10.2.10",
137+
"npm-merge-driver-install": "^1.1.1",
138+
"prettier": "^1.19.1",
139+
"regenerator-runtime": "^0.13.5",
140+
"rimraf": "^3.0.2",
141+
"shell-quote": "^1.6.1",
142+
"strip-ansi": "^6.0.0",
143+
"travis-size-report": "^1.1.0"
144+
}
144145
}

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import alias from '@rollup/plugin-alias';
1818
import postcss from 'rollup-plugin-postcss';
1919
import typescript from 'rollup-plugin-typescript2';
2020
import json from '@rollup/plugin-json';
21+
import ttypescriptPlugin from 'ttypescript';
2122
import logError from './log-error';
2223
import { isDir, isFile, stdout, isTruthy, removeScope } from './utils';
2324
import { getSizeInfo } from './lib/compressed-size';
@@ -486,7 +487,7 @@ function createConfig(options, entry, format, writeMeta) {
486487
},
487488
useTypescript &&
488489
typescript({
489-
typescript: require('typescript'),
490+
typescript: ttypescriptPlugin,
490491
cacheRoot: `./node_modules/.cache/.rts2_cache_${format}`,
491492
useTsconfigDeclarationDir: true,
492493
tsconfigDefaults: {

0 commit comments

Comments
 (0)