Open mblout opened 4 years ago
I have the same error with this code:
const defaultLib = require('./default-lib');
foo(lib = defaultLib) {
this.lib = lib;
}
The issue seems to be with default functional parameters set to a constant.
Seeing the same problem here... setting mangle: false
in the options seems to work-around the problem.
Also, seems there is a similar old issue : https://github.com/babel/minify/issues/556
I see the same issue when using rollup-babel-minify
. Dependabot tried to update to latest babel and couldn't due to this issue.
TypeError: unknown: Cannot read property 'add' of undefined
at ScopeTracker.addReference (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/scope-tracker.js:47:34)
at ReferencedIdentifier (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/index.js:196:26)
at newFn (/Users/jeffyates/git/checksync/node_modules/@babel/traverse/lib/visitors.js:220:17)
at bfsTraverse (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/bfs-traverse.js:32:43)
at Mangler.collect (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/index.js:229:7)
at Mangler.run (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/index.js:54:12)
at PluginPass.exit (/Users/jeffyates/git/checksync/node_modules/babel-plugin-minify-mangle-names/lib/index.js:558:19)
at newFn (/Users/jeffyates/git/checksync/node_modules/@babel/traverse/lib/visitors.js:179:21)
at NodePath._call (/Users/jeffyates/git/checksync/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/Users/jeffyates/git/checksync/node_modules/@babel/traverse/lib/path/context.js:42:17)
Same issue here.
same issue here :(
Same issue here to build webtorrent
I'm having the same issue when I'm assigning a default value to a parameter. As soon as I remove the default value, the issue is gone.
Same issue
I have noticed a weird behaviour :
@babel/core@7.5.5
, and I do not hit this issue@babel/core
to any superior version, I start hitting the issue@babel/core
to 7.5.5
, I still hit the issue.I think this means the issue is caused by one of @babel/core
's dependencies. Not sure how to pinpoint which one :/
Same issue here.
same issue :(
The issue seems to be with default functional parameters set to a constant.
Same for me on both babel-preset-minify 0.4.3 and 0.5.1.
This doesn’t compile:
import { doc } from '../utils/Document';
const DEFAULT_DEBOUNCE_DELAY = 100
let resizeTimer = null
export default function debounceResize(callback, delay = DEFAULT_DEBOUNCE_DELAY) {
clearTimeout(resizeTimer)
doc.classList.add('resizing')
resizeTimer = setTimeout(() => {
doc.classList.remove('resizing')
callback()
}, delay)
}
This compiles properly:
import { doc } from '../utils/Document';
let resizeTimer = null
export default function debounceResize(callback, delay = 100) {
clearTimeout(resizeTimer)
doc.classList.add('resizing')
resizeTimer = setTimeout(() => {
doc.classList.remove('resizing')
callback()
}, delay)
}
I'm still stuck on @babel/core@7.5.5 because of this. Any way we can help fix this ?
I was able to work around this problem by using @babel/plugin-transform-parameters
to transpile away the default parameters syntax prior to minification. I would still be interested to see the bug fixed though.
I was seeing the same thing as @arantes555, where upgrading to the latest package started causing the issue, but rolling back to the previously working version still produced the bug, even after wiping and reinstalling node_modules
. I eventually gave up and switched to terser, which has been working fine.
@fwextensions I ended up switching to terser too...
For those who, for some reason, cannot switch, the trick in this case is to wipe node_modules, and roll-back both your package.json and pacakge-lock.json, then re-installing.
I got same error.
Any update? Seem there is an PR checked but not merged.
I was able to work around this problem by using
@babel/plugin-transform-parameters
to transpile away the default parameters syntax prior to minification. I would still be interested to see the bug fixed though.
Confirming it works with @babel/plugin-transform-parameters Thank you very much @s100
Any update? I found that it started to fail after a change in @babel/types@7.8.0
- https://github.com/babel/babel/pull/10917
Hopefuly https://github.com/babel/minify/pull/1024 will be merged soon.
@ochodek I used Yarn's built-in yarn patch
feature to apply #1024's changes (if you're not using Yarn 3+, you can use patch-package instead). It fixed the issue for me.
seeing " Cannot read property 'add' of undefined" with the latest
sample code, junk.js
command: npx babel junk.js --presets=minify
package.json
stack