Skip to content
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: reorder entries such that first registered entry is exported module #11389

Closed
wants to merge 1 commit into from

Conversation

knagaitsev
Copy link

The issue is explained here: webpack/webpack-dev-server#2692 (comment)

My idea is that the very first entry in the compilation should be the one that is exported, so that if a user or webpack-dev-server registers more entries later, those will not be exported when a user has a config like:

output: {
  library: 'main',
  libraryTarget: 'window'
},

This would result in a breaking change which I thinks make sense, but it can be adjusted if others find this to be a problematic breaking change. Consider the config:

entry: [
  './entry1.js',
  './entry2.js',
]

Current behavior: entry2.js is the exported module.

With my changes: entry1.js is the exported module (This seems more intuitive to me, feel free to disagree)

If we don't want this breaking change, then I can reorder the entry config again here:

compiler.hooks.entryOption.call(options.context, options.entry);

So that the last entry is the one exported.

What kind of change does this PR introduce?

fix (related to webpack-dev-server)

Did you add tests for your changes?

Not yet

Does this PR introduce a breaking change?

Yes, ordering of entries internally in webpack

What needs to be documented once your changes are merged?

How webpack entries work when exporting as a module

@webpack-bot
Copy link
Contributor

For maintainers only:

  • This needs to be documented (issue in webpack/webpack.js.org will be filed when merged)
  • This needs to be backported to webpack 4 (issue will be created when merged)

@webpack-bot
Copy link
Contributor

@Loonride The most important CI builds failed. This way your PR can't be merged.

Please take a look at the CI results from travis (failure) and appveyor (failure) and fix these issues.

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

I don't think this is the right fix for that.

  • This mess up execution order
  • It has always exported the last module, this would be a huge breaking change.
  • Plugins can already control entry order, by applying the plugin before or after the plugins generated by the entry option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants