-
-
Notifications
You must be signed in to change notification settings - Fork 199
Fix support for Webpack externals. This fixes #471 #495
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
Conversation
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.
Hi @deAtog,
As I said in the other PR, I really prefer this version :)
Could you fix the linting issues? It seems that your IDE sometimes used tabs instead of spaces.
By the way I also recommend you to check if there is an EditorConfig plugin for the one you use since many projects (including Encore) have an .editorconfig
files nowadays.
@Lyrkan fixed the linting issues. |
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.
Sorry but I clicked the approve button a bit fast, I've a few non-blocking comments left.
* jquery: 'jQuery', | ||
* react: 'react' | ||
* }) | ||
* const nodeExternals = require('webpack-node-externals'); |
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'm wondering if that's a good idea to put this specific example. I'm a bit scared that some people will think this is a requirement in order to add externals...
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.
Feel free to suggest an alternate example, but webpack-node-externals is probably the most commonly used functional usage here. Maybe spitting it into two examples would be better? One that only adds jquery and react, and one that uses webpack-node-externals?
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.
Hm... maybe splitting it would be better yes.
But maybe I'm also worrying for no real reason here...
@weaverryan What do you think?
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 think splitting is better since I really can't see someone defining 'jquery' and 'react' as externals and then using webpack-node-externals in the same config.
index.js
Outdated
* react: 'react' | ||
* }, | ||
* nodeExternals() | ||
* ]); | ||
* | ||
* @param {object} externals |
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 {*}
instead of {object}
?
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.
Yeah, {*} would indeed be better.
* nodeExternals() | ||
* // add any valid externals you have | ||
* nodeExternals(), | ||
* /^(jquery|\$)$/i |
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.
That PR is the one that doesn't use rest parameters (as opposed to #472), so you'd need to put these two lines into an array.
Thank you @deAtog! |
…d Ellingsworth, Lyrkan, weaverryan) This PR was merged into the master branch. Discussion ---------- Fix support for Webpack externals. This fixes #471 This is an alternative to #472 which does not modify the public Encore API and requires the user to pass an array if they want to add multiple externals at a time. Commits ------- 58dc86d tweaking example c1fbbf3 Split the addExternals example into two separate examples. c0a8d8d Use {*} instead of {object} for externals parameter of addExternals method. 0e012d3 Fix style issues identified by lint. 5ab6822 Include a regex in the tests of addExternals. a51b35f Update documentation for Encore.addExternals 3d6fb55 Ensure a copy of the externals is returned when generating a Webpack config. 84a0dc0 Store externals in an array. This fixes #471
This is an alternative to #472 which does not modify the public Encore API and requires the user to pass an array if they want to add multiple externals at a time.