Skip to content
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

Error: Couldn't find intersection #904

Open
jsg2021 opened this issue Sep 24, 2018 · 26 comments
Open

Error: Couldn't find intersection #904

jsg2021 opened this issue Sep 24, 2018 · 26 comments
Labels
bug

Comments

@jsg2021
Copy link

@jsg2021 jsg2021 commented Sep 24, 2018

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'
    ]
}
@wavded

This comment has been minimized.

Copy link

@wavded wavded commented Sep 24, 2018

Same

@ZempTime

This comment has been minimized.

Copy link

@ZempTime ZempTime commented Sep 25, 2018

I'm also getting a pretty much identical stack trace when I updated to

"babel-preset-minify": "^0.5.0-alpha.9",

@boopathi boopathi added the bug label Sep 25, 2018
@driesd

This comment has been minimized.

Copy link

@driesd driesd commented Sep 25, 2018

I'm also getting the same stack trace with "babel-preset-minify": "^0.5.0-alpha.9".

@goozler

This comment has been minimized.

Copy link

@goozler goozler commented Sep 25, 2018

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

@pkuczynski

This comment has been minimized.

Copy link

@pkuczynski pkuczynski commented Sep 29, 2018

Have the same problem. For me it crashes when optimizing following file:

const hasValue = value => Boolean(value) || value === 0

export default hasValue
Hypnosphi added a commit to storybookjs/storybook that referenced this issue Oct 2, 2018
fusionstrings added a commit to comeon-stockholm/babel-preset-comeon that referenced this issue Oct 3, 2018
@wende60

This comment has been minimized.

Copy link

@wende60 wende60 commented Oct 18, 2018

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

@derwaldgeist

This comment has been minimized.

Copy link

@derwaldgeist derwaldgeist commented Oct 26, 2018

Same here. I tried to upgrade to Babel 7 because of #556, and now the error journey just continues... Pretty disappointing experience.

@williaster

This comment has been minimized.

Copy link

@williaster williaster commented Nov 12, 2018

Same error

@linorabolini

This comment has been minimized.

Copy link

@linorabolini linorabolini commented Nov 13, 2018

Same issue, downgraded to 0.3.0 and it works okay now.

"babel-preset-minify": "^0.3.0",

@crespo5

This comment has been minimized.

Copy link

@crespo5 crespo5 commented Nov 14, 2018

Same issue... any solution? For me not works in CLI and in babel preset.

@kasperpeulen

This comment has been minimized.

Copy link

@kasperpeulen kasperpeulen commented Nov 16, 2018

I downgraded to ^0.4.3 to get it working.

@CloudPower97

This comment has been minimized.

Copy link

@CloudPower97 CloudPower97 commented Dec 5, 2018

I'm experiencing this problem as well... Any solutions?

swernerx added a commit to sebastian-software/babel-preset-edge that referenced this issue Dec 20, 2018
@termitek12

This comment has been minimized.

Copy link

@termitek12 termitek12 commented Dec 25, 2018

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.

@FelixButzbach

This comment has been minimized.

Copy link

@FelixButzbach FelixButzbach commented Jan 16, 2019

I just switched from babel-preset-babili to babel-preset-minify and I am experiencing the same problem. @goozler s solution worked for me.

@danielfazlijevic

This comment has been minimized.

Copy link

@danielfazlijevic danielfazlijevic commented Jan 20, 2019

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! fonis@0.0.1 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```
kristw added a commit to kristw/build-config that referenced this issue Feb 8, 2019
I ran into this `Error: Couldn't find intersection` when compiling `@superset-ui/legacy-*`

Seeing the details on this issue and try setting `builtIns:false` fixes the problem.
babel/minify#904

More on `builtIns` and what it does
https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-builtins
@finom

This comment has been minimized.

Copy link

@finom finom commented Feb 11, 2019

I tried to use babel-plugin-minify-builtins without any other plugins but still get the same bug.

@william-bratches

This comment has been minimized.

Copy link

@william-bratches william-bratches commented Feb 17, 2019

Same issue here.

@fatlard1993

This comment has been minimized.

Copy link

@fatlard1993 fatlard1993 commented Feb 19, 2019

Same issue here. Changing 'minify' to ['minify', { builtIns: false }] as @goozler suggested worked for me for now.

Teisi added a commit to Teisi/typo3-gulp-scss that referenced this issue Feb 25, 2019
@aprilmintacpineda

This comment has been minimized.

Copy link

@aprilmintacpineda aprilmintacpineda commented Mar 19, 2019

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).

@xixilive

This comment has been minimized.

Copy link

@xixilive xixilive commented Mar 21, 2019

In my case:

Note: Math.ceil and Math.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!

@aprilmintacpineda

This comment has been minimized.

Copy link

@aprilmintacpineda aprilmintacpineda commented Mar 22, 2019

@bderblatter

This comment has been minimized.

Copy link

@bderblatter bderblatter commented Apr 25, 2019

I'm just following the directions here and I'm getting this error:

$ npm run js

> assets@0.1.0 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! assets@0.1.0 js: `babel ../assets/js/modules --out-dir ../assets/dist/js --presets minify`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the assets@0.1.0 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
        }]
    ]
};
@meduzen

This comment has been minimized.

Copy link

@meduzen meduzen commented May 11, 2019

I encountered this bug suddenly, only while watching file changed (webpack watch), but have no idea why has 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"
}
ovanderzee pushed a commit to ovanderzee/onscreenness that referenced this issue May 24, 2019
Onno van der Zee
@dtvn

This comment has been minimized.

Copy link

@dtvn dtvn commented Jul 24, 2019

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"
image

@MichaelOrtho

This comment has been minimized.

Copy link

@MichaelOrtho MichaelOrtho commented Sep 16, 2019

In my case it throws this if I use Math.floor. If I change it to Math.round or some other, it passes.

@TheDudeFromCI

This comment has been minimized.

Copy link

@TheDudeFromCI TheDudeFromCI commented Nov 1, 2019

I've found this error to be thrown when using Math.max. Commenting that line out allows it to solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.