mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-10 08:19:10 +08:00
refactor(jsx-explorer): replace @babel/core
with @babel/standalone
This commit is contained in:
parent
455ae7182d
commit
4bd09577cc
@ -9,14 +9,14 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
"@babel/standalone": "^7.25.6",
|
||||
"@vue/babel-plugin-jsx": "workspace:*",
|
||||
"assert": "^2.1.0",
|
||||
"monaco-editor": "^0.51.0",
|
||||
"pathe": "^1.1.2",
|
||||
"vue": "^3.5.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/babel__standalone": "^7.1.7",
|
||||
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
||||
"terser": "^5.31.6",
|
||||
"unplugin-replace": "^0.3.3",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as monaco from 'monaco-editor';
|
||||
import { watchEffect } from 'vue';
|
||||
import { transform } from '@babel/core';
|
||||
import { transform } from '@babel/standalone';
|
||||
import babelPluginJsx from '@vue/babel-plugin-jsx';
|
||||
// @ts-expect-error missing types
|
||||
import typescript from '@babel/plugin-syntax-typescript';
|
||||
@ -85,27 +85,21 @@ const App = defineComponent((props) => <div>Hello World</div>)`,
|
||||
localStorage.setItem('state', state);
|
||||
window.location.hash = encodeURIComponent(src);
|
||||
console.clear();
|
||||
transform(
|
||||
src,
|
||||
{
|
||||
try {
|
||||
const res = transform(src, {
|
||||
babelrc: false,
|
||||
plugins: [
|
||||
[babelPluginJsx, { ...compilerOptions }],
|
||||
[typescript, { isTSX: true }],
|
||||
],
|
||||
ast: true,
|
||||
},
|
||||
(err, result = {}) => {
|
||||
const res = result!;
|
||||
if (!err) {
|
||||
});
|
||||
console.log('AST', res.ast!);
|
||||
output.setValue(res.code!);
|
||||
} else {
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
output.setValue(err.message!);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// handle resize
|
||||
|
@ -9,7 +9,6 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@vue/babel-plugin-jsx': '@vue/babel-plugin-jsx/src/index.ts',
|
||||
path: 'pathe',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
@ -17,10 +16,6 @@ export default defineConfig({
|
||||
Replace({
|
||||
values: {
|
||||
'process.env.BABEL_TYPES_8_BREAKING': 'false',
|
||||
'process.env.BABEL_ENV': '"development"',
|
||||
'process.env.NODE_NDEBUG': 'true',
|
||||
'process.env.NODE_DEBUG': 'false',
|
||||
'Buffer.isBuffer': 'function isBuffer() { return false; }',
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
22
pnpm-lock.yaml
generated
22
pnpm-lock.yaml
generated
@ -165,9 +165,9 @@ importers:
|
||||
|
||||
packages/jsx-explorer:
|
||||
dependencies:
|
||||
'@babel/core':
|
||||
specifier: ^7.25.2
|
||||
version: 7.25.2
|
||||
'@babel/standalone':
|
||||
specifier: ^7.25.6
|
||||
version: 7.25.6
|
||||
'@vue/babel-plugin-jsx':
|
||||
specifier: workspace:*
|
||||
version: link:../babel-plugin-jsx
|
||||
@ -184,6 +184,9 @@ importers:
|
||||
specifier: ^3.5.3
|
||||
version: 3.5.3(typescript@5.5.4)
|
||||
devDependencies:
|
||||
'@types/babel__standalone':
|
||||
specifier: ^7.1.7
|
||||
version: 7.1.7
|
||||
'@vitejs/plugin-vue-jsx':
|
||||
specifier: ^4.0.1
|
||||
version: 4.0.1(vite@5.4.3(@types/node@22.5.4)(terser@5.31.6))(vue@3.5.3(typescript@5.5.4))
|
||||
@ -785,6 +788,10 @@ packages:
|
||||
resolution: {integrity: sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/standalone@7.25.6':
|
||||
resolution: {integrity: sha512-Kf2ZcZVqsKbtYhlA7sP0z5A3q5hmCVYMKMWRWNK/5OVwHIve3JY1djVRmIVAx8FMueLIfZGKQDIILK2w8zO4mg==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/template@7.25.0':
|
||||
resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
@ -1289,6 +1296,9 @@ packages:
|
||||
'@types/babel__helper-plugin-utils@7.10.3':
|
||||
resolution: {integrity: sha512-FcLBBPXInqKfULB2nvOBskQPcnSMZ0s1Y2q76u9H1NPPWaLcTeq38xBeKfF/RBUECK333qeaqRdYoPSwW7rTNQ==}
|
||||
|
||||
'@types/babel__standalone@7.1.7':
|
||||
resolution: {integrity: sha512-4RUJX9nWrP/emaZDzxo/+RYW8zzLJTXWJyp2k78HufG459HCz754hhmSymt3VFOU6/Wy+IZqfPvToHfLuGOr7w==}
|
||||
|
||||
'@types/babel__template@7.4.4':
|
||||
resolution: {integrity: sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==}
|
||||
|
||||
@ -3792,6 +3802,8 @@ snapshots:
|
||||
dependencies:
|
||||
regenerator-runtime: 0.14.1
|
||||
|
||||
'@babel/standalone@7.25.6': {}
|
||||
|
||||
'@babel/template@7.25.0':
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.24.7
|
||||
@ -4147,6 +4159,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/babel__core': 7.20.5
|
||||
|
||||
'@types/babel__standalone@7.1.7':
|
||||
dependencies:
|
||||
'@types/babel__core': 7.20.5
|
||||
|
||||
'@types/babel__template@7.4.4':
|
||||
dependencies:
|
||||
'@babel/parser': 7.25.6
|
||||
|
Loading…
Reference in New Issue
Block a user