-
-
Notifications
You must be signed in to change notification settings - Fork 258
Use rollup for bundling to speed up startup time #190
Conversation
@@ -29,13 +29,16 @@ | |||
"flow-bin": "^0.33.0", | |||
"lodash": "^4.15.0", | |||
"nyc": "^8.1.0", | |||
"rollup": "^0.36.3", | |||
"rollup-plugin-babel": "^2.6.1", | |||
"rollup-plugin-node-resolve": "^2.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to be able to import an index
file without having to explicitly list ./foo/index
.
if (!pluginMap[name]) { | ||
pluginMap[name] = true; | ||
|
||
let plugin = exports.plugins[name]; | ||
let plugin = plugins[name]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to rename the plugins
identifier in the argument list for loadPlugins
, because it was shadowing the identifier of the same name at the top of the file. The current code is relying on the way the module eventually gets compiled to cjs, but this doesn't work now that we're bundling.
Hmm. Apparently Thoughts? |
We could just not run rollup in node 0.10 and do what we were doing before? We should be able to run the tests with/without rollup right? (might be painful) |
My biggest concern there is that, Rollup could theoretically generate a bundle that wouldn't work on 0.10.x, but we wouldn't know if we didn't test the bundle itself. I did have a thought, though. |
I doubt this is a feasible suggestion, but since node is dropping support for 0.10 at the end of the month, maybe you could bump Babylon to 7 and make it for node 0.12 and up? Alternatively, for node 4 and up, since node drops support for 0.12 at the end of the year. Although, bumping the minimum node version to 4 seems to be on Babel's Next Major milestone. |
We can just use node 6 to build with rollup and then test on the rest? |
agree, maybe even the latest node version edit: Uppps wrong button |
Cool - I'll push updates to the PR this weekend to build with node latest, then run tests on the target node version |
e2fc2b4
to
f4ec01d
Compare
"coverage": "nyc report --reporter=json && codecov -f coverage/coverage-final.json", | ||
"lint": "eslint src bin", | ||
"flow": "flow", | ||
"prepublish": "cross-env BABEL_ENV=production npm run build", | ||
"preversion": "npm run test && npm run changelog", | ||
"test": "npm run lint && npm run flow && npm run build && npm run test-only", | ||
"test-only": "ava test", | ||
"test-ci": "cross-env BABEL_ENV=test npm run build && nyc npm run test-only", | ||
"watch": "babel src --out-dir lib --watch", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have to remove watch if it doesn't need to use rollup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you bring up a good point. I just noticed that I didn't change the test-only
command to run a build first, so technically the code you test against locally isn't 1:1 with the code tested in CI (babel-ified code locally, vs rollup output in CI). Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure - I don't think we do in Babel either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, that's a good point. We could leave it in, and then, if enough of us hit weirdness where things pass in CI but fail locally, we can always pull it out (or try and fix the rollup watch plugin).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I never used watch in babylon as the tests usually do a build before and the build does not take too long.
The 'classCallCheck' Babel helper is used more than once in your code. It's strongly recommended that you use the "external-helpers" plugin or the "es2015-rollup" preset. See https://github.com/rollup/rollup-plugin-babel#configuring-babel for more information Since we already use https://gist.github.com/hzoo/6f393d0a24be191e25dee0bb894bb09e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecoverage is broken see comments.
|
||
before_script: | ||
- 'if [ -n "${BABEL-}" ]; then make bootstrap-babel ; fi' | ||
- 'npm run build' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add BABEL_ENV=test
here infront of the call so that babel-plugin-istanbul is used.
"coverage": "nyc report --reporter=json && codecov -f coverage/coverage-final.json", | ||
"lint": "eslint src bin", | ||
"flow": "flow", | ||
"prepublish": "cross-env BABEL_ENV=production npm run build", | ||
"preversion": "npm run test && npm run changelog", | ||
"test": "npm run lint && npm run flow && npm run build && npm run test-only", | ||
"test-only": "ava test", | ||
"test-ci": "cross-env BABEL_ENV=test npm run build && nyc npm run test-only", | ||
"watch": "babel src --out-dir lib --watch", | ||
"test-ci": "cross-env BABEL_ENV=test nyc npm run test-only", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove cross-env BABEL_ENV=test
here then as it is only used for babel but babel is not run here.
before_install: | ||
# Rollup doesn't support node < 4.x. Switch to latest for build | ||
- . $HOME/.nvm/nvm.sh | ||
- nvm install stable && nvm use stable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe should we use nvm install --lts
instead of nvm install stable
stable is deprecated first of all and is now an alias for node and second it currently installs node 7 and not sure how stable that is already. Or do you think thats okay?
And btw install also automatically calls use.
🎉 We can have a separate issue to use Wonder how hard it would be to just dedupe it in a plugin instead |
Yay, this will also stop people doing dumb shit like this. |
This closes #181.
Copy/pasting the example I posted in that issue:
Test case
Without bundling
With bundling
With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph.
As noted in that thread, this requires (for now) dropping
npm run watch
due to bugs inrollup-watch
. Would like to hear feedback from other contributors to determine if this is going to severely impact anyone's workflow.