Skip to content

Dynamic entry support#3634

Merged
TheLarkInn merged 11 commits intowebpack:masterfrom
nkzawa:add/dynamic-entry
Jan 9, 2017
Merged

Dynamic entry support#3634
TheLarkInn merged 11 commits intowebpack:masterfrom
nkzawa:add/dynamic-entry

Conversation

@nkzawa
Copy link
Copy Markdown
Contributor

@nkzawa nkzawa commented Dec 29, 2016

What kind of change does this PR introduce?
feature

Did you add tests for your changes?
yes

If relevant, link to documentation update:

Summary
Enable to change the value of the entry option during watch mode.
Related: #3354, #2874

Does this PR introduce a breaking change?
No.

Other information

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
Member

Choose a reason for hiding this comment

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

Why was this changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is because an entry with a certain name might has different dependencies when the entry function was called multiple times.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok makes sense. Could you update readableIdentifier too and completely remove this.name from the MultiModule.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How should I update readableIdentifier ? I thought it's for human then this.name makes sense ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

readableIdentifier should reflect identifier but in a human readable way. You can use requestShortener.shorten to generate a readable identifier from a request.


Other issue: identifier should only use d.request and not this.context. And don't join them by !. This doesn't make sense here (! is for loaders). Maybe just join them by | or space.

@nkzawa
Copy link
Copy Markdown
Contributor Author

nkzawa commented Jan 2, 2017

@sokra @TheLarkInn Let me know if there are anything else I should work on.

Copy link
Copy Markdown
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.

identifier and readableIdentifier

@nkzawa
Copy link
Copy Markdown
Contributor Author

nkzawa commented Jan 2, 2017

@sokra Fixed identifier and readableIdentifier. Please check.

return path.resolve(this.context, d.request);
}.bind(this)).join("!");
return d.request;
}.bind(this)).join(" ");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should use second parameter of map or even better you can use an arrow function

MultiModule.prototype.readableIdentifier = function(requestShortener) {
return "multi " + this.dependencies.map(function(d) {
return requestShortener.shorten(d.request);
}.bind(this)).join(" ");
Copy link
Copy Markdown
Contributor

@chicoxyzzy chicoxyzzy Jan 2, 2017

Choose a reason for hiding this comment

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

same here and other places

var dep = new SingleEntryDependency(e);
dep.loc = name + ":" + (100000 + idx);
return dep;
}, this), name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use arrow function here please

}, this), this.name), this.name, callback);
var dep = MultiEntryPlugin.createDependency(this.entries, this.name);
compilation.addEntry(this.context, dep, this.name, callback);
}.bind(this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use compiler instead of this, add arrow function and remove bind

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think fixing styles is not the scope of this PR. I will fix what I added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fair point

dep.loc = this.name;
var dep = SingleEntryPlugin.createDependency(this.entry, this.name);
compilation.addEntry(this.context, dep, this.name, callback);
}.bind(this));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
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.

Looks good.

Take a look at the CI output. You need to update some Validation tests because of the schema update.


DynamicEntryPlugin.createDependency = function(entry, name) {
if(Array.isArray(entry))
return new MultiEntryPlugin.createDependency(entry, name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new is incorrect here.


DynamicEntryPlugin.createDependency = function(entry, name) {
if(Array.isArray(entry))
return new MultiEntryPlugin.createDependency(entry, name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

new is incorrect here.

@TheLarkInn
Copy link
Copy Markdown
Member

Sync master and I think we are looking good.

@nkzawa
Copy link
Copy Markdown
Contributor Author

nkzawa commented Jan 6, 2017

@TheLarkInn fixed conflicts.

@TheLarkInn
Copy link
Copy Markdown
Member

Sorry we've been merging a lot lately. Mind syncing again and I'll.merge right away.

@nkzawa
Copy link
Copy Markdown
Contributor Author

nkzawa commented Jan 9, 2017

@TheLarkInn done.

@TheLarkInn
Copy link
Copy Markdown
Member

Thanks!!

@TheLarkInn TheLarkInn merged commit a22b00e into webpack:master Jan 9, 2017
@nkzawa nkzawa deleted the add/dynamic-entry branch January 9, 2017 07:33
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.

4 participants