babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

Exceptions in 0.5.0 #913

Closed rahbari closed 6 years ago

rahbari commented 6 years ago

After Updating to v0.5.0 I get a lot of errors while minifying single files:

TypeError: unknown: Cannot read property 'contexts' of null
    at NodePath._getQueueContexts (D:\WiFiSpot\node_modules\babel-traverse\lib\path\context.js:278:21)
    at NodePath._containerInsert (D:\WiFiSpot\node_modules\babel-traverse\lib\path\modification.js:94:23)
    at NodePath._containerInsertBefore (D:\WiFiSpot\node_modules\babel-traverse\lib\path\modification.js:137:15)
    at NodePath.insertBefore (D:\WiFiSpot\node_modules\babel-traverse\lib\path\modification.js:56:19)
    at NodePath.unshiftContainer (D:\WiFiSpot\node_modules\babel-traverse\lib\path\modification.js:239:15)
    at BuiltInReplacer.replace (D:\WiFiSpot\node_modules\babel-plugin-minify-builtins\lib\index.js:164:22)
    at PluginPass.exit (D:\WiFiSpot\node_modules\babel-plugin-minify-builtins\lib\index.js:205:27)
    at newFn (D:\WiFiSpot\node_modules\babel-traverse\lib\visitors.js:276:21)
    at NodePath._call (D:\WiFiSpot\node_modules\babel-traverse\lib\path\context.js:76:18)
    at NodePath.call (D:\WiFiSpot\node_modules\babel-traverse\lib\path\context.js:48:17)
JeffML commented 6 years ago

Seeing same issue. Why was this closed?

rv-jbaker commented 6 years ago

We are also seeing this issue. Did you find a resolution @rahbari?

rahbari commented 6 years ago

@rv-jbaker @JeffML The problem is babel core and some modules (Not babel-preset-minifiy) have new package names and you just don't get new version with npm update, for example:

    "@babel/core": "^7.1.6",
    "@babel/plugin-syntax-object-rest-spread": "^7.0.0",
    "@babel/plugin-transform-modules-commonjs": "^7.1.0",
    "babel-preset-minify": "^0.5.0",

Total mess :))

seanmorris commented 5 years ago

I'm having this issue as well.

seanmorris commented 5 years ago
17:25:50 - error: Compiling of app/article/component/HeadingMenu.js failed. TypeError: app/article/component/HeadingMenu.js: Cannot read property 'contexts' of null
    at NodePath._getQueueContexts (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:278:21)
    at NodePath._containerInsert (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:94:23)
    at NodePath._containerInsertBefore (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:137:15)
    at NodePath.insertBefore (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:56:19)
    at NodePath.unshiftContainer (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/modification.js:239:15)
    at BuiltInReplacer.replace (/home/sean/bluetheme/node_modules/babel-plugin-minify-builtins/lib/index.js:164:22)
    at PluginPass.exit (/home/sean/bluetheme/node_modules/babel-plugin-minify-builtins/lib/index.js:205:27)
    at newFn (/home/sean/bluetheme/node_modules/babel-traverse/lib/visitors.js:276:21)
    at NodePath._call (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:48:17)
    at NodePath.visit (/home/sean/bluetheme/node_modules/babel-traverse/lib/path/context.js:117:8)
    at TraversalContext.visitQueue (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:150:16)
    at TraversalContext.visitSingle (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:108:19)
    at TraversalContext.visit (/home/sean/bluetheme/node_modules/babel-traverse/lib/context.js:192:19)
    at Function.traverse.node (/home/sean/bluetheme/node_modules/babel-traverse/lib/index.js:114:17)
    at traverse (/home/sean/bluetheme/node_modules/babel-traverse/lib/index.js:79:12)
    at File.transform (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/file/index.js:516:35)
    at /home/sean/bluetheme/node_modules/babel-core/lib/transformation/pipeline.js:50:19
    at File.wrap (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/file/index.js:532:16)
    at Pipeline.transform (/home/sean/bluetheme/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
    at Promise (/home/sean/bluetheme/node_modules/babel-brunch/index.js:81:26)
    at new Promise (<anonymous>:null:null)
    at BabelCompiler.compile (/home/sean/bluetheme/node_modules/babel-brunch/index.js:77:12)
seanmorris commented 5 years ago

Disabling the "builtIn" plugin seems to suppress the error. I'm using brunch so here's my working config:

exports.plugins = {
  babel: {
    'presets': ['es2015'],
    'env': {
      'production': {
        'presets': [['minify', {
          'builtIns': false
        }]]
      }
    }
  },
};