@useavalon/avalon 0.1.6 → 0.1.7

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.7",
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';
@@ -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 = {
@@ -309,27 +307,33 @@ export async function avalon(config?: AvalonPluginConfig): Promise<PluginOption[
309
307
  checkDirectoriesExist(resolvedConfig, resolvedViteConfig.root);
310
308
  },
311
309
 
312
- resolveId(id: string) {
310
+ async resolveId(id: string) {
313
311
  if (id === "/src/client/main.js" && clientMainResolved) {
314
312
  return clientMainResolved;
315
313
  }
316
- if (id in integrationClientMap && integrationClientMap[id]) {
317
- return integrationClientMap[id];
314
+ // /@useavalon/*/client resolve through Vite's pipeline so it finds
315
+ // workspace-linked or npm-installed integration packages from the
316
+ // consuming project's node_modules, not from avalon's own context.
317
+ if (integrationClientIds.has(id)) {
318
+ const packageId = id.slice(1); // strip leading /
319
+ const resolved = await this.resolve(packageId);
320
+ return resolved?.id ?? null;
318
321
  }
319
322
  return null;
320
323
  },
321
324
 
322
325
  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.
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.
327
330
  if (id.includes('node_modules/@useavalon/') && /\.tsx?$/.test(id)) {
328
331
  const { transform: oxcTransform } = await import('oxc-transform');
329
332
  const result = await oxcTransform(id, code, {
333
+ sourcemap: true,
330
334
  typescript: { onlyRemoveTypeImports: false },
331
335
  });
332
- return { code: result.code, map: result.map };
336
+ return { code: result.code, map: result.map, moduleType: 'js' };
333
337
  }
334
338
  },
335
339