Add support for import declarations#2
Open
ruimarinho wants to merge 1 commit intoandrewimm:masterfrom
Open
Conversation
Author
|
@andrewimm, any feedback here :)? |
Owner
|
Apologies, I guess I never got the notifications for this. This is fantastic, I'll do a full review inline. |
andrewimm
requested changes
Jan 11, 2017
src/index.js
Outdated
| let pkg = require(path.join(srcPath, '..', node.object.arguments[0].value)); | ||
| let value = pkg[node.property.name]; | ||
| treePath.replaceWith(t.expressionStatement(t.valueToNode(value))); | ||
| ImportDeclaration: function importDeclaration(path) { |
Owner
There was a problem hiding this comment.
let's use treePath here over path, otherwise we get implicit conflicts with the path module imported at the top.
src/index.js
Outdated
| return pkg[key]; | ||
| } | ||
|
|
||
| function isManifest(node) { |
Owner
There was a problem hiding this comment.
npm never refers to package.json as a manifest, and that word has overloaded meanings for things like Heroku or Android. Could we just call this isPackageJSON?
src/index.js
Outdated
| return path.replaceWithMultiple(variables); | ||
| }, | ||
|
|
||
| MemberExpression: function MemberExpression(path) { |
143ad31 to
acaf7e8
Compare
Author
|
Feedback addressed @andrewimm. |
|
Hey @andrewimm can you please merge this PR in? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey,
Thanks for this cool package. I really dislike having to copy the
package.jsonto the distribution build of babel and this package allows me to do exactly just that.I've noticed that support for the ES2015 modules was missing, so I've decided to submit this PR with support for that. Default exports won't get replaced, as expected, but no error will occur also.
I think it's time for the package to get some tests, I just didn't have the time to do it on this PR.