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

使用jsx语法时,在render里面使用{/*xxx*/}注释时,出现报错 #3676

Closed
rason00 opened this issue Mar 20, 2019 · 3 comments
Closed

Comments

@rason00
Copy link

rason00 commented Mar 20, 2019

Version

3.5.1

Environment info

  System:
    OS: Windows 10
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
  Binaries:
    Node: 10.15.3 - E:\rason\软件\node\node.EXE
    Yarn: Not Found
    npm: 6.4.1 - E:\rason\软件\node\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2
    @vue/babel-preset-app:  3.5.1
    @vue/babel-preset-jsx:  1.0.0-beta.2
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2
    @vue/babel-sugar-inject-h:  1.0.0-beta.2
    @vue/babel-sugar-v-model:  1.0.0-beta.2
    @vue/babel-sugar-v-on:  1.0.0-beta.2
    @vue/cli-overlay:  3.5.1
    @vue/cli-plugin-babel: ^3.5.0 => 3.5.1
    @vue/cli-plugin-eslint: ^3.5.0 => 3.5.1
    @vue/cli-service: ^3.5.0 => 3.5.1
    @vue/cli-shared-utils:  3.5.1
    @vue/component-compiler-utils:  2.6.0
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    eslint-plugin-vue: ^5.0.0 => 5.2.2
    vue: ^2.6.6 => 2.6.9
    vue-eslint-parser:  2.0.3
    vue-hot-reload-api:  2.3.3
    vue-loader:  15.7.0
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.21 => 2.6.9
    vue-template-es2015-compiler:  1.9.1
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

新建项目,在.jsx文件内,在render里面使用{/**/}注释时,出现报错(如下)

export default {
  name: 'test',
  data() {
    return {
      msg: 'test'
    }
  },
  render() {
    return (
      <div>
        {/* 注释 */}
        {this.msg}
      </div>
    )
  }
}

报错

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: Property elements[0] of ArrayExpression expected node to be of a type ["null","Expression","SpreadElement"] but instead got "JSXEmptyExpression"
    at validate (E:\rason\job\test\test\node_modules\@babel\types\lib\definitions\utils.js:148:13)
    at validator (E:\rason\job\test\test\node_modules\@babel\types\lib\definitions\utils.js:97:7)
    at Object.validate (E:\rason\job\test\test\node_modules\@babel\types\lib\definitions\utils.js:172:7)
    at validate (E:\rason\job\test\test\node_modules\@babel\types\lib\validators\validate.js:17:9)
    at builder (E:\rason\job\test\test\node_modules\@babel\types\lib\builders\builder.js:46:27)
    at Object.ArrayExpression (E:\rason\job\test\test\node_modules\@babel\types\lib\builders\generated\index.js:239:31)
    at transformJSXElement (E:\rason\job\test\test\node_modules\@vue\babel-plugin-transform-vue-jsx\dist\plugin.js:1:5589)
    at PluginPass.JSXElement (E:\rason\job\test\test\node_modules\@vue\babel-plugin-transform-vue-jsx\dist\plugin.js:1:6518)
    at newFn (E:\rason\job\test\test\node_modules\@babel\traverse\lib\visitors.js:193:21)
    at NodePath._call (E:\rason\job\test\test\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (E:\rason\job\test\test\node_modules\@babel\traverse\lib\path\context.js:40:17)
    at NodePath.visit (E:\rason\job\test\test\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (E:\rason\job\test\test\node_modules\@babel\traverse\lib\context.js:118:16)
    at TraversalContext.visitSingle (E:\rason\job\test\test\node_modules\@babel\traverse\lib\context.js:90:19)
    at TraversalContext.visit (E:\rason\job\test\test\node_modules\@babel\traverse\lib\context.js:146:19)
    at Function.traverse.node (E:\rason\job\test\test\node_modules\@babel\traverse\lib\index.js:94:17)

 @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js& 8:0-53 12:16-26
 @ ./src/App.vue?vue&type=script&lang=js&
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.0.144:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

What is expected?

正常使用{/**/}注释

What is actually happening?

在3.0.4的时候却可以正常使用{/**/}

@JimmyBastos
Copy link

I'm facing the same problem... Any update on this?

@rason00
Copy link
Author

rason00 commented Mar 22, 2019

I'm facing the same problem... Any update on this?

No, I started with 3.0.4, and he can use JSX annotations normally. Now after upgrading, I can only delete all the annotations.

@haoqunjiang
Copy link
Member

Fixed in @vue/babel-preset-jsx 1.0.0-beta.3

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

3 participants