minify
minify copied to clipboard
babel-plugin-minify-constant-folding fails on var split = ''.split;
babel-plugin-minify-constant-folding fails on expression
var split = ''.split;
split.call('', '');
To Reproduce
Minimal code to reproduce the bug
var split = ''.split;
split.call('', '');
Stack Trace
Error: /node_modules/core-js/internals/indexed-object.js: don't know how to turn this value into a node
at Object.valueToNode (/Users/yuri/web/hq/node_modules/@babel/types/lib/converters/valueToNode.js:87:9)
at PluginPass.Expression (/Users/yuri/web/hq/node_modules/babel-plugin-minify-constant-folding/lib/index.js:195:26)
at PluginPass.newFn (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/visitors.js:220:17)
at newFn (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/visitors.js:179:21)
at NodePath._call (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/path/context.js:55:20)
at NodePath.call (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/path/context.js:42:17)
at NodePath.visit (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/path/context.js:90:31)
at TraversalContext.visitQueue (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/context.js:112:16)
at TraversalContext.visitSingle (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/context.js:84:19)
at TraversalContext.visit (/Users/yuri/web/hq/node_modules/@babel/traverse/lib/context.js:140:19)
Configuration
How are you using babel-minify?
babel-preset-minify trough babel API
babel-minify version: 0.5.1
babel version : 7.12.1
babel-minify-config:
{
builtIns: false,
deadcode: false,
// evaluate: false, // Switching babel-plugin-minify-constant-folding off solves the problem
mangle: false,
}
Note that this exact code is found in core-js: https://github.com/zloirock/core-js/blob/cdb246f043ad0b8f3a3b35747b9e531e4b0936f5/packages/core-js/internals/indexed-object.js#L4
As a result it makes it's way into many npm packages that ship a transpiled/bundled main JS file/entry point (i.e. mocha.js).