-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Description
I have a need to bundle a pre-optimized external lib with my RN application. Until RN 0.42 I had been using a .babelignore to prevent the packager from trying to optimize this file and choke.
It seems in 0.42 and higher I'm no longer allowed to ignore the file.
This issue has also been reported as #12071
I've chatted with @loganfsmyth from BabelJS and his comments were:
cool, I think this is a regression in react-native, their code in that stacktrace is not handling ignored files: https://github.com/facebook/react-native/blob/master/packager/transformer.js#L110,
astwill beundefinedif the file was ignored (edited)
I believe that code was added recently for their faster sourcemap generation logic
Reproduction Steps and Sample Code
A project running 0.43.0-rc4 which produces a more verbose error than 0.42 does is here:
https://github.com/kevinold/RNBabelIgnoreIssue
Upon running react-native run-ios the following error is produced:
error: bundling: TypeError: Cannot read property 'tokens' of undefined
at new Generator (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/babel-generator/lib/index.js:51:21)
at exports.default (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/babel-generator/lib/index.js:19:13)
at Object.transform (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/transformer.js:110:20)
at transformCode (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/src/JSTransformer/worker/worker.js:91:31)
at exports.transformAndExtractDependencies (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/react-native/packager/src/JSTransformer/worker/worker.js:148:3)
at handle (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/worker-farm/lib/child/index.js:41:8)
at process.<anonymous> (/Users/kold/eval-projects/RNBabelIgnoreIssue/node_modules/worker-farm/lib/child/index.js:47:3)
at emitTwo (events.js:106:13)
at process.emit (events.js:194:7)
TransformError: /Users/kold/eval-projects/RNBabelIgnoreIssue/epublican-native-context-opt.js: Cannot read property 'tokens' of undefined
Bundling `index.ios.js` 99.0% (403/405), failed.
Solution
Handle babel ignored (in .babelrc ignore sections or .babelignore) files in the packager: https://github.com/facebook/react-native/blob/master/packager/transformer.js#L110
Additional Information
- React Native version: Broken: 0.42-0.43.0-rc4, works on 0.41
- Platform: iOS (I assume Android too)
- Development Operating System: OS X El Capitan