minify: 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'
    ]
}

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 52
  • Comments: 38

Commits related to this issue

Most upvoted comments

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

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

I downgraded to ^0.4.3 to get it working.

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 issue, downgraded to 0.3.0 and it works okay now.

“babel-preset-minify”: “^0.3.0”,

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

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
        }]
    ]
};

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 }]],

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

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

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

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!

I’m also getting the same stack trace with “babel-preset-minify”: “^0.5.0-alpha.9”.