Giter VIP home page Giter VIP logo

Comments (15)

theWorkFsz avatar theWorkFsz commented on May 16, 2024 22

@iwangx if you use vue-cli to create your project,then you should toggle the injectH feature in @vue/app jsx options like this

module.exports = {
  presets: [
    [
      "@vue/app",
      {
        useBuiltIns: "entry",
        jsx: {
          injectH: false
        }
      }
    ]
  ]
};

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024 10

@iwangx, just to fix it for the moment you can disable injectH in babel config like this:

{
  "presets": [
    [
      "@vue/babel-preset-jsx",
      {
        "injectH": false
      }
    ]
  ]
}

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024 3

So when I npm run serve ,console log

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /Users/***/view.vue: Duplicate declaration "h" (This is an error on an internal node. Probably an internal error.)

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024 3

@iwangx, since you use weird h passing around, we probably don't want to support this, but you can build this project if you turn it off, you can do it by using this babel config:

module.exports = {
  presets: [
    ['@vue/babel-preset-jsx', {
      injectH: false
    }],
    ['@vue/app', {
      useBuiltIns: 'entry'
    }],
  ],
  'plugins': [
    [ 'component', {
      'libraryName': 'element-ui',
      'styleLibraryName': 'theme-chalk'
    } ],
  ]
};

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024

@iwangx, to make it simpler, can you please create a basic reproduction repository on github?

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

@nickmessing it ok.but a new error was added

[Vue warn]: Error in data(): "TypeError: Cannot read property '$createElement' of undefined"

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

@nickmessing
https://github.com/iwangx/jsx-example

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024

@iwangx, thank you for the reproduction, I'll check it once I get to my computer

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

@nickmessing , I don't think plug-ins should define 'h' by themselves. Usually, we define 'h' by ourselves and look for the variable 'h' from the nearest scope.

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024

When you turned off injectH it's disabled so there are two different bugs involved, probably... Not just the h injection

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

So I hope you can solve this problem as soon as possible.

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

@nickmessing
The problem still exists.

[Vue warn]: Error in data(): "TypeError: Cannot read property '$createElement' of undefined"

from jsx-vue2.

nickmessing avatar nickmessing commented on May 16, 2024

@iwangx, I just changed babel config to the one I provided in your repo and it builds fine...

from jsx-vue2.

iwangx avatar iwangx commented on May 16, 2024

@nickmessing But this error will be output in the browser console

from jsx-vue2.

towry avatar towry commented on May 16, 2024

Some tool like storybook for vue has its own configuration so you need remove babel-plugin-transform-vue-jsx plugin in your babel config like in babel.config.js.

export TARGET=story && npm run storybook

In babel.config.js:

// only add this plugin if it is not in storybook mode.
if (process.env.TARGET !== 'story') {
    module.exports.plugin.push( `babel-plugin-transform-vue-jsx` );
}

from jsx-vue2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.