mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-07-04 02:53:28 +08:00
fix(jsx-explorer): support browser env
This commit is contained in:
13
packages/jsx-explorer/src/editor.worker.ts
Normal file
13
packages/jsx-explorer/src/editor.worker.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
|
||||
|
||||
// @ts-ignore
|
||||
self.MonacoEnvironment = {
|
||||
globalAPI: true,
|
||||
getWorker(_: any, label: string) {
|
||||
if (label === 'typescript' || label === 'javascript') {
|
||||
return new tsWorker();
|
||||
}
|
||||
return new editorWorker();
|
||||
},
|
||||
};
|
1
packages/jsx-explorer/src/env.d.ts
vendored
Normal file
1
packages/jsx-explorer/src/env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
@ -9,6 +9,7 @@ import {
|
||||
compilerOptions,
|
||||
initOptions,
|
||||
} from './options';
|
||||
import './editor.worker';
|
||||
import './index.css';
|
||||
|
||||
main();
|
||||
@ -100,6 +101,7 @@ const App = defineComponent((props) => <div>Hello World</div>)`,
|
||||
console.log('AST', res.ast!);
|
||||
output.setValue(res.code!);
|
||||
} else {
|
||||
console.error(err);
|
||||
output.setValue(err.message!);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user