optimize-plugin icon indicating copy to clipboard operation
optimize-plugin copied to clipboard

Cannot read property 'arguments' of undefined

Open aladdin-add opened this issue 5 years ago • 3 comments

Build completed in 78.241s


Build completed in 0s

TypeError: /Users/weiran/repo/dian/honor/assets/~containers~a~count~cash-114e7fb5.js: Cannot read property 'arguments' of undefined
    at NodePath._getKey (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/family.js:194:25)
    at NodePath.get (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/family.js:186:17)
    at NodePath._getPattern (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/family.js:226:21)
    at NodePath.get (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/family.js:188:17)
    at visitParam (/Users/weiran/repo/dian/honor/node_modules/babel-preset-modernize/dist/plugins/transform-destructuring/index.js:1:5836)
    at PluginPass.VariableDeclarator (/Users/weiran/repo/dian/honor/node_modules/babel-preset-modernize/dist/plugins/transform-destructuring/index.js:1:7332)
    at newFn (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/visitors.js:175:21)
    at NodePath._call (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/context.js:42:17)
    at NodePath.visit (/Users/weiran/repo/dian/honor/node_modules/optimize-plugin/node_modules/@babel/traverse/lib/path/context.js:92:31)
error Command failed with exit code 1.

aladdin-add avatar Dec 15 '20 09:12 aladdin-add

Happening the same here.

Was trying to troubleshoot here but not sure where to start.

I have tried removing the preset extra configs and sourceType but no success.

module.exports = function (api) { // eslint-disable-line func-names
  api.cache(true);

  const presets = [
    ['@babel/preset-env', {
      targets: {
        browsers: ['last 2 versions']
      },
      useBuiltIns: 'usage',
      corejs: '3.0.0'
    }],
    '@babel/react'
  ];

  const plugins = [
    '@babel/plugin-syntax-dynamic-import',
    '@babel/plugin-proposal-class-properties',
    '@babel/plugin-proposal-do-expressions',
    '@babel/plugin-proposal-export-default-from',
    '@babel/plugin-transform-runtime'
  ];

  return {
    presets,
    plugins,
    sourceType: 'module'
  };
};

leonardofaria avatar Dec 21 '20 20:12 leonardofaria

Just an update: I have a fix for this in babel-preset-modernize that should be released soon.

In the meantime, you can disable automatic modernization by passing new OptimizePlugin({ modernize: false }).

developit avatar Feb 22 '21 21:02 developit

@developit, do you have a link to the PR with this fix? Thanks!

cjones26 avatar Jun 15 '22 21:06 cjones26