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 · 39 comments
Open

Error: Couldn't find intersection #904

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

Comments

@jsg2021
Copy link

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
Copy link

wavded commented Sep 24, 2018

Same

@ZempTime
Copy link

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 Confirmed bug label Sep 25, 2018
@driesd
Copy link

driesd commented Sep 25, 2018

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

@goozler
Copy link

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
Copy link

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-group/babel-preset-comeon that referenced this issue Oct 3, 2018
@wende60
Copy link

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
Copy link

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

@williaster
Copy link

Same error

@linorabolini
Copy link

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

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

@crespo5
Copy link

crespo5 commented Nov 14, 2018

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

@kasperpeulen
Copy link

I downgraded to ^0.4.3 to get it working.

@CloudPower97
Copy link

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
Copy link

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
Copy link

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
Copy link

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```

@finom
Copy link

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
Copy link

Same issue here.

@fatlard1993
Copy link

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
Copy link

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

@dtvn
Copy link

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
Copy link

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

@TheDudeFromCI
Copy link

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

@rfossella
Copy link

rfossella commented Apr 7, 2020

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

@Singtah
Copy link

Singtah commented May 12, 2020

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```

Same issue here, ok locally but not on Heroku. Would appriciate to know how you fixed it ?

@rfossella
Copy link

rfossella commented May 13, 2020

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

@dogia
Copy link

dogia commented Jul 17, 2020

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;`

@Mitsunee
Copy link

Mitsunee commented Dec 1, 2020

just happend across this problem with Math.floor() in my little library project. I currently have 2 js files, both of which have the same method convert() in their classes, which uses Math.floor() a bunch. Building these files standalone (see package.json) works fine, but if I try npx babel src -d builds it suddenly gets the same error as op.

Here's the link to the commit where I pushed my current configs: https://github.com/Mitsunee/fox-timers/commit/5a57968d9209a5a34f04952e9954359ab9e80b40

And a screenshot of the error as I'm getting it:
Screenshot_20201201_155801

@sivaraj-v
Copy link

Any update ?

@rndm2
Copy link

rndm2 commented Oct 27, 2021

Still reproduced for me with multiple webpack configurations

@joshuambg
Copy link

Still an issue for me.

"@babel/core": "^7.4.3",
"babel-minify": "^0.5.1",
"babel-preset-minify": "^0.5.1",
"webpack": "^5.62.1",

Solved with

 "presets": [["minify", { "builtIns": false }]],

@ElPrudi
Copy link

ElPrudi commented Aug 4, 2022

Yes, still an issue for me.
Had to use

 "presets": [["minify", { "builtIns": false, "mangle": false }]]

@esauvisky
Copy link

Still an issue. For me, it happens because of String.fromCharCode(). Setting builtIns to false solves it.

@jkufrin
Copy link

jkufrin commented Apr 27, 2023

Yes, still an issue for me. Had to use

 "presets": [["minify", { "builtIns": false, "mangle": false }]]

Thanks! That worked for me. And for those using gulp-babel-minify:

.pipe(minify({ "builtIns": false, "mangle": false }))

alextselegidis added a commit to alextselegidis/easyappointments that referenced this issue May 3, 2023
beatrizsmerino added a commit to beatrizsmerino/calendar that referenced this issue Jun 18, 2023
Error:
- Starting 'jsCompile'...
'jsCompile' errored after 341 ms
Error in plugin "gulp-babel"
Message:
    /Applications/MAMP/htdocs/calendar/src/js/pages/_pages-calendar-1.js: Couldn't find intersection

Solution:
- Update the `babel` configuration in the `jsCompile` gulp function.
Call the `babel-preset-minify` package with the name `minify` instead and disable the `builtIns` and `mangle` options.

Reason:
- The reason behind this change may be the use of a newer version of Babel or a related library. The syntax `babel-preset-minify` has been replaced by simply `minify with additional options to customize the behavior of the minification process.
The `"builtIns": false` and `"mangle": false` options are disabled in the Babel configuration to prevent the transformation of new native JavaScript methods and objects and to keep variable and property names non-obfuscated, respectively.

References:
- babel/minify#904 (comment)
- https://www.npmjs.com/package/babel-preset-minify
@xhemals
Copy link

xhemals commented Mar 30, 2024

Still had this issue, workaround I had for still being able to have minified code in my build was this:

  1. Setup different environments in babel.config.json
{
  "env": {
    "dev": {
       "presets": [["minify", { "builtIns": false}]]
     },
    "build": {
      "presets": ["minify"]
    }
  }
}
  1. In package.json, declare BABEL_ENV=dev at the start of my npm run dev. And BABEL_ENV=build at the start of my nom run build command.

Hope this helps anyone still having this issue in 2024!

@hopolivier
Copy link

Hello,
In case someone would like to run babel-minify from the command line, with builtins minifying deactivated, I tried :

babel-minify <filename or directory> --out-dir <output directory> --builtIns false

and it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests