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

Ensure correct Babel plugin locations in packager transform #4248

Closed
wants to merge 1 commit into from
Closed

Ensure correct Babel plugin locations in packager transform #4248

wants to merge 1 commit into from

Conversation

sebmck
Copy link
Contributor

@sebmck sebmck commented Nov 19, 2015

Manually resolve all default Babel plugins. babel.transform will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.

NOTE: Haven't tested this. Please don't merge until Travis has done CI.

@sebmck
Copy link
Contributor Author

sebmck commented Nov 19, 2015

cc @tadeuzagallo @mkonicek

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @davidaurelio, @sahrens and @spicyj to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Nov 19, 2015
// using the plugins installed in the react-native package.
config.plugins = config.plugins.map(function(plugin) {
if (!Array.isArray(plugin)) plugin = [plugin];
plugin[0] = require(`babel-plugin-${plugin[0]}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Mightn't plugin[0] already be the plugin object at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep... At least for one of them.

…mpt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.
@sebmck
Copy link
Contributor Author

sebmck commented Nov 19, 2015

Tests pass.

@ide
Copy link
Contributor

ide commented Nov 20, 2015

Looks good to me FWIW. My only (small) concern is the code duplication with Babel's normalising logic -- maybe add a comment saying to keep this snippet logically in sync with Babel's behavior? Really don't feel strongly either way. Green tests are beautiful =)

@tadeuzagallo
Copy link
Contributor

I had tried something similar locally but had the same concerns as @ide, but I'm okay with shipping it so we have green tests again, I think we can iterate later if necessary.

@davidaurelio
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/1078005122219412/int_phab to review.

// Normalise plugin to an array.
if (!Array.isArray(plugin)) {
plugin = [plugin];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so I can get a better understanding of it: are non-arrays only supported for strings, i.e. module names to import?

Would this code have the same effect as

return typeof plugin === 'string' ? [require(`babel-plugin-${plugin}`)] : plugin;

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Each entry in the plugins array can be a plugin or a [plugin, options] pair. In either case, the plugin can be the name of a plugin or the plugin itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @spicyj!

@davidaurelio
Copy link
Contributor

Thanks for making us green again, @sebmck!

@sebmck sebmck closed this in 06e5140 Nov 20, 2015
@mkonicek
Copy link
Contributor

Thanks so much @sebmck! 🎆

@mkonicek
Copy link
Contributor

There are now a few new Flow errors that landed just before this but should be easy to fix, I'll take care of that and then master is hopefully green 👍

@sebmck sebmck deleted the babel-plugin-names branch November 21, 2015 03:00
sunnylqm pushed a commit to sunnylqm/react-native that referenced this pull request Dec 2, 2015
Summary: Manually resolve all default Babel plugins. `babel.transform` will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.

**NOTE:** Haven't tested this. Please don't merge until Travis has done CI.
Closes facebook#4248

Reviewed By: svcscm

Differential Revision: D2679651

Pulled By: davidaurelio

fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
Crash-- pushed a commit to Crash--/react-native that referenced this pull request Dec 24, 2015
Summary: Manually resolve all default Babel plugins. `babel.transform` will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.

**NOTE:** Haven't tested this. Please don't merge until Travis has done CI.
Closes facebook#4248

Reviewed By: svcscm

Differential Revision: D2679651

Pulled By: davidaurelio

fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
cpojer pushed a commit to facebook/metro that referenced this pull request Jan 26, 2017
Summary: Manually resolve all default Babel plugins. `babel.transform` will attempt to resolve all base plugins relative to the file it's compiling. This makes sure that we're using the plugins installed in the react-native package.

**NOTE:** Haven't tested this. Please don't merge until Travis has done CI.
Closes facebook/react-native#4248

Reviewed By: svcscm

Differential Revision: D2679651

Pulled By: davidaurelio

fb-gh-sync-id: 0cdef1e738ba28c09c811432a71047f80540ed7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants