minify
minify copied to clipboard
Error: Couldn't find intersection
Describe the bug
After updating to 0.5, I started getting these errors...
Stack Trace
./node_modules/regenerator-runtime/runtime-module.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Couldn't find intersection
Error: Child compilation failed:
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Couldn't find intersection
- ancestry.js:153 NodePath.getDeepestCommonAncestorFrom
[app]/[@babel]/traverse/lib/path/ancestry.js:153:11
- index.js:244 getSegmentedSubPaths
[app]/[babel-plugin-minify-builtins]/lib/index.js:244:14
- index.js:92 BuiltInReplacer.replace
[app]/[babel-plugin-minify-builtins]/lib/index.js:92:31
- index.js:205 PluginPass.exit
[app]/[babel-plugin-minify-builtins]/lib/index.js:205:27
- visitors.js:193 newFn
[app]/[@babel]/traverse/lib/visitors.js:193:21
- context.js:53 NodePath._call
[app]/[@babel]/traverse/lib/path/context.js:53:20
- context.js:40 NodePath.call
[app]/[@babel]/traverse/lib/path/context.js:40:17
- context.js:97 NodePath.visit
[app]/[@babel]/traverse/lib/path/context.js:97:8
- context.js:118 TraversalContext.visitQueue
[app]/[@babel]/traverse/lib/context.js:118:16
- context.js:90 TraversalContext.visitSingle
[app]/[@babel]/traverse/lib/context.js:90:19
- context.js:146 TraversalContext.visit
[app]/[@babel]/traverse/lib/context.js:146:19
- index.js:94 Function.traverse.node
[app]/[@babel]/traverse/lib/index.js:94:17
- index.js:76 traverse
[app]/[@babel]/traverse/lib/index.js:76:12
- index.js:88 transformFile
[app]/[@babel]/core/lib/transformation/index.js:88:29
- index.js:45 runSync
[app]/[@babel]/core/lib/transformation/index.js:45:3
Configuration
babel-minify preset in babel config
babel-minify version: 0.5.0
babel version : 7.1.0
babel-minify-config:
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
sourceType: 'unambiguous',
compact: PROD,
presets: [
require.resolve('./babel.config.js'),
[require.resolve('babel-preset-minify'), {
mangle: false,
deadcode: false,
// simplify: false,
evaluate: false,
}]
]
}
babelrc:
{
sourceType: 'unambiguous',
compact: false,
presets: [
['@babel/preset-env', {
shippedProposals: true,
targets: [
'> 1% in US',
'last 2 versions',
'not dead',
]
}],
'@babel/preset-flow',
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-runtime',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-syntax-dynamic-import'
]
}
Same
I'm also getting a pretty much identical stack trace when I updated to
"babel-preset-minify": "^0.5.0-alpha.9",
I'm also getting the same stack trace with "babel-preset-minify": "^0.5.0-alpha.9".
I have the same versions of libs and I had the same issue. Disabling builtIns
helped me. I have these options now:
['minify', {
builtIns: false,
evaluate: false,
mangle: false,
}],
It's like a temporary fix
Have the same problem. For me it crashes when optimizing following file:
const hasValue = value => Boolean(value) || value === 0
export default hasValue
confirm that @goozler solution works also for me with the same problems... it works setting only builtIns to false
Example here https://github.com/wende60/Javascript-Gallery
Same here. I tried to upgrade to Babel 7 because of https://github.com/babel/minify/issues/556, and now the error journey just continues... Pretty disappointing experience.
Same error
Same issue, downgraded to 0.3.0 and it works okay now.
"babel-preset-minify": "^0.3.0",
Same issue... any solution? For me not works in CLI and in babel preset.
I downgraded to ^0.4.3 to get it working.
I'm experiencing this problem as well... Any solutions?
For me this is a problem when I minify multiple files or some files that are > 1MB.
If I minify files one by one - everything is ok.
However minify files one by one is annoying and this should be fixed ASAP.
I just switched from babel-preset-babili to babel-preset-minify and I am experiencing the same problem. @goozler s solution worked for me.
I am experiencing the same problem right now, what's weird is that it works on my PC locally, but when I deploy it to Heroku it crashes
2019-01-20T02:21:49.246316+00:00 app[web.1]: at NodePath.getDeepestCommonAncestorFrom (/app/node_modules/@babel/traverse/lib/path/ancestry.js:153:11)
2019-01-20T02:21:49.246318+00:00 app[web.1]: at getSegmentedSubPaths (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:244:14)
2019-01-20T02:21:49.246319+00:00 app[web.1]: at BuiltInReplacer.replace (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:92:31)
2019-01-20T02:21:49.246321+00:00 app[web.1]: at PluginPass.exit (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:205:27)
2019-01-20T02:21:49.246322+00:00 app[web.1]: at newFn (/app/node_modules/@babel/traverse/lib/visitors.js:193:21)
2019-01-20T02:21:49.246323+00:00 app[web.1]: at NodePath._call (/app/node_modules/@babel/traverse/lib/path/context.js:53:20)
2019-01-20T02:21:49.246325+00:00 app[web.1]: at NodePath.call (/app/node_modules/@babel/traverse/lib/path/context.js:40:17)
2019-01-20T02:21:49.246326+00:00 app[web.1]: at NodePath.visit (/app/node_modules/@babel/traverse/lib/path/context.js:97:8)
2019-01-20T02:21:49.246327+00:00 app[web.1]: at TraversalContext.visitQueue (/app/node_modules/@babel/traverse/lib/context.js:118:16)
2019-01-20T02:21:49.246329+00:00 app[web.1]: at TraversalContext.visitSingle (/app/node_modules/@babel/traverse/lib/context.js:90:19)
2019-01-20T02:21:49.261822+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-01-20T02:21:49.262262+00:00 app[web.1]: npm ERR! errno 1
2019-01-20T02:21:49.263298+00:00 app[web.1]: npm ERR! [email protected] start: `set NODE_ENV=production && babel lib/js --out-dir public/js && node ./bin/www`
2019-01-20T02:21:49.263458+00:00 app[web.1]: npm ERR! Exit status 1```
I tried to use babel-plugin-minify-builtins
without any other plugins but still get the same bug.
Same issue here.
Same issue here. Changing 'minify'
to ['minify', { builtIns: false }]
as @goozler suggested worked for me for now.
In my case this happens intermittently (I'm not sure when) but I've never experienced this when building locally. However, building using runners
on GitLab, this happens frequently (about 50 to 60 percent of the time).
In my case:
Note:
Math.ceil
andMath.floor
// throw Error: Couldn't find intersection
function(){
const gen = () => seq.substr(Math.ceil(Math.random() * 1e5) % len, 1)
}
// not throw
function(){
const gen = () => seq.substr(Math.floor(Math.random() * 1e5) % len, 1)
}
Append comments:
with --builtIns false
option, Math.ceil
works fine!
I started to notice this error when I added this polyfill. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Polyfill
I'm just following the directions here and I'm getting this error:
$ npm run js
> [email protected] js /Code/front-end-tools
> babel ../assets/js/modules --out-dir ../assets/dist/js --presets minify
Error: Couldn't find intersection
at NodePath.getDeepestCommonAncestorFrom (/Code/front-end-tools/node_modules/@babel/traverse/lib/path/ancestry.js:153:11)
at getSegmentedSubPaths (/Code/front-end-tools/node_modules/babel-plugin-minify-builtins/lib/index.js:244:14)
at BuiltInReplacer.replace (/Code/front-end-tools/node_modules/babel-plugin-minify-builtins/lib/index.js:92:31)
at PluginPass.exit (/Code/front-end-tools/node_modules/babel-plugin-minify-builtins/lib/index.js:205:27)
at newFn (/Code/front-end-tools/node_modules/@babel/traverse/lib/visitors.js:193:21)
at NodePath._call (/Code/front-end-tools/node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (/Code/front-end-tools/node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (/Code/front-end-tools/node_modules/@babel/traverse/lib/path/context.js:97:8)
at TraversalContext.visitQueue (/Code/front-end-tools/node_modules/@babel/traverse/lib/context.js:118:16)
at TraversalContext.visitSingle (/Code/front-end-tools/node_modules/@babel/traverse/lib/context.js:90:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] js: `babel ../assets/js/modules --out-dir ../assets/dist/js --presets minify`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /.npm/_logs/2019-04-25T21_53_04_927Z-debug.log
I also fixed it by disabling builtIns
, in this case it was in my babel.config.js
file:
module.exports = {
presets: [
['@babel/preset-env', {
"useBuiltIns": "entry"
}],
['minify', {
'builtIns': false
}]
]
};
I encountered this bug suddenly, only while watching files change (webpack watch), but have no idea why as no changes were made to my build setup. Running file compilation for production was still fine.
Solved it by downgrading from 0.5.0 to 0.4.3, as suggested by @kasperpeulen. The builtIns
and useBuiltIns
proposals didn’t solved anything in my case.
Here’s my .babelrc
:
{
"comments": false,
"presets": ["@babel/preset-env"],
"env":
{
"development": { "presets": ["minify"] },
"production": { "presets": ["minify"] }
}
}
and the `devDependencies` part of the `package.json`
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"babel-loader": "^8.0.5",
"babel-preset-minify": "^0.4.3",
"browser-sync": "^2.26.5",
"browser-sync-webpack-plugin": "^2.2.0",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^5.0.2",
"cross-env": "^5.1.4",
"css-loader": "^2.1.1",
"cssnano": "^4.1.10",
"dotenv": "^8.0.0",
"friendly-errors-webpack-plugin": "^1.7.0",
"mini-css-extract-plugin": "^0.5.0",
"node-sass": "^4.12.0",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.5.0",
"sass-loader": "^7.1.0",
"vue-loader": "^15.0.9",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.29.0",
"webpack-build-notifier": "^1.0.2",
"webpack-cli": "^3.3.0",
"webpack-merge": "^4.1.2"
}
For me this is a problem when I minify multiple files or some files that are > 1MB.
If I minify files one by one - everything is ok.
However minify files one by one is annoying and this should be fixed ASAP.
I got a same problem today too.
"babel-preset-minify": "0.5.0"
In my case it throws this if I use Math.floor
. If I change it to Math.round
or some other, it passes.
I've found this error to be thrown when using Math.max
. Commenting that line out allows it to solve.
Oddly, while the 'builtIns': false did work, it did not help me when using babel minify in NPM. I'm actually not even sure how to put that override in the CLI - e.g. npm run build.
But, when I found the offending js program, and compiled/minified that separately it did work.
So, I ended up with a package.json file with min and non-min build commands (where c.js was causing intersection issue)
"scripts": {
"build": "babel ./a.js ./b.js ./c.js --out-dir ./build",
"build-min": "babel ./a.js ./b.js --presets minify --out-dir ./build && babel ./c.js --presets minify --out-dir ./public/build"}
I am experiencing the same problem right now, what's weird is that it works on my PC locally, but when I deploy it to Heroku it crashes
2019-01-20T02:21:49.246316+00:00 app[web.1]: at NodePath.getDeepestCommonAncestorFrom (/app/node_modules/@babel/traverse/lib/path/ancestry.js:153:11) 2019-01-20T02:21:49.246318+00:00 app[web.1]: at getSegmentedSubPaths (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:244:14) 2019-01-20T02:21:49.246319+00:00 app[web.1]: at BuiltInReplacer.replace (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:92:31) 2019-01-20T02:21:49.246321+00:00 app[web.1]: at PluginPass.exit (/app/node_modules/babel-plugin-minify-builtins/lib/index.js:205:27) 2019-01-20T02:21:49.246322+00:00 app[web.1]: at newFn (/app/node_modules/@babel/traverse/lib/visitors.js:193:21) 2019-01-20T02:21:49.246323+00:00 app[web.1]: at NodePath._call (/app/node_modules/@babel/traverse/lib/path/context.js:53:20) 2019-01-20T02:21:49.246325+00:00 app[web.1]: at NodePath.call (/app/node_modules/@babel/traverse/lib/path/context.js:40:17) 2019-01-20T02:21:49.246326+00:00 app[web.1]: at NodePath.visit (/app/node_modules/@babel/traverse/lib/path/context.js:97:8) 2019-01-20T02:21:49.246327+00:00 app[web.1]: at TraversalContext.visitQueue (/app/node_modules/@babel/traverse/lib/context.js:118:16) 2019-01-20T02:21:49.246329+00:00 app[web.1]: at TraversalContext.visitSingle (/app/node_modules/@babel/traverse/lib/context.js:90:19) 2019-01-20T02:21:49.261822+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2019-01-20T02:21:49.262262+00:00 app[web.1]: npm ERR! errno 1 2019-01-20T02:21:49.263298+00:00 app[web.1]: npm ERR! [email protected] start: `set NODE_ENV=production && babel lib/js --out-dir public/js && node ./bin/www` 2019-01-20T02:21:49.263458+00:00 app[web.1]: npm ERR! Exit status 1```
Same issue here, ok locally but not on Heroku. Would appriciate to know how you fixed it ?
Hi. As stated in the post, when I did the minify it displayed which file was causing the issue. I tried to minify ONLY that program and it worked. So I created two separate compiles - 1 for the offending program and another for all the others.
"build-min": "babel ./a.js ./b.js --presets minify --out-dir ./build && babel ./c.js --presets minify --out-dir ./public/build"}
Take care if you are using Math.
let movX = Math.abs(currentPosX - this.path[0].posX); let movY = Math.abs(currentPosY - this.path[0].posY);
I was solve my issue changing Math.abs
`let movX = currentPosX - this.path[0].posX; let movY = currentPosY - this.path[0].posY;
if(movX < 0) movX = (-1) * movX; if(movY < 0) movY = (-1) * movY;`