-
Notifications
You must be signed in to change notification settings - Fork 27.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
Example: Externals - config for untranspiled external packages #3732
Conversation
}) | ||
config.module.rules.push({ | ||
test: /\.+(js|jsx)$/, | ||
loader: defaultLoaders.babel, |
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.
Does this respect my local babel config? Trying this out but wouldn't process stage-2.
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.
Never mind, it does work!
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.
Yep defaultLoaders.babel
is provided by next to be integrated into plugins / next.config.js. It's the same babel config used to configure .js
transpilation 🙏
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.
A fully working example will help a lot
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 can say that this next.config.js
does indeed work. I took what's here and tested in my own project (Lerna based).
const webpack = require("webpack") | ||
|
||
// Update these to match your package scope name. | ||
const internalNodeModulesRegExp = /@zeit(?!.*node_modules)/ |
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.
A little confused by how this works. The internalNodeModulesRegExp won't replace the scan to our internal node_modules right?
And what's the externalNodeModules? seems like it's used to ignore a re-compile in webpackDevServer?
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.
Yup, I don't get this part either.
Whats remaining on blocking this merge? Happy to help. |
Does this work with |
@@ -0,0 +1,26 @@ | |||
const webpack = require("webpack") |
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.
Why is webpack
imported here? Is this needed?
Going to close this in favor of https://github.com/zeit/next.js/blob/canary/examples/with-yarn-workspaces/packages/web-app/next.config.js |
@timneutkens I am the maintainer of |
@martpie |
Thank you for noticing that, I'll have a look |
This provides an example
next.config.js
which adds support for external untranspiled npm packages. It overrides Webpack'sexternals
so it will process these packages and configures webpack-dev-server to enable HMR onnpm link
ed local packages.