@useavalon/avalon 0.1.7 → 0.1.8
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");
|
|
@@ -283,17 +283,13 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
283
283
|
|
|
284
284
|
config() {
|
|
285
285
|
// @useavalon packages ship raw .ts source. Mark them as noExternal so
|
|
286
|
-
// Vite processes them through the transform pipeline.
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
// handles TS stripping for these files instead.
|
|
286
|
+
// Vite processes them through the transform pipeline (SSR).
|
|
287
|
+
// For client-side, Vite's built-in OXC plugin handles .ts stripping
|
|
288
|
+
// and sets moduleType: 'js' automatically.
|
|
290
289
|
return {
|
|
291
290
|
ssr: {
|
|
292
291
|
noExternal: [/^@useavalon\//],
|
|
293
292
|
},
|
|
294
|
-
oxc: {
|
|
295
|
-
exclude: [/node_modules\/@useavalon\//],
|
|
296
|
-
},
|
|
297
293
|
};
|
|
298
294
|
},
|
|
299
295
|
|
|
@@ -322,21 +318,6 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
|
|
|
322
318
|
return null;
|
|
323
319
|
},
|
|
324
320
|
|
|
325
|
-
async transform(code: string, id: string) {
|
|
326
|
-
// Vite 8's built-in OXC plugin returns { moduleType: "js" } so the dev
|
|
327
|
-
// server knows the output is JavaScript. Because we exclude @useavalon
|
|
328
|
-
// packages from that plugin (via oxc.exclude), we must strip TypeScript
|
|
329
|
-
// ourselves AND set moduleType so the browser receives valid JS.
|
|
330
|
-
if (id.includes('node_modules/@useavalon/') && /\.tsx?$/.test(id)) {
|
|
331
|
-
const { transform: oxcTransform } = await import('oxc-transform');
|
|
332
|
-
const result = await oxcTransform(id, code, {
|
|
333
|
-
sourcemap: true,
|
|
334
|
-
typescript: { onlyRemoveTypeImports: false },
|
|
335
|
-
});
|
|
336
|
-
return { code: result.code, map: result.map, moduleType: 'js' };
|
|
337
|
-
}
|
|
338
|
-
},
|
|
339
|
-
|
|
340
321
|
async buildStart() {
|
|
341
322
|
await runAutoDiscovery(resolvedConfig, viteConfig?.root, activeIntegrations);
|
|
342
323
|
runValidation(resolvedConfig, activeIntegrations);
|