Coder Social home page Coder Social logo

g-plane / swc-plugin-vue-jsx Goto Github PK

View Code? Open in Web Editor NEW
83.0 2.0 6.0 432 KB

SWC plugin for transforming Vue JSX.

Home Page: https://www.npmjs.com/package/swc-plugin-vue-jsx

License: MIT License

Rust 98.77% TypeScript 1.23%
jsx swc-plugin vue

swc-plugin-vue-jsx's People

Contributors

g-plane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

swc-plugin-vue-jsx's Issues

error: thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("vueJsx.jsx")'

*  Executing task: npm run vueJsx 


> [email protected] vueJsx
> swc ./vueJsx.jsx -o vueJsx.out.js

Successfully compiled 1 file with swc.
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: npm run vueJsx 


> [email protected] vueJsx
> swc ./vueJsx.jsx -o vueJsx.out.js

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("vueJsx.jsx")'

Caused by:
    0: failed to invoke `swc-plugin-vue-jsx` as js transform plugin at node_modules\swc-plugin-vue-jsx\swc_plugin_vue_jsx.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[1429]:0xf8502)
           at <unnamed> (<module>[1462]:0x102a10)
    2: heap_get_oob', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\swc-0.255.18\src\plugin.rs:228:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failed to handle: failed to invoke plugin: failed to invoke plugin on 'Some("vueJsx.jsx")'

Caused by:
    0: failed to invoke `swc-plugin-vue-jsx` as js transform plugin at node_modules\swc-plugin-vue-jsx\swc_plugin_vue_jsx.wasm
    1: RuntimeError: out of bounds memory access
           at <unnamed> (<module>[1429]:0xf8502)
           at <unnamed> (<module>[1462]:0x102a10)
    2: heap_get_oob
Error: Failed to compile 1 file with swc.
    at Object.assertCompilationResult (D:\html-test\tool-test\swc\node_modules\@swc\cli\lib\swc\util.js:149:15)
    at files (D:\html-test\tool-test\swc\node_modules\@swc\cli\lib\swc\file.js:201:19)
    at async _default (D:\html-test\tool-test\swc\node_modules\@swc\cli\lib\swc\file.js:220:9)

 *  The terminal process "C:\Users\viruser.v-desktop\AppData\Local\Programs\Git\bin\bash.exe '--login', '-i', '-c', 'npm run vueJsx'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

.swcrc

{
  "env": {
    "targets": {
      "chrome": "49"
    },
    "mode": "usage",
    "coreJs": "3.29",
  },
  "jsc": {
    "parser": {
      "syntax": "ecmascript", // 'typescript'
      "jsx": true
    },
    "externalHelpers": true,
    "experimental": {
      "plugins": [
        [
          "swc-plugin-vue-jsx",
          {}
        ]
      ]
    }
  },
}

dependencies

 "devDependencies": {
    "@swc/cli": "^0.1.62",
    "@swc/core": "^1.3.42",
    "@swc/helpers": "^0.4.14",
    "browserslist": "^4.21.3",
    "core-js": "^3.29.1",
    "swc-plugin-vue-jsx": "^0.2.1"
  },
  "dependencies": {
    "vue": "^3.2.47"
  }

How to use the plugin. Is there something I done error?

thread '<unnamed>' panicked at 'failed to invoke plugin: failed to invoke plugin on 'Some("H:\\syc-eds-front\\src\\views\\Bus\\component\\NodeState\\index.jsx")'

image

image

The .swcrc configuration is as follows

{
    "isModule": true,
    "sourceMaps": true,
    "inlineSourcesContent": true,
    "jsc": {
        "target": "esnext",
        "parser": {
          "syntax": "ecmascript",
          "jsx": true,
          "dynamicImport": true,
          "privateMethod": true,
          "functionBind": true,
          "exportDefaultFrom": true,
          "exportNamespaceFrom": true,
          "decorators": true,
          "decoratorsBeforeExport": true,
          "topLevelAwait": true,
          "importMeta": true
        },
        "experimental": {
          "plugins": [["swc-plugin-vue-jsx", {
            "transformOn": true,
            "optimize": true
          }]]
        }
    }
  }
    "swc-loader": "^0.2.3",
    "swc-plugin-vue-jsx": "^0.2.5",
    "@swc/core": "^1.3.80"

An error is reported when the relevant route is encountered

error:faild in latest swc/core

Caused by:
    0: failed to invoke `swc-plugin-vue-jsx` as js transform plugin at node_modules/swc-plugin-vue-jsx/swc_plugin_vue_jsx.wasm
    1: RuntimeError: unreachable
           at <unnamed> (<module>[935]:0x7f49e)
           at <unnamed> (<module>[888]:0x7caa4)
           at <unnamed> (<module>[938]:0x7f628)
           at <unnamed> (<module>[937]:0x7f5df)
           at <unnamed> (<module>[311]:0x29deb)
           at <unnamed> (<module>[257]:0x277a4)
           at <unnamed> (<module>[88]:0x1c0d4)
           at <unnamed> (<module>[1418]:0xf1689)
           at <unnamed> (<module>[1445]:0xfb6ee)
           at <unnamed> (<module>[1552]:0x11aece)
           at <unnamed> (<module>[1231]:0xb9102)
           at <unnamed> (<module>[1290]:0xcbdea)
           at <unnamed> (<module>[1202]:0xb430d)
           at <unnamed> (<module>[1289]:0xc9de3)
           at <unnamed> (<module>[1208]:0xb554d)
           at <unnamed> (<module>[1420]:0xf250a)
           at <unnamed> (<module>[1433]:0xf7930)
           at <unnamed> (<module>[1455]:0xfc52b)

//package.json
"dependencies": {
    "vue": "^3.2.47"
  },
  "devDependencies": {
    "@swc/core": "^1.3.57",
    "rollup-plugin-swc3": "^0.8.1",
    "@types/node": "^18.14.0",
    "@vitejs/plugin-vue": "^4.0.0",
    "@vue/tsconfig": "^0.1.3",
    "npm-run-all": "^4.1.5",
    "swc-plugin-vue-jsx": "^0.2.3",
    "typescript": "next",
    "vite": "^4.1.3",
    "vue-tsc": "^1.1.5"
  }
//vite.config.js
import { fileURLToPath, URL } from 'node:url'
import { swc } from "rollup-plugin-swc3";
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),swc({
    include: /\.[mc]?[jt]sx?$/,
    exclude: /node_modules/,
    tsconfig: 'tsconfig.json',
    jsc: {
      experimental:{
        plugins:[['swc-plugin-vue-jsx',{}]]
      }
    }
  })],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})

It works in swc/core 1.3.49

Cryptic error.

thread '' panicked at 'invalid utf8 character detected: FromUtf8Error { bytes: [

Maybe an issue with i18n?

const i18n = createI18n({ legacy: false });

{{ $t('savedsearchform.instantly') }}

optional chain error (@swc/core>=1.3.63)

optional chain compiled error when I use the plugin

source

let a = {};
a.b = 1;
let b = a?.b;

after compiled

var _this;
var a = {};
a.b = 1;
var b = (_this = this) === null || _this === void 0 ? void 0 : _this.; // here

depdencies

"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.66",
"@swc/helpers": "^0.5.1",
"browserslist": "^4.21.3",
"core-js": "^3.31.0",
"swc-plugin-vue-jsx": "^0.2.4"

.swcrc

{
  "env": {
    "targets": {
      "chrome": "49"
    },
    "mode": "usage",
    "coreJs": "3.31",
  },
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": true
    },
    "externalHelpers": true,
    "experimental": {
      "plugins": [  // remove the plugin will be normal
        [
          "swc-plugin-vue-jsx",
          {}
        ]
      ]
    }
  },
}

expected behavior

var a = {};
a.b = 1;
var b = a === null || a === void 0 ? void 0 : a.b; // @swc/[email protected] result

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.