Skip to content

Commit d99206b

Browse files
committed
refactor(jsx-explorer): dogfooding of JSX syntax
1 parent 9d97341 commit d99206b

File tree

6 files changed

+205
-119
lines changed

6 files changed

+205
-119
lines changed

packages/jsx-explorer/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"vue": "^3.4.15"
1616
},
1717
"devDependencies": {
18+
"@vitejs/plugin-vue-jsx": "^3.1.0",
19+
"vite-plugin-monaco-editor": "^1.1.0",
1820
"vite-plugin-node-polyfills": "^0.19.0"
1921
}
2022
}

packages/jsx-explorer/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function main() {
7474
src,
7575
{
7676
babelrc: false,
77-
plugins: [[babelPluginJsx, compilerOptions]],
77+
plugins: [[babelPluginJsx, { ...compilerOptions }]],
7878
ast: true,
7979
},
8080
(err, result = {}) => {

packages/jsx-explorer/src/options.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.

packages/jsx-explorer/src/options.tsx

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { createApp, defineComponent, reactive } from 'vue';
2+
import { type VueJSXPluginOptions } from '@vue/babel-plugin-jsx';
3+
4+
export { VueJSXPluginOptions };
5+
6+
export const compilerOptions: VueJSXPluginOptions = reactive({
7+
mergeProps: true,
8+
optimize: false,
9+
transformOn: false,
10+
enableObjectSlots: true,
11+
resolveType: false,
12+
});
13+
14+
const App = defineComponent({
15+
setup() {
16+
return () => [
17+
<>
18+
<h1>Vue 3 JSX Explorer</h1>
19+
<a
20+
href="https://app.netlify.com/sites/vue-jsx-explorer/deploys"
21+
target="_blank"
22+
>
23+
History
24+
</a>
25+
<div id="options-wrapper">
26+
<div id="options-label">Options ↘</div>
27+
<ul id="options">
28+
<li>
29+
<input
30+
type="checkbox"
31+
id="mergeProps"
32+
name="mergeProps"
33+
checked={compilerOptions.mergeProps}
34+
onChange={(e: Event) => {
35+
compilerOptions.mergeProps = (
36+
e.target as HTMLInputElement
37+
).checked;
38+
}}
39+
/>
40+
<label for="mergeProps">mergeProps</label>
41+
</li>
42+
43+
<li>
44+
<input
45+
type="checkbox"
46+
id="optimize"
47+
name="optimize"
48+
checked={compilerOptions.optimize}
49+
onChange={(e: Event) => {
50+
compilerOptions.optimize = (
51+
e.target as HTMLInputElement
52+
).checked;
53+
}}
54+
/>
55+
<label for="optimize">optimize</label>
56+
</li>
57+
58+
<li>
59+
<input
60+
type="checkbox"
61+
id="transformOn"
62+
name="transformOn"
63+
checked={compilerOptions.transformOn}
64+
onChange={(e: Event) => {
65+
compilerOptions.transformOn = (
66+
e.target as HTMLInputElement
67+
).checked;
68+
}}
69+
/>
70+
<label for="transformOn">transformOn</label>
71+
</li>
72+
73+
<li>
74+
<input
75+
type="checkbox"
76+
id="enableObjectSlots"
77+
name="enableObjectSlots"
78+
checked={compilerOptions.enableObjectSlots}
79+
onChange={(e: Event) => {
80+
compilerOptions.enableObjectSlots = (
81+
e.target as HTMLInputElement
82+
).checked;
83+
}}
84+
/>
85+
<label for="enableObjectSlots">enableObjectSlots</label>
86+
</li>
87+
88+
<li>
89+
<input
90+
type="checkbox"
91+
id="resolveType"
92+
name="resolveType"
93+
checked={!!compilerOptions.resolveType}
94+
onChange={(e: Event) => {
95+
compilerOptions.resolveType = (
96+
e.target as HTMLInputElement
97+
).checked;
98+
}}
99+
/>
100+
<label for="resolveType">resolveType</label>
101+
</li>
102+
</ul>
103+
</div>
104+
</>,
105+
];
106+
},
107+
});
108+
109+
export function initOptions() {
110+
createApp(App).mount(document.getElementById('header')!);
111+
}

packages/jsx-explorer/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { defineConfig } from 'vite';
22
import { nodePolyfills } from 'vite-plugin-node-polyfills';
3+
import VueJSX from '@vitejs/plugin-vue-jsx';
4+
import MonacoEditorPlugin from 'vite-plugin-monaco-editor';
35

46
export default defineConfig({
57
resolve: {
@@ -8,6 +10,11 @@ export default defineConfig({
810
},
911
},
1012
plugins: [
13+
VueJSX(),
14+
// @ts-expect-error
15+
(MonacoEditorPlugin.default as typeof MonacoEditorPlugin)({
16+
languageWorkers: ['editorWorkerService', 'typescript'],
17+
}),
1118
nodePolyfills({
1219
globals: {
1320
process: true,

0 commit comments

Comments
 (0)