babel: error index.js: "" is not a valid identifer name error with 7.7.0
Bug Report
Hi There, One of our builds on CI has just failed when we picked up the latest 7.7.0 release. Building a react-native project is failing and we’re getting this error :
error index.js: "" is not a valid identifer name
debug TypeError: "" is not a valid identifer name
at node_modules/metro/node_modules/@babel/types/lib/definitions/core.js:322:17
at Object.validate (node_modules/@babel/types/lib/definitions/utils.js:201:7)
at validateField (node_modules/metro/node_modules/@babel/types/lib/validators/validate.js:22:9)
at validate (node_modules/metro/node_modules/@babel/types/lib/validators/validate.js:16:3)
at builder (node_modules/metro/node_modules/@babel/types/lib/builders/builder.js:38:27)
at Object.Identifier (node_modules/metro/node_modules/@babel/types/lib/builders/generated/index.js:334:31)
at functionFromProgram (metro/src/ModuleGraph/worker/JsFileWrapping.js:71:7)
at Object.wrapModule (metro/src/ModuleGraph/worker/JsFileWrapping.js:39:19)
at node_modules/metro/src/JSTransformer/worker.js:323:52
This happend on circle CI right after 7.7.0 was published, on a code base that hasn’t changed, and is building perfectly on other platforms where the dependencies haven’t been installed.
The problem is that many packages (like the metro bundler) have @babel/core@^7.0.0
defined as dependency, so this is automatically picked up when using these dependencies. This is what happened to us this morning
Current Behavior I expect my RN bundle to build 😬
Input Code simply make sure 7.7.0 is resolved. if 7.6.3 or earlier is resolved, all is good
Environment
- Babel version(s): [7.7.0]
- Node/npm version: [Node 8]
- OS: [Ubuntu]
- Monorepo: [no]
- How you are using Babel: [react native metro bundler]
Possible Solution remove that update
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 19 (4 by maintainers)
FYI, react native community is deeply affected by this.
Definitely an unfortunate Metro bug: https://github.com/facebook/metro/blob/690f175c2d88432521edd9cde55bfdd220588134/packages/metro/src/ModuleGraph/worker/JsFileWrapping.js#L81
An empty string is not a valid variable name and isn’t a valid function name 😦 They should just be passing
null
, e.g.Tracked in https://github.com/facebook/metro/issues/481
@guyca besides, if you have to rollback for a feature to work, it means there’s a breaking change in the version, and it shouldn’t be
7.7.0
but8.0.0
and we wouldn’t have that problem @nicolo-ribaudo this is really serious. Could you please - at least consider to - unpublish that version so it doesn’t block people from building react-native bundles ?@f-roland Yep! My intention was only to provide context, not to argue against reverting this change.
Thanks @yuanfux - still waiting for the versions to be removed from the npm registry - that’s the only real fix