what-compiler 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "what-compiler",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "JSX compiler for What Framework - transforms JSX to optimized DOM operations",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -38,11 +38,11 @@
38
38
  "license": "MIT",
39
39
  "peerDependencies": {
40
40
  "@babel/core": "^7.0.0",
41
- "what-core": "^0.11.0"
41
+ "what-core": "^0.11.2"
42
42
  },
43
43
  "files": [
44
44
  "src",
45
- "dist"
45
+ "dist/**/*.min.js"
46
46
  ],
47
47
  "devDependencies": {
48
48
  "@babel/core": "^7.23.0",
@@ -17,6 +17,41 @@ import { setupErrorOverlay } from './error-overlay.js';
17
17
  const VIRTUAL_ROUTES_ID = 'virtual:what-routes';
18
18
  const RESOLVED_VIRTUAL_ID = '\0' + VIRTUAL_ROUTES_ID;
19
19
 
20
+ /**
21
+ * Shape the "preserve JSX" transform config for the running Vite version.
22
+ *
23
+ * Vite ≤7 transforms with esbuild and takes `esbuild: { jsx: 'preserve' }`.
24
+ * Vite 8 (rolldown-based) transforms with oxc; the `esbuild` key still works
25
+ * but prints a deprecation warning on every dev/build run
26
+ * ("'esbuild' option ... is deprecated, please use 'oxc' instead"), so we
27
+ * emit `oxc: { jsx: 'preserve' }` there instead.
28
+ *
29
+ * Detection (either signal selects oxc):
30
+ * - feature: rolldown-vite exposes `this.meta.rolldownVersion` to plugins —
31
+ * the most reliable signal, also covers `rolldown-vite` aliased as vite 7.
32
+ * - version: `import('vite')` exports `version`; major ≥ 8 means rolldown.
33
+ *
34
+ * Exported for unit tests.
35
+ */
36
+ export function jsxPreserveConfig({ rolldownVersion, viteVersion } = {}) {
37
+ const major = parseInt(String(viteVersion ?? ''), 10);
38
+ const useOxc = Boolean(rolldownVersion) || (Number.isFinite(major) && major >= 8);
39
+ return useOxc
40
+ ? { oxc: { jsx: 'preserve' } }
41
+ : { esbuild: { jsx: 'preserve' } };
42
+ }
43
+
44
+ // Resolved once per process — the Vite version can't change mid-run.
45
+ let viteVersionPromise = null;
46
+ function detectViteVersion() {
47
+ if (!viteVersionPromise) {
48
+ viteVersionPromise = import('vite')
49
+ .then((vite) => vite.version || '')
50
+ .catch(() => ''); // vite not resolvable (tests) — esbuild fallback
51
+ }
52
+ return viteVersionPromise;
53
+ }
54
+
20
55
  // Pattern: exported function starting with uppercase = component
21
56
  const COMPONENT_EXPORT_RE = /export\s+(?:default\s+)?function\s+([A-Z]\w*)/;
22
57
  // Pattern: files that are likely signal/store/utility files
@@ -177,7 +212,7 @@ export default function whatVitePlugin(options = {}) {
177
212
  },
178
213
 
179
214
  // Configure for development
180
- config(config, { mode, command }) {
215
+ async config(config, { mode, command }) {
181
216
  // SPRINT v0.11 C7: make the `production` exports condition reachable.
182
217
  // what-framework/what-core ship pre-minified production bundles behind
183
218
  // the `production` condition in their exports maps, but Vite's default
@@ -196,12 +231,16 @@ export default function whatVitePlugin(options = {}) {
196
231
  // of the defaults), so import/browser/default resolution for other
197
232
  // packages is unaffected.
198
233
  const useProdCondition = command === 'build' && mode === 'production' && prodBundles;
234
+ // Preserve JSX so our babel plugin handles it — don't let the bundler's
235
+ // built-in transformer (esbuild on Vite ≤7, oxc on Vite 8+) touch it.
236
+ // jsxPreserveConfig picks the right option key for the running version.
237
+ const jsxPreserve = jsxPreserveConfig({
238
+ rolldownVersion: this?.meta?.rolldownVersion,
239
+ viteVersion: await detectViteVersion(),
240
+ });
199
241
  return {
200
242
  ...(useProdCondition ? { resolve: { conditions: ['production'] } } : {}),
201
- esbuild: {
202
- // Preserve JSX so our babel plugin handles it -- don't let esbuild transform it
203
- jsx: 'preserve',
204
- },
243
+ ...jsxPreserve,
205
244
  optimizeDeps: {
206
245
  // Exclude framework packages from Vite's dependency pre-bundling.
207
246
  //