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

Make AMD parser modules extensible again #6674

Merged
merged 4 commits into from
Mar 18, 2018
Merged

Conversation

chuckdumont
Copy link
Contributor

@chuckdumont chuckdumont commented Mar 5, 2018

What kind of change does this PR introduce?

Structural (non-functional) changes to the AMD parser modules that restore extensibility which was lost in the v4 upgrade

Did you add tests for your changes?

No. Not needed. No functional changes.

If relevant, link to documentation update:

N/A

Summary

Prior to V4, code reuse in the AMD parser modules could be achieved through the use of the call require:amd:array, call require:amd:item, call define:amd:array and call define:amd:item plugin events. These events were removed in V4, with no alternative to facilitate reuse of parser code by plugins. This PR restores extensibility through the use of class inheritance (a cleaner approach for the use case). The extensibility is needed by dojo-webpack-plugin which needs to subclass and provide custom implementations of thie processArray and processItem methods while leveraging the core parser functionality of the base classes.

Does this PR introduce a breaking change?

No

Other information

This PR is best reviewed by ignoring whitespace changes.

@jsf-clabot
Copy link

jsf-clabot commented Mar 5, 2018

CLA assistant check
All committers have signed the CLA.

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@chuckdumont
Copy link
Contributor Author

Hi. It's been 10 days since this PR was posted. I someone going to review it or is there something process step I'm missing?

parser.hooks.call.for("define").tap(
"AMDDefineDependencyParserPlugin",
this.processCallDefine.bind(
Object.create(this, {
Copy link
Member

Choose a reason for hiding this comment

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

This is weird. Just add the parser as additional argument to call member methods.


processCallRequire(expr) {
const processArrayForRequestString = param => {
Copy link
Member

Choose a reason for hiding this comment

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

For consistency processArrayForRequestString and processItemForRequestString should also be member methods.

return true;
}

newDefineDependency(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

newDefineDependency(...args) {
return new AMDDefineDependency(...args);
}
newRequireArrayDependency(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

newRequireArrayDependency(...args) {
return new AMDRequireArrayDependency(...args);
}
newRequireItemDependency(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

}
}

newRequireDependenciesBlock(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

newRequireDependenciesBlock(...args) {
return new AMDRequireDependenciesBlock(...args);
}
newRequireItemDependency(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

newRequireItemDependency(...args) {
return new AMDRequireItemDependency(...args);
}
newRequireArrayDependency(...args) {
Copy link
Member

Choose a reason for hiding this comment

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

Write out all arguments explicitly.

parser.hooks.call.for("require").tap(
"AMDRequireDependenciesBlockParserPlugin",
this.processCallRequire.bind(
Object.create(this, {
Copy link
Member

Choose a reason for hiding this comment

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

Same

@webpack-bot
Copy link
Contributor

@chuckdumont Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@chuckdumont
Copy link
Contributor Author

@sokra the requested changes have been made. Thanks.

@sokra sokra merged commit 4428efe into webpack:master Mar 18, 2018
@sokra
Copy link
Member

sokra commented Mar 18, 2018

Thanks

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

4 participants