-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: added suggestion for rollup config #9201
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
for the gatsby package
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,10 @@ | |
"cross-env": "^5.1.4", | ||
"lerna": "^2.9.0", | ||
"nyc": "^7.0.0", | ||
"rimraf": "^2.6.1" | ||
"rimraf": "^2.6.1", | ||
"rollup": "^0.66.6", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😈 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤘 |
||
"rollup-plugin-auto-external": "^2.0.0", | ||
"rollup-plugin-babel": "^4.0.3" | ||
}, | ||
"engines": { | ||
"node": ">6.0.0" | ||
|
@@ -179,6 +182,7 @@ | |
"build:rawfiles": "copyfiles -u 1 src/internal-plugins/**/raw_* dist", | ||
"build:cjs": "babel cache-dir --out-dir cache-dir/commonjs --ignore **/__tests__", | ||
"build:src": "babel src --out-dir dist --source-maps --ignore **/gatsby-cli.js,**/raw_*,**/__tests__", | ||
"build:rollup": "rollup -c", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if this is integrated, the |
||
"clean-test-bundles": "find test/ -type f -name bundle.js* -exec rm -rf {} +", | ||
"prepare": "cross-env NODE_ENV=production npm run build", | ||
"test-coverage": "node_modules/.bin/nyc --reporter=lcov --reporter=text npm test", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
|
||
export default { | ||
input: 'cache-dir/gatsby-browser-entry.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fail, unfortunately. We want the files to remain unbundled so that we can conditionally require certain files. For instance, if we take Bundling this for the browser honestly just wouldn't work, I don't think, because it'll trace those dependencies, exclude conditional requires that we'd want in certain phases, and then create a (smaller, but not as functional) bundle file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair point. i'm not familiar enough with the approach, so this is some of the detail i was hoping to tease out. there could possibly still be a way to accomplish as a bundle (or multiple), but that could be more of an investment than its worth at this point. maybe the better approach would be simple transpilation then, similar to what was done for the common js version, but with |
||
plugins: [ | ||
autoExternal(), | ||
babel({ | ||
presets: [[require(`path`).join(__dirname, `..`, `..`, `.babel-preset.js`), {modules: false}]], | ||
runtimeHelpers: true, | ||
exclude: ['./node_modules/**'] | ||
}) | ||
], | ||
output: [ | ||
{file: 'lib/index.cjs.js', format: 'cjs', sourcemap: true}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the files produced here are the ones that should be referenced as the directory and file names can certainly be adjusted to fit your conventions, but i started with these to demonstrate the mechanics to start with. |
||
{file: 'lib/index.es.js', format: 'es', sourcemap: true} | ||
] | ||
}; |
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.
the output of the transpilation during the rollup build needs to preserve the es-module syntax so that rollup can properly do the rest of its processing. the default retains the previous behavior, but this allows overriding how the modules are handled.