4catalyzer / babel-plugin-dev-expression Goto Github PK
View Code? Open in Web Editor NEWA mirror of Facebook's dev-expression Babel plugin
License: MIT License
A mirror of Facebook's dev-expression Babel plugin
License: MIT License
I got a very similar issue to #2 using React Native v0.43. After some testing, it turns out this plugin doesn't work at all with React Native :(
Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "BinaryExpression"
Working demo project: https://github.com/cooperka/DemoDevExpression
Full stack:
error: bundling: TypeError: /Users/me/dev/apps/my-app/node_modules/react-native/packager/src/Resolver/polyfills/prelude_dev.js: Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "BinaryExpression"
at validate (/Users/me/dev/apps/my-app/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/Users/me/dev/apps/my-app/node_modules/babel-types/lib/definitions/core.js:412:50)
at Object.validate (/Users/me/dev/apps/my-app/node_modules/babel-types/lib/index.js:505:9)
at NodePath._replaceWith (/Users/me/dev/apps/my-app/node_modules/babel-traverse/lib/path/replacement.js:176:7)
at NodePath.replaceWith (/Users/me/dev/apps/my-app/node_modules/babel-traverse/lib/path/replacement.js:160:8)
at PluginPass.enter (/Users/me/dev/apps/my-app/node_modules/babel-plugin-dev-expression/dev-expression.js:41:18)
at newFn (/Users/me/dev/apps/my-app/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/Users/me/dev/apps/my-app/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/Users/me/dev/apps/my-app/node_modules/babel-traverse/lib/path/context.js:48:17)
TransformError: /Users/me/dev/apps/my-app/node_modules/react-native/packager/src/Resolver/polyfills/prelude_dev.js: /Users/me/dev/apps/my-app/node_modules/react-native/packager/src/Resolver/polyfills/prelude_dev.js: Property property of MemberExpression expected node to be of a type ["Identifier"] but instead got "BinaryExpression"
Bundling `index.ios.js` 100.0% (1991/1991), failed.
.babelrc
:
{
"presets": ["react-native"],
"plugins": ["dev-expression"]
}
Any idea what's going on or how to fix it?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@babel/plugin-transform-modules-commonjs
, codecov
, prettier
)package.json
@babel/plugin-transform-modules-commonjs ^7.15.4
codecov ^3.8.1
jest ^26.6.3
prettier ^2.4.1
.travis.yml
In order to make the ESM builds work on modern browsers, without additional bundlers involved, would you consider change the way process.env.NODE_ENV
is accessed to gracefully handle a missing process
?
process?.env?.NODE_ENV
or maybe process?.env.NODE_ENV
should be enough.
Hi!
Noticed today that babel-plugin-dev-expression works with babel 5.4.7
but can't use it with babel 6.3.13.
TypeError: t.literal is not a function
at module.exports (/.../node_modules/babel-plugin-dev-expression/dev-expression.js:26:7)
I noticed that my commonjs
build included the incorrectly transformed invariant(false)
.
This is incorrect as the import
is being transformed to var _invariant
and invariant
isn't defined.
The issue can be reproduced in babel repl.
Not sure if invariant(false)
can be converted to (0, _invariant.default)(false)
or whatever.
I'm wondering if it would aslo make sens to let the plugin wrap the import
/require
of the warning
dependency with a process.env.NODE_ENV !== 'production'
block.
That shouldn't make any different when using a flat bundler like rollup but I think that would save us some module tree traversal when using a bundler like webpack.
Try to add this plugin into .babelrc but throw a TypeError, and everything works normally after removed it.
/Users/chentsulin/Projects/electron-react-boilerplate/node_modules/babel-core/lib/transformation/file/index.js:591
throw err;
^
TypeError: /Users/chentsulin/Projects/electron-react-boilerplate/webpack.config.production.js: Property key of ObjectProperty expected node to be of a type ["Identifier","StringLiteral","NumericLiteral"] but instead got "BinaryExpression"
at validate (/Users/chentsulin/Projects/electron-react-boilerplate/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/Users/chentsulin/Projects/electron-react-boilerplate/node_modules/babel-types/lib/definitions/core.js:507:63)
at Object.validate (/Users/chentsulin/Projects/electron-react-boilerplate/node_modules/babel-types/lib/index.js:541:9)
at NodePath._replaceWith (/Users/chentsulin/Projects/electron-react-boilerplate/node_modules/babel-traverse/lib/path/replacement.js:214:7)
More detail Info:
PR: https://github.com/chentsulin/electron-react-boilerplate/pull/238/files
Travis Build: https://travis-ci.org/chentsulin/electron-react-boilerplate/jobs/135365374
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.