@useavalon/avalon 0.1.6 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,15 +1,15 @@
1
- export { type PropExtractionResult, FALLBACK_PROPS, extractVueProps } from "./vue";
2
- export { extractSvelteProps } from "./svelte";
3
- export { extractLitProps } from "./lit";
4
- export { extractSolidProps } from "./solid";
5
- export { extractQwikProps } from "./qwik";
1
+ export { type PropExtractionResult, FALLBACK_PROPS, extractVueProps } from "./vue.ts";
2
+ export { extractSvelteProps } from "./svelte.ts";
3
+ export { extractLitProps } from "./lit.ts";
4
+ export { extractSolidProps } from "./solid.ts";
5
+ export { extractQwikProps } from "./qwik.ts";
6
6
 
7
- import type { PropExtractionResult } from "./vue";
8
- import { extractVueProps } from "./vue";
9
- import { extractSvelteProps } from "./svelte";
10
- import { extractLitProps } from "./lit";
11
- import { extractSolidProps } from "./solid";
12
- import { extractQwikProps } from "./qwik";
7
+ import type { PropExtractionResult } from "./vue.ts";
8
+ import { extractVueProps } from "./vue.ts";
9
+ import { extractSvelteProps } from "./svelte.ts";
10
+ import { extractLitProps } from "./lit.ts";
11
+ import { extractSolidProps } from "./solid.ts";
12
+ import { extractQwikProps } from "./qwik.ts";
13
13
 
14
14
  /** Maps framework name to its prop extractor function */
15
15
  export const EXTRACTOR_MAP: Record<string, (source: string) => PropExtractionResult> = {
@@ -1,4 +1,4 @@
1
- import { FALLBACK_PROPS, type PropExtractionResult } from "./vue";
1
+ import { FALLBACK_PROPS, type PropExtractionResult } from "./vue.ts";
2
2
 
3
3
  /** Mapping from Lit type constructors to TypeScript type strings */
4
4
  const LIT_TYPE_MAP: Record<string, string> = {
@@ -1,5 +1,5 @@
1
- import type { PropExtractionResult } from "./vue";
2
- import { FALLBACK_PROPS } from "./vue";
1
+ import type { PropExtractionResult } from "./vue.ts";
2
+ import { FALLBACK_PROPS } from "./vue.ts";
3
3
 
4
4
  /**
5
5
  * Extract props type from a Qwik component file.
@@ -1,4 +1,4 @@
1
- import { FALLBACK_PROPS, type PropExtractionResult } from "./vue";
1
+ import { FALLBACK_PROPS, type PropExtractionResult } from "./vue.ts";
2
2
 
3
3
  /**
4
4
  * Extract props from a Solid component source string.
@@ -1,4 +1,4 @@
1
- import { FALLBACK_PROPS, type PropExtractionResult } from "./vue";
1
+ import { FALLBACK_PROPS, type PropExtractionResult } from "./vue.ts";
2
2
 
3
3
  /**
4
4
  * Extract props from a Svelte component source string.
@@ -362,7 +362,7 @@ export type {
362
362
  ValidRoutePattern,
363
363
  ValidRouteExtension,
364
364
  PageComponentProps,
365
- } from '../types/routing';
365
+ } from '../types/routing.ts';
366
366
 
367
367
  export {
368
368
  isValidRouteParams,
@@ -373,4 +373,4 @@ export {
373
373
  createTypedMetadataGenerator,
374
374
  createTypedPageLoader,
375
375
  createTypedApiHandler,
376
- } from '../types/routing';
376
+ } from '../types/routing.ts';
@@ -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");
@@ -43,7 +43,7 @@ function resolveAvalonPackagePath(relativePath: string): string {
43
43
  * Resolves the absolute path to a file inside an @useavalon/<name> integration package.
44
44
  */
45
45
  function resolveIntegrationPackagePath(name: string, relativePath: string): string {
46
- const require = createRequire(import.meta.url);
46
+ const require = createRequire(join(process.cwd(), 'package.json'));
47
47
  const modEntry = require.resolve(`@useavalon/${name}`);
48
48
  const pkgRoot = dirname(modEntry);
49
49
  return join(pkgRoot, relativePath);
@@ -269,14 +269,12 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
269
269
  }
270
270
 
271
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
- }
279
- }
272
+ // These are resolved dynamically in the resolveId hook using Vite's resolver
273
+ const integrationClientIds = new Set(
274
+ ['preact', 'react', 'vue', 'svelte', 'solid', 'lit', 'qwik'].map(
275
+ name => `/@useavalon/${name}/client`
276
+ )
277
+ );
280
278
 
281
279
  // The main Avalon plugin
282
280
  const avalonPlugin: Plugin = {
@@ -285,17 +283,13 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
285
283
 
286
284
  config() {
287
285
  // @useavalon packages ship raw .ts source. Mark them as noExternal so
288
- // Vite processes them through the transform pipeline. Also exclude them
289
- // from Vite's built-in OXC transform (which applies the project's jsx
290
- // config and fails on plain .ts files). Our own transform hook below
291
- // 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.
292
289
  return {
293
290
  ssr: {
294
291
  noExternal: [/^@useavalon\//],
295
292
  },
296
- oxc: {
297
- exclude: [/node_modules\/@useavalon\//],
298
- },
299
293
  };
300
294
  },
301
295
 
@@ -309,30 +303,21 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
309
303
  checkDirectoriesExist(resolvedConfig, resolvedViteConfig.root);
310
304
  },
311
305
 
312
- resolveId(id: string) {
306
+ async resolveId(id: string) {
313
307
  if (id === "/src/client/main.js" && clientMainResolved) {
314
308
  return clientMainResolved;
315
309
  }
316
- if (id in integrationClientMap && integrationClientMap[id]) {
317
- return integrationClientMap[id];
310
+ // /@useavalon/*/client resolve through Vite's pipeline so it finds
311
+ // workspace-linked or npm-installed integration packages from the
312
+ // consuming project's node_modules, not from avalon's own context.
313
+ if (integrationClientIds.has(id)) {
314
+ const packageId = id.slice(1); // strip leading /
315
+ const resolved = await this.resolve(packageId);
316
+ return resolved?.id ?? null;
318
317
  }
319
318
  return null;
320
319
  },
321
320
 
322
- async transform(code: string, id: string) {
323
- // Vite 8's OXC transform applies the project's jsx config to ALL .ts files,
324
- // including those in node_modules/@useavalon. OXC rejects jsx options for
325
- // plain .ts files. Strip TypeScript ourselves for @useavalon packages so
326
- // Vite's built-in OXC doesn't need to touch them.
327
- if (id.includes('node_modules/@useavalon/') && /\.tsx?$/.test(id)) {
328
- const { transform: oxcTransform } = await import('oxc-transform');
329
- const result = await oxcTransform(id, code, {
330
- typescript: { onlyRemoveTypeImports: false },
331
- });
332
- return { code: result.code, map: result.map };
333
- }
334
- },
335
-
336
321
  async buildStart() {
337
322
  await runAutoDiscovery(resolvedConfig, viteConfig?.root, activeIntegrations);
338
323
  runValidation(resolvedConfig, activeIntegrations);