Uh oh!
There was an error while loading. Please reload this page.
Enable strict mode for transform-es2015-modules-commonjs - #5796
Enable strict mode for transform-es2015-modules-commonjs#5796janicduplessis wants to merge 1 commit into
Conversation
facebook-github-bot
commented
Feb 7, 2016
By analyzing the blame information on this pull request, we identified @skevy to be a potential reviewer. |
janicduplessis
commented
Feb 7, 2016
skevy
commented
Feb 8, 2016
cc @martinbigio |
facebook-github-bot
commented
Feb 11, 2016
@janicduplessis updated the pull request. |
1 similar comment
facebook-github-bot
commented
Feb 11, 2016
@janicduplessis updated the pull request. |
satya164
commented
Feb 14, 2016
Would be awesome to get it merged. |
corbt
commented
Feb 18, 2016
Looks good to me, just need someone at Facebook to make the changes to their .babelrc's as necessary. |
bestander
commented
Mar 10, 2016
@martinbigio this is related to #6403 that I asked you to check. |
janicduplessis
commented
Mar 10, 2016
I retested this recently and it need #6255 to be merged to work properly or keep the allowTopLevelThis. |
facebook-github-bot
commented
Mar 14, 2016
@janicduplessis updated the pull request. |
bestander
commented
Mar 15, 2016
@janicduplessis does this need to be rebased? |
facebook-github-bot
commented
Mar 15, 2016
@janicduplessis updated the pull request. |
4118dec to
cdba9d3Comparefacebook-github-bot
commented
Mar 15, 2016
@janicduplessis updated the pull request. |
cdba9d3 to
df9efe9Comparefacebook-github-bot
commented
Mar 15, 2016
@janicduplessis updated the pull request. |
janicduplessis
commented
Mar 15, 2016
I removed the allowTopLevelThis since it's already addressed in #6255 and rebased on master. All tests should pass now. |
bestander
commented
Mar 21, 2016
@facebook-github-bot shipit |
facebook-github-bot
commented
Mar 21, 2016
Thanks for importing. If you are an FB employee go to Phabricator to review. |
bestander
commented
Mar 21, 2016
@janicduplessis have you tested this with a manual babel transform? Our apps internally use babel imperatively: If I do before calling transform I still get "use strict" injected automatically |
janicduplessis
commented
Mar 21, 2016
No I haven't tested that. Did you clear the packager cache to make sure the transforms are all run again? |
janicduplessis
commented
Mar 21, 2016
Tested this and it worked: It prints |
bestander
commented
Mar 21, 2016
Thanks a lot, mate. |
janicduplessis
commented
Mar 21, 2016
Good luck :) |
janicduplessis
commented
Mar 27, 2016
Ok, we should probably revert this. Not sure what changed in babel but changing a plugin option by defining it a second time doesn't work anymore. Since we transform all the code in node_modules by default there are a lot of issues with libraries that don't support strict mode. Right now the only way to disable it is to not use babel-preset-react-native and define all the transforms manually so it is not very convenient. Let's wait until there is a supported way to pass options to presets in babel so disabling strict mode is easy. Also I know there was already some discussion about that but shipping react-native and libraries already compiled would help a lot here. cc @bestander |
bestander
commented
Mar 27, 2016
Sounds good to me. On Sunday, 27 March 2016, Janic Duplessis notifications@github.com wrote:
|
satya164
commented
Mar 27, 2016
There's always a risk of breaking third party code since we're transpiling things under |
bestander
commented
Mar 27, 2016
Makes sense actually. On Sunday, 27 March 2016, Satyajit Sahoo notifications@github.com wrote:
|
satya164
commented
Mar 27, 2016
@bestander Yeah. And keep the original files as *.flow files, so flow works for consumers. |
bestander
commented
Mar 27, 2016
I know David Aurelio wanted to get rid of haste code with transpiling A discussion in Core Contributors group maybe? On Sunday, 27 March 2016, Satyajit Sahoo notifications@github.com wrote:
|
satya164
commented
Mar 27, 2016
@bestander Yeah, will post in the group. :) |
janicduplessis
commented
Mar 27, 2016
Summary:See discussion here #5796 (comment) **Test plan (required)** Change the babel-preset-react-native dependency to `"babel-preset-react-native": "file:./babel-preset",` so it uses the local babel-preset instead of the one from npm. ``` ./packager/packager.sh --reset-cache ``` open `http://localhost:8081/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false` and there should not be any added 'strict mode'. Closes#6686 Reviewed By: mkonicek Differential Revision: D3103122 Pulled By: bestander fb-gh-sync-id: 85658ee01bb73f13dacb2b6a48ab121324c13118 fbshipit-source-id: 85658ee01bb73f13dacb2b6a48ab121324c13118
Summary:See discussion here react#5796 (comment) **Test plan (required)** Change the babel-preset-react-native dependency to `"babel-preset-react-native": "file:./babel-preset",` so it uses the local babel-preset instead of the one from npm. ``` ./packager/packager.sh --reset-cache ``` open `http://localhost:8081/Examples/UIExplorer/UIExplorerApp.android.bundle?platform=android&dev=true&hot=false&minify=false` and there should not be any added 'strict mode'. Closesreact#6686 Reviewed By: mkonicek Differential Revision: D3103122 Pulled By: bestander fb-gh-sync-id: 85658ee01bb73f13dacb2b6a48ab121324c13118 fbshipit-source-id: 85658ee01bb73f13dacb2b6a48ab121324c13118
Since #5422 react-native works with strict mode modules but the transform was not updated since Facebook has some non strict mode compatible internal modules. Now that #5214 has landed and it is easy to change the babel config I think we should enable it by default to make es2015 modules spec compliant.
Someone at Facebook will have to make the internal changes necessary to disable strict mode modules for their projects that use non strict mode compatible modules by including a .babelrc file with
{ "presets": [ "react-native" ], "plugins": [ ["transform-es2015-modules-commonjs", { "strict": false, "allowTopLevelThis": true }] ] }before merging this.
We might also want to mention this in the breaking change section for the next release.