FranckFreiburger / http-vue-loader

load .vue files from your html/js
MIT License
1.49k stars 275 forks source link

is it possible to use JSX? #126

Open luman-web opened 3 years ago

luman-web commented 3 years ago

i'm using the following preset to make jsx working in project https://github.com/vuejs/jsx jsx renders perfectly within components that i create in source code of my project, but when i'm trying to execute component code using http-vue-loader, it falis.

here's what i'm trying to execute

<script>
module.exports = {
  render() {
     return <div>test 123</div>
  },
}
</script>

so i'm getting the following error output

vue.esm.js?a026:628 [Vue warn]: Failed to resolve async component: function() {
  return new Component(name).load(url)
  .then(function(component) {

    return component.normalize();
  })
  .then(function(component) {

    return component.compile();
  })
  .then(function(component) {

    var exports = component.script !== null ? component.script.module.exports : {};

    if ( component.template !== null )
      exports.template = component.template.getContent();

    if ( exports.name === undefined )
      if ( component.name !== undefined )
        exports.name = component.name;

    exports._baseURI = component.baseURI;

    return exports;
  });
}
Reason: SyntaxError: Unexpected token '<'

any chance to make the jsx code work with http-vue-loader?

Toilal commented 3 years ago

Use <script lang="jsx"> and implement the transformation manually in httpVueLoader.langProcessor.jsx