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

used declatoris syntax, babel-loader throw an error: TypeError: Cannot read property 'left' of null #656

Closed
bigbigbo opened this issue Aug 14, 2018 · 4 comments

Comments

@bigbigbo
Copy link

Webpack Version:
4.16.5

Babel Core Version:
7.0.0-rc.1

Babel Loader Version:
8.0.0-beta.0

Please tell us about your environment:
Windows 7

Current behavior:
I'd like to use the declatoris syntax,like this

@withRouter
class extends React.Component

babel-loader configuration is

{
        test: /\.(js|jsx)$/,
        include: [paths.appSrc],
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env', '@babel/preset-react'],
            plugins: [
              '@babel/transform-runtime',
              ['@babel/plugin-proposal-decorators', { legacy: true }],
              ['@babel/plugin-proposal-class-properties', { loose: true }],
              '@babel/proposal-do-expressions',
              '@babel/proposal-export-default-from',
              '@babel/proposal-export-namespace-from',
              '@babel/proposal-optional-chaining',
              '@babel/proposal-throw-expressions',
              '@babel/syntax-dynamic-import',
              '@babel/syntax-import-meta',
              'react-hot-loader/babel',
              'add-module-exports',
              'dva-hmr'
            ],
            cacheDirectory: true
          }
}

when I build, babel-loader throw an error

ERROR in ./src/layouts/AppWrapper.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Cannot read property 'left' of null
    at NodePath._getKey (E:\cool-feeling\node_modules\@babel\traverse\lib\path\family.js:132:25)
    at NodePath.get (E:\cool-feeling\node_modules\@babel\traverse\lib\path\family.js:124:17)
    at NodePath._getPattern (E:\cool-feeling\node_modules\@babel\traverse\lib\path\family.js:164:21)
    at NodePath.get (E:\cool-feeling\node_modules\@babel\traverse\lib\path\family.js:126:17)
    at ExportsFinder.findExports (E:\cool-feeling\node_modules\babel-plugin-add-module-exports\lib\index.js:89:17)
    at E:\cool-feeling\node_modules\babel-plugin-add-module-exports\lib\index.js:74:17
    at Array.forEach (<anonymous>)
    at ExportsFinder.isOnlyExportsDefault (E:\cool-feeling\node_modules\babel-plugin-add-module-exports\lib\index.js:72:38)
    at AssignmentExpression (E:\cool-feeling\node_modules\babel-plugin-add-module-exports\lib\index.js:22:21)
    at NodePath._call (E:\cool-feeling\node_modules\@babel\traverse\lib\path\context.js:53:20)
 @ ./src/pages/index/router.js 24:41-76
 @ ./src/pages/index/index.js
 @ multi (webpack)-dev-server/client?http://localhost (webpack)/hot/dev-server.js ./src/pages/index/index.js

I use https://babeljs.io/docs/en/next/babel-plugin-proposal-class-properties.html and I don't think I've set it wrong.
Expected/desired behavior:

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
    https://github.com/bigbigbo/cool-feeling

  • What is the expected behavior?
    I can use declatoris syntax normally

  • What is the motivation / use case for changing the behavior?
    null

thanks!

@bigbigbo
Copy link
Author

when I remove babel-plugin-add-module-exports, it can run well

@bigbigbo
Copy link
Author

babel-plugin-add-module-exports does not seem to have made any adaptation to babel@7.0.0-rc.1

@loganfsmyth
Copy link
Member

I'm confused about your example code

@withRouter
class extends React.Component

should be a syntax error because the class is not exported and does not have name.

That said, this does seem like an issue with add-module-exports so I'm going to close in favor of 59naga/babel-plugin-add-module-exports#63.

@bigbigbo
Copy link
Author

@loganfsmyth sorry, this example code has brought you confusion. In fact, this is a shortened code 😄

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

No branches or pull requests

2 participants