Skip to content

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

Merged
merged 8 commits into from
Feb 2, 2019

Conversation

deAtog
Copy link

@deAtog deAtog commented Jan 15, 2019

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.

Copy link
Collaborator

@Lyrkan Lyrkan left a 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.

@deAtog
Copy link
Author

deAtog commented Jan 21, 2019

@Lyrkan fixed the linting issues.

Copy link
Collaborator

@Lyrkan Lyrkan left a 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');
Copy link
Collaborator

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...

Copy link
Author

@deAtog deAtog Jan 21, 2019

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?

Copy link
Collaborator

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?

Copy link
Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe {*} instead of {object}?

Copy link
Author

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
Copy link
Collaborator

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.

@weaverryan
Copy link
Member

Thank you @deAtog!

@weaverryan weaverryan merged commit 58dc86d into symfony:master Feb 2, 2019
weaverryan pushed a commit that referenced this pull request Feb 2, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants