Skip to content

Enable to update entry during watch mode#3354

Closed
nkzawa wants to merge 2 commits intowebpack:masterfrom
nkzawa:add/dynamic-entries
Closed

Enable to update entry during watch mode#3354
nkzawa wants to merge 2 commits intowebpack:masterfrom
nkzawa:add/dynamic-entries

Conversation

@nkzawa
Copy link
Copy Markdown
Contributor

@nkzawa nkzawa commented Nov 22, 2016

What kind of change does this PR introduce?

feature

Did you add tests for your changes?
No, because

  • Tests fails on my local even if I don't touch the code.
  • This is a proposal. I'd like to get comments before adding tests.

If relevant, did you update the documentation?
No

Summary

This PR enables to add/remove entry during watch mode.

Related: #2874

compiler.plugin('watch-run', function(watching, callback) {
  // add
  compiler.entry.myNewEntry = './foo.js'

  // remove
  delete compiler.entry.myOldEntry
})

Does this PR introduce a breaking change?

Maybe no.

Other information
This PR is based on our work for next.js

@jsf-clabot
Copy link
Copy Markdown

jsf-clabot commented Nov 22, 2016

CLA assistant check
All committers have signed the CLA.

return "multi " + this.name;
return "multi " + this.dependencies.map(function(d) {
return path.resolve(this.context, d.request);
}.bind(this)).join('!');
Copy link
Copy Markdown
Contributor Author

@nkzawa nkzawa Nov 22, 2016

Choose a reason for hiding this comment

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

This change is required because entry might be changed to have a same name with different dependencies.

@sokra
Copy link
Copy Markdown
Member

sokra commented Nov 23, 2016

Instead of making this PR, make a PR that allows the entry options to be a function returning an entry object (or a promise).

This could be done by adding a 3rd branch to the EntryOptionPlugin and introducing a new DynamicEntryPlugin which handles this. Because this plugin may need to reuse some code from SingleEntryPlugin and MultiEntryPlugin, you could move this code into static functions and call them from your new plugin.

@sokra sokra closed this Nov 23, 2016
@nkzawa nkzawa deleted the add/dynamic-entries branch December 29, 2016 16:34
@nkzawa nkzawa mentioned this pull request Dec 29, 2016
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