@useavalon/avalon 0.1.3 → 0.1.4
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 +1 -1
- package/src/vite-plugin/plugin.ts +30 -8
package/package.json
CHANGED
|
@@ -256,16 +256,26 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
256
256
|
verbose: preResolvedConfig.verbose,
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
//
|
|
260
|
-
// In the monorepo www/ project
|
|
261
|
-
|
|
259
|
+
// Pre-resolve paths for standalone projects.
|
|
260
|
+
// In the monorepo www/ project these are handled by manual resolve.alias.
|
|
261
|
+
const require = createRequire(import.meta.url);
|
|
262
|
+
|
|
262
263
|
let clientMainResolved: string | null = null;
|
|
263
264
|
try {
|
|
264
|
-
const require = createRequire(import.meta.url);
|
|
265
265
|
const clientEntry = require.resolve("@useavalon/avalon/client");
|
|
266
266
|
clientMainResolved = join(dirname(clientEntry), "main.js");
|
|
267
267
|
} catch {
|
|
268
|
-
//
|
|
268
|
+
// Monorepo — www/ sets its own alias
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Resolve /@useavalon/*/client virtual imports used by main.js
|
|
272
|
+
const integrationClientMap: Record<string, string | null> = {};
|
|
273
|
+
for (const name of ['preact', 'react', 'vue', 'svelte', 'solid', 'lit', 'qwik']) {
|
|
274
|
+
try {
|
|
275
|
+
integrationClientMap[`/@useavalon/${name}/client`] = require.resolve(`@useavalon/${name}/client`);
|
|
276
|
+
} catch {
|
|
277
|
+
integrationClientMap[`/@useavalon/${name}/client`] = null;
|
|
278
|
+
}
|
|
269
279
|
}
|
|
270
280
|
|
|
271
281
|
// The main Avalon plugin
|
|
@@ -273,6 +283,18 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
273
283
|
name: "avalon",
|
|
274
284
|
enforce: "pre",
|
|
275
285
|
|
|
286
|
+
config() {
|
|
287
|
+
// Vite 8 uses OXC for TS/JSX transform. When the project tsconfig sets
|
|
288
|
+
// jsx: "react-jsx", Vite passes jsx options to OXC for ALL .ts files
|
|
289
|
+
// including those in node_modules/@useavalon. OXC rejects this for plain
|
|
290
|
+
// .ts files that don't contain JSX. Exclude @useavalon packages from OXC.
|
|
291
|
+
return {
|
|
292
|
+
oxc: {
|
|
293
|
+
exclude: [/node_modules\/@useavalon\//],
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
|
|
276
298
|
configResolved(resolvedViteConfig: ResolvedConfig) {
|
|
277
299
|
viteConfig = resolvedViteConfig;
|
|
278
300
|
const isDev = resolvedViteConfig.command === "serve";
|
|
@@ -284,12 +306,12 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
284
306
|
},
|
|
285
307
|
|
|
286
308
|
resolveId(id: string) {
|
|
287
|
-
// Resolve /src/client/main.js to the actual file inside @useavalon/avalon.
|
|
288
|
-
// The SSR renderer injects <script src="/src/client/main.js"> into HTML.
|
|
289
|
-
// Without this alias, standalone projects get a 404.
|
|
290
309
|
if (id === "/src/client/main.js" && clientMainResolved) {
|
|
291
310
|
return clientMainResolved;
|
|
292
311
|
}
|
|
312
|
+
if (id in integrationClientMap && integrationClientMap[id]) {
|
|
313
|
+
return integrationClientMap[id];
|
|
314
|
+
}
|
|
293
315
|
return null;
|
|
294
316
|
},
|
|
295
317
|
|