-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
0.4.2 breaks - passes invalid data to babel-helper-evaluate-path #845
Comments
Probably related: Adding preset-react: .babelrc: {
"presets": [
[ "@babel/env", { "targets": { "node": '6.9.0', "browsers": [] } } ],
"@babel/react",
"minify"
]
} Code: class MyComponent {
}
MyComponent.propTypes = {
userName: 123
} Exception: TypeError: Cannot read property 'isIfStatement' of null
at evaluateBasedOnControlFlow (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:199:32)
at evaluateIdentifier (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:119:26)
at evaluate (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-helper-evaluate-path/lib/index.js:21:12)
at PluginPass.Expression (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/babel-plugin-minify-constant-folding/lib/index.js:165:21)
at PluginPass.newFn (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/visitors.js:286:17)
at newFn (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/visitors.js:243:21)
at NodePath._call (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:65:18)
at NodePath.call (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/path/context.js:100:12)
at TraversalContext.visitQueue (/Users/swerner/Workspace/sebastian-software/babel-preset-edge/node_modules/@babel/traverse/lib/context.js:144:16) |
Both issues are new with the release of 0.4.2. |
Using the CLI with the output of preset-env it also fails:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Component = void 0;
class Component extends Other {
constructor() {
super();
this.flag = true;
}
main() {
alert(this.foo);
}
}
exports.Component = Component; Error Message:
|
Can be reduced further by using this input code: exports.Component = void 0;
class Component {
}
exports.Component = Component; This produces the same error when using the CLI. |
When using 0.4.1 for these packages it seems to work:
Unfortunately because the patch update it still fails without the last two. NPM still "normalizes" to 0.4.2 in some deeper dependencies. |
Thanks for reporting. I released another patch - |
Unfortunately this does not seem to be the case. Only one of the exceptions is gone. This one is still there:
Executed on all the new versions. Seems to be related to some different code though. Still investigating... |
Code: class MyComponent {
}
MyComponent.propTypes = {
} .babelrc "presets": [
"babel-preset-minify",
"@babel/react",
"@babel/env"
] Error:
When disabling "evaluate" it works:
Output: "use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var MyComponent=function a(){_classCallCheck(this,a)};MyComponent.propTypes={}; |
…r too risky/tricky to use here. See also: babel/minify#845 (comment) Probably the bug is related to separately activating/disabling specific features of the minifier.
Describe the bug
To Reproduce
Minimal code to reproduce the bug
Actual Output
Nothing!
Expected Output
Output when disabling minify preset:
Stack Trace
If applicable,
Configuration
How are you using babel-minify?
Directly from the CLI.
babel-minify version:
0.4.2
babel version :
7.0.0-beta.46
babel-minify-config: None
babelrc:
The text was updated successfully, but these errors were encountered: