Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

Commit

Permalink
build: speedup npm start
Browse files Browse the repository at this point in the history
- [npm start] remove typescript declaration file
- [npm start] use babel with typescript preset
- [npm build] use typescript compiler

references:
- rollup/rollup-plugin-babel#255
- rollup/rollup-plugin-typescript#129
- rollup/rollup-plugin-babel#271
- rollup/rollup-plugin-babel#279
- microsoft/TypeScript-Babel-Starter#29
  • Loading branch information
DrSensor committed Feb 4, 2019
1 parent 402c4be commit 0e7827f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"prettier": "^1.15.3",
"rollup": "^1.0.0",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
Expand Down
12 changes: 9 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {sync as rmEmptyDir} from "delete-empty"
import nodeResolve from "rollup-plugin-node-resolve"
import json from "rollup-plugin-json"
import typescript from "rollup-plugin-typescript2"
import babel from "rollup-plugin-babel"

const log = logger({timestamp: true})
const {LERNA_PACKAGE_NAME, LERNA_ROOT_PATH, ROLLUP_WATCH} = process.env
Expand All @@ -24,7 +25,7 @@ const lernaInfo = {
generateBundle: output => log.pass(`finish building ${LERNA_PACKAGE_NAME} as ${output.format.toUpperCase()} module 🏁`),
writeBundle: result => {
if (numOutput <= ++count) {
mv("types/*/src/*", "types")
if (!ROLLUP_WATCH) mv("types/*/src/*", "types")
rmEmptyDir("types")
}
},
Expand Down Expand Up @@ -88,8 +89,13 @@ export default {
plugins: [
lernaInfo,
json(),
nodeResolve(),
typescript({
ROLLUP_WATCH && babel({
root: LERNA_ROOT_PATH,
cwd: process.cwd(),
extensions: [".ts"]
}),
nodeResolve({extensions: [".ts"]}),
!ROLLUP_WATCH && typescript({
exclude: ["test/**"],
tsconfig: resolve(LERNA_ROOT_PATH, "tsconfig.json"),
// cacheRoot: `${require("temp-dir")}/.rpt2_cache`, // enable this if it's difficult to read the packages structure
Expand Down

0 comments on commit 0e7827f

Please sign in to comment.