mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-07-02 10:03:25 +08:00
refactor(jsx-explorer): replace @babel/core
with @babel/standalone
This commit is contained in:
@ -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 {
|
||||
console.error(err);
|
||||
output.setValue(err.message!);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
console.log('AST', res.ast!);
|
||||
output.setValue(res.code!);
|
||||
} 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; }',
|
||||
},
|
||||
}),
|
||||
],
|
||||
|
Reference in New Issue
Block a user