@useavalon/avalon 0.1.7 → 0.1.9
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
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
|
|
27
27
|
import type { Plugin } from "vite";
|
|
28
28
|
import type { ResolvedImageConfig } from "./types.ts";
|
|
29
|
+
import { createRequire } from "node:module";
|
|
30
|
+
import { join } from "node:path";
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Creates the vite-imagetools plugin with Avalon's configuration
|
|
@@ -42,8 +44,11 @@ export async function createImagePlugin(
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
try {
|
|
45
|
-
// Dynamic import to avoid hard dependency if user disables images
|
|
46
|
-
|
|
47
|
+
// Dynamic import to avoid hard dependency if user disables images.
|
|
48
|
+
// Use createRequire from the project root so we resolve the package
|
|
49
|
+
// from the consuming project's node_modules, not avalon's own context.
|
|
50
|
+
const require = createRequire(join(process.cwd(), 'package.json'));
|
|
51
|
+
const { imagetools } = require("vite-imagetools");
|
|
47
52
|
|
|
48
53
|
if (verbose) {
|
|
49
54
|
console.log(" 🖼️ Image optimization enabled");
|
|
@@ -282,11 +282,13 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
282
282
|
enforce: "pre",
|
|
283
283
|
|
|
284
284
|
config() {
|
|
285
|
-
// @useavalon packages ship raw .ts source.
|
|
286
|
-
// Vite processes them through the transform pipeline
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
//
|
|
285
|
+
// @useavalon packages ship raw .ts source.
|
|
286
|
+
// - noExternal: Vite processes them through the transform pipeline (SSR)
|
|
287
|
+
// - oxc.exclude: Prevent Vite's built-in OXC from processing them.
|
|
288
|
+
// Integration plugins (react, preact, etc.) set jsx: 'automatic' which
|
|
289
|
+
// OXC then applies to ALL files including plain .ts — causing
|
|
290
|
+
// "Invalid jsx option: automatic" errors. Our transform hook below
|
|
291
|
+
// strips TypeScript without applying any JSX config.
|
|
290
292
|
return {
|
|
291
293
|
ssr: {
|
|
292
294
|
noExternal: [/^@useavalon\//],
|
|
@@ -323,10 +325,10 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
323
325
|
},
|
|
324
326
|
|
|
325
327
|
async transform(code: string, id: string) {
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
//
|
|
328
|
+
// Strip TypeScript from @useavalon packages in node_modules.
|
|
329
|
+
// We exclude these from Vite's OXC (via oxc.exclude) because integration
|
|
330
|
+
// plugins set jsx: 'automatic' which OXC applies to all files, breaking
|
|
331
|
+
// plain .ts files. We handle TS stripping ourselves with no JSX config.
|
|
330
332
|
if (id.includes('node_modules/@useavalon/') && /\.tsx?$/.test(id)) {
|
|
331
333
|
const { transform: oxcTransform } = await import('oxc-transform');
|
|
332
334
|
const result = await oxcTransform(id, code, {
|