-
-
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
[BUG] Cannot read property 'add' of undefined #556
Comments
Thanks. Do you have a minimal reproduction code snippet or the input code that creates this error ? And since you're using webpack, can you try with babili-webpack-plugin to find if the same error happens with babili webpack plugin. There are a few issues when used with es2015 |
I was having the same issue today, but I'm not using webpack. It was working before some changes I had made, so I stashed them and re-applied them one by one. The culprit was the snippet below in a function that otherwise had no return value: if (!someLocalBooleanVariable && this.state.anotherBooleanVariable) {
return;
} I can't show the client's code, but I'll try to put together an example later and see if I can reproduce the issue. |
I got same error with following code: import { app } from 'electron'
app.session = {
async start () {
await app.windowManager.createFullWindow({})
}
} Making alias of import { app } from 'electron'
const app2 = app
app.session = {
async start () {
await app2.windowManager.createFullWindow({})
}
} Hope it helps. |
Is everyone here facing this issue ONLY when using Is anyone getting the same bug when used WITHOUT es2015-block-scoping ? |
My .babelrc is: {
"presets": [
"stage-0",
["env", {
"targets": {
"node": "7.4.0",
"electron": "1.6.7"
},
"useBuiltIns": true
}]
],
"plugins": [
"add-module-exports",
"transform-decorators-legacy"
],
"env": {
"production": {
"presets": ["babili"]
}
}
} When I removed {
"presets": [
"stage-0"
],
"plugins": [
"transform-es2015-block-scoping",
"add-module-exports",
"transform-decorators-legacy"
],
"env": {
"production": {
"presets": ["babili"]
}
}
} |
I am also experiencing this issue. My .babelrc
I can resolve it by turning mangle off:
|
I'm also having the issue, but only when transforming my source files with browserify. The second call to babili in gulp-babel doesn't error. Trying babili only in the browserify transform still errors. If I just disable mangle in the browserify transform, it works. My gulp task
|
I tried to use a couple of things integrated directly with babel, + https://github.com/babel/babili - Issue with es2015 preset babel/minify#556 + https://github.com/rreverser/babel-plugin-uglify - Just didn't work! So, added in a script using the UglifyJS2 CLI tool which saves ~20% of the size! ✌
So I have a repro repo: https://github.com/arichiardi/js.spec/tree/webpack-babili 😄 Just run |
I'm having this same issue with this
|
I'm having the same issue. In my case it happens when there's a class and at least one method name is a symbol. If I switch from symbol to string (either computed or not) it works fine: Fails: const someSymbol = Symbol('meant to keep method private-ish. not to be exported or exposed any other way');
export default class Foo {
[someSymbol]() {}
} Works: export default class Foo {
some() {}
} Using: 0.1.3 (latest currently) .babelrc{
"presets": [
"latest",
"stage-0",
"babili",
],
"plugins": [
"babel-plugin-add-module-exports"
]
}
|
Same issue with The following code is output of Babili. Here function(t) {
for (var a = /<em>(.*?)<\/em>/, n = t, i = [], d = 0; n.length; ) {
d++;
var l = n.match(a);
if (l) {
var r = l.index;
0 !== r && i.push(n.slice(0, r));
var s = l[0];
i.push(Fa["default"].createElement("em", {
key: d
}, s.slice(4, -5))),
n = n.slice(r + s.length)
} else {
i.push(n);
break
}
}
return tokens
} Here is the input code: const createReactElement = (name: string): $ReadOnlyArray<string | React$Element<*>> => {
const rule = /<em>(.*?)<\/em>/;
let tail = name;
const tokens = [];
let index = 0;
while (tail.length) {
index++;
const match = tail.match(rule);
if (match) {
// $FlowFixMe
const matchIndex = match.index;
if (matchIndex !== 0) {
tokens.push(tail.slice(0, matchIndex));
}
const matchingString = match[0];
tokens.push(<em key={index}>{matchingString.slice(4, -5)}</em>);
tail = tail.slice(matchIndex + matchingString.length);
} else {
tokens.push(tail);
break;
}
}
return tokens;
}; |
I'm looking into fixing this. I've narrowed it down to a very small reproducible example: import Foo from 'bar';
class Baz extends Foo {}
(function() { Foo }), Baz; {
"plugins": ["transform-es2015-modules-commonjs", "minify-mangle-names"]
} The issue doesn't seem to occur if the order of the plugins is flipped, or if one plugin is run on the output of the other. The two plugins might be conflicting with each other somehow. |
@not-an-aardvark Doing the same - funny I saw your post load as I was visiting this page! TODO - edit this post with current |
I think I figured out the issue -- it seems like it's actually a problem with |
After upgrading babel to latest version I am still experiencing this issue |
I am also affected with preset "env". Any progress on this ?
|
I'm experiencing the same as @julienvincent and @jtraulle. |
Thanks for the package. I am also experiencing this issue with the latest version. Here is an example error log:
Let me know if there's anything I can do to help. |
Thanks, setting |
I agree with @derwaldgeist Is there any better solution? |
Any updates on this? |
Having this problem too. |
I am also having this problem when mangle is set to true. Is setting it to false the only solution? |
This issue is closed but the errors are still present, a workaround was found but I don't think it's optimal. |
Just made a PR to work around the issue: #860. I'm not exactly sure why it happens - I'm not using the commonjs modules transform but it still happens for me. This seems to fix the issue though by just adding the missing scope before trying to track a reference in it. |
@devongovett This error is occurring again, on updating to babel core 7.8.0 |
I'm upgrading babel from 7.7.4 to 7.8.3 today and this happened to me too, after changing the configuration for minify from |
Same thing here. It seems to be happening again with 7.8, and seems it can be worked-around with |
In my case the same error occurred due to some function's parameter default value set to a constant. const VALUE = 10;
function myFunction(param = VALUE) {...} The workaround was to replace the constant in the function declaration, like this: function myFunction(param = 10) {...} or function myFunction(param) {
if ("undefined" === typeof param) {
param = VALUE;
}
} |
I am seeing this same error when using
|
This is still a problem today. @eugenmihailescu's workaround worked for me, which suggests that this plugin doesn't handle that correctly, even though it's valid. So it really should be re-opened and fixed (or a new issue). Anyhow, I switched to terser, since that works for my sitch, and it handles using var/funcs to set default param values just fine. |
Encountered this today. @eugenmihailescu's workaround worked for me. My scenario: Did a bit of testing and found out it's not necessarily due to a |
It's still an issue. (rollup-babel-minify) |
Would it be better to reopen this issue or create new one? |
same tody |
Some versions of babel-minify choke on function parameters that default to named constants: babel/minify#556 This moves the default assignment into the function body.
Here's my
.babelrc
:babelrc
Running babel resulted in this error:
Now if I disable Mangling, the minification doesn't seem to have much effect:
Dist without
production
env:The text was updated successfully, but these errors were encountered: