g-plane / swc-plugin-vue-jsx Goto Github PK
View Code? Open in Web Editor NEWSWC plugin for transforming Vue JSX.
Home Page: https://www.npmjs.com/package/swc-plugin-vue-jsx
License: MIT License
SWC plugin for transforming Vue JSX.
Home Page: https://www.npmjs.com/package/swc-plugin-vue-jsx
License: MIT License
* 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?
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
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
thread '' panicked at 'invalid utf8 character detected: FromUtf8Error { bytes: [
Maybe an issue with i18n?
const i18n = createI18n({ legacy: false });
{{ $t('savedsearchform.instantly') }}
optional chain compiled error when I use the plugin
let a = {};
a.b = 1;
let b = a?.b;
var _this;
var a = {};
a.b = 1;
var b = (_this = this) === null || _this === void 0 ? void 0 : _this.; // here
"@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"
{
"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",
{}
]
]
}
},
}
var a = {};
a.b = 1;
var b = a === null || a === void 0 ? void 0 : a.b; // @swc/[email protected] result
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.