@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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
- const { imagetools } = await import("vite-imagetools");
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. Mark them as noExternal so
286
- // Vite processes them through the transform pipeline. Also exclude them
287
- // from Vite's built-in OXC transform (which applies the project's jsx
288
- // config and fails on plain .ts files). Our own transform hook below
289
- // handles TS stripping for these files instead.
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
- // 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.
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, {