@reckona/mreact-router 0.0.113 → 0.0.115

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.
@@ -385,18 +385,37 @@ function moduleTypeForFilename(filename) {
385
385
  return "js";
386
386
  }
387
387
  function nodeBuiltinsForBrowserPlugin(platform, policy) {
388
+ const nodeModuleShimId = "\0mreact-router-node-module-shim";
388
389
  return {
389
390
  name: "mreact-router-browser-node-builtins",
390
391
  enforce: "pre",
391
392
  resolveId(id) {
392
393
  if (platform === "browser" && nodeBuiltinSpecifiers.has(id)) {
393
394
  if (policy === "externalize") {
395
+ if (id === "node:module" || id === "module") {
396
+ return nodeModuleShimId;
397
+ }
394
398
  return { external: true, id: id.startsWith("node:") ? id : `node:${id}` };
395
399
  }
396
400
  this.error(`Browser build cannot import Node builtin ${JSON.stringify(id)}.`);
397
401
  }
398
402
  return undefined;
399
403
  },
404
+ load(id) {
405
+ if (id !== nodeModuleShimId) {
406
+ return undefined;
407
+ }
408
+ return `export const builtinModules = [];
409
+
410
+ export function createRequire() {
411
+ return function cloudflareRequire() {
412
+ throw new Error("CommonJS require is not available in browser worker bundles.");
413
+ };
414
+ }
415
+
416
+ export default { builtinModules, createRequire };
417
+ `;
418
+ },
400
419
  };
401
420
  }
402
421
  function routerCompatPlugin(plugin) {
@@ -1 +1 @@
1
- {"version":3,"file":"bundle-pipeline.js","sourceRoot":"","sources":["../src/bundle-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,KAAK,IAAI,SAAS,GAInB,MAAM,MAAM,CAAC;AACd,OAAO,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,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAU;IAC7B,MAAM,aAAa,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9C,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import { builtinModules } from \"node:module\";\nimport { access } from \"node:fs/promises\";\nimport { dirname, extname, isAbsolute, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n build as viteBuild,\n type InlineConfig,\n type PluginOption,\n type Plugin as VitePlugin,\n} from \"vite\";\nimport { workspacePackageFile } from \"./workspace-packages.js\";\n\nexport interface RouterBundleOptions {\n base?: string | undefined;\n cache?: Map<string, Promise<RouterBundleOutput>> | undefined;\n cacheDir?: string | undefined;\n cacheKey?: string | undefined;\n code: string;\n define?: Record<string, string> | undefined;\n dropConsoleFunctions?: readonly string[] | undefined;\n externalizeAppSourceModuleDirs?: readonly string[] | undefined;\n filename: string;\n minify?: boolean | undefined;\n modulePreload?: boolean | undefined;\n nodeBuiltins?: \"externalize\" | \"reject\" | undefined;\n outfile?: string | undefined;\n platform: \"browser\" | \"node\";\n preserveExports?: boolean | undefined;\n root?: string | undefined;\n plugins?: readonly RouterCompatPlugin[] | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n sourceMap?: boolean | undefined;\n target?: string | undefined;\n}\n\nexport interface RouterBundleModulesOptions {\n base?: string | undefined;\n cacheDir?: string | undefined;\n chunkFileNames?: string | undefined;\n define?: Record<string, string> | undefined;\n dropConsoleFunctions?: readonly string[] | undefined;\n entries: readonly RouterBundleEntryOptions[];\n entryFileNames?: string | undefined;\n minify?: boolean | undefined;\n nodeBuiltins?: \"externalize\" | \"reject\" | undefined;\n platform: \"browser\" | \"node\";\n plugins?: readonly RouterCompatPlugin[] | undefined;\n root?: string | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n sourceMap?: boolean | undefined;\n target?: string | undefined;\n}\n\nexport interface RouterBundleEntryOptions {\n code: string;\n filename: string;\n name: string;\n}\n\nexport interface RouterBundleOutput {\n assets?: RouterBundleAssetOutput[] | undefined;\n code: string;\n map?: string | undefined;\n}\n\nexport interface RouterBundleModulesOutput {\n assets?: RouterBundleAssetOutput[] | undefined;\n chunks: RouterBundleChunkOutput[];\n}\n\nexport interface RouterBundleChunkOutput {\n code: string;\n fileName: string;\n imports: string[];\n isEntry: boolean;\n map?: string | undefined;\n name: string;\n}\n\nexport interface RouterBundleAssetOutput {\n fileName: string;\n source: string | Uint8Array;\n}\n\ninterface RouterBundlerChunk {\n code: string;\n fileName: string;\n imports?: string[] | undefined;\n isEntry?: boolean | undefined;\n name?: string | undefined;\n type: \"chunk\";\n}\n\ninterface RouterBundlerAsset {\n fileName: string;\n source: string | Uint8Array;\n type: \"asset\";\n}\n\ninterface RouterBundlerOutput {\n output: Array<RouterBundlerAsset | RouterBundlerChunk>;\n}\n\nexport interface RouterCompatPlugin {\n name: string;\n setup(buildApi: RouterCompatBuildApi): void;\n}\n\nexport interface RouterCompatBuildApi {\n onLoad(\n options: { filter: RegExp; namespace?: string | undefined },\n callback: (args: { path: string }) => RouterCompatLoadResult | Promise<RouterCompatLoadResult>,\n ): void;\n onResolve(\n options: { filter: RegExp },\n callback: (args: {\n importer?: string | undefined;\n path: string;\n resolveDir: string;\n }) => RouterCompatResolveResult | Promise<RouterCompatResolveResult>,\n ): void;\n}\n\nexport type RouterCompatLoadResult =\n | {\n contents: string;\n loader?: string | undefined;\n resolveDir?: string | undefined;\n }\n | undefined;\n\nexport type RouterCompatResolveResult =\n | {\n errors?: Array<{ text: string }> | undefined;\n external?: boolean | undefined;\n namespace?: string | undefined;\n path?: string | undefined;\n }\n | undefined;\n\nconst nodeBuiltinSpecifiers = new Set(builtinModules.flatMap((name) => [name, `node:${name}`]));\nconst mreactJsxRuntimeAliasPaths = new Map([\n [\n \"react\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom/client\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom/server\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react/jsx-dev-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-dev-runtime\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react/jsx-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-runtime\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"@reckona/mreact/jsx-dev-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-dev-runtime\",\n monorepoDir: \"react\",\n packageName: \"@reckona/mreact\",\n }),\n ],\n [\n \"@reckona/mreact/jsx-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-runtime\",\n monorepoDir: \"react\",\n packageName: \"@reckona/mreact\",\n }),\n ],\n [\n \"@reckona/mreact-compat/hooks\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"hooks-entry\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n]);\n\nexport async function bundleRouterModule(\n options: RouterBundleOptions,\n): Promise<RouterBundleOutput> {\n if (options.cache !== undefined && options.cacheKey !== undefined) {\n const cached = options.cache.get(options.cacheKey);\n\n if (cached !== undefined) {\n return cloneRouterBundleOutput(await cached);\n }\n\n const pending = bundleRouterModuleUncached(options);\n options.cache.set(options.cacheKey, pending);\n\n try {\n return cloneRouterBundleOutput(await pending);\n } catch (error) {\n options.cache.delete(options.cacheKey);\n throw error;\n }\n }\n\n return await bundleRouterModuleUncached(options);\n}\n\nasync function bundleRouterModuleUncached(\n options: RouterBundleOptions,\n): Promise<RouterBundleOutput> {\n const entryId = `${options.filename}?mreact-router-entry`;\n const outfile = options.outfile ?? \"entry.js\";\n const config = {\n base: options.base ?? \"/\",\n ...(options.cacheDir === undefined ? {} : { cacheDir: options.cacheDir }),\n configFile: false,\n ...(options.define === undefined ? {} : { define: options.define }),\n logLevel: \"silent\",\n plugins: [\n nodeBuiltinsForBrowserPlugin(options.platform, options.nodeBuiltins ?? \"reject\"),\n mreactJsxRuntimeAliasPlugin(),\n ...(options.vitePlugins ?? []),\n virtualEntryPlugin(entryId, options.code),\n ...(options.externalizeAppSourceModuleDirs === undefined\n ? []\n : [\n externalizeAppSourceModulesPlugin(\n options.filename,\n options.externalizeAppSourceModuleDirs,\n ),\n ]),\n ...(options.plugins ?? []).map(routerCompatPlugin),\n ],\n publicDir: false,\n root: options.root ?? dirname(options.filename),\n ssr: {\n noExternal: true,\n },\n build: {\n emptyOutDir: false,\n lib:\n options.preserveExports === true\n ? {\n entry: entryId,\n fileName: () => outfile,\n formats: [\"es\"],\n }\n : false,\n minify: options.minify === true,\n modulePreload: options.modulePreload ?? true,\n sourcemap: options.sourceMap === true,\n ssr: options.platform === \"node\",\n target: options.target ?? \"es2022\",\n write: false,\n rolldownOptions: {\n input: entryId,\n ...routerBundleTreeshakeOptions(options.dropConsoleFunctions),\n output: {\n codeSplitting: false,\n entryFileNames: outfile,\n format: \"es\",\n },\n },\n },\n } satisfies InlineConfig;\n const result = await viteBuild(config);\n const output = (Array.isArray(result) ? result[0] : result) as RouterBundlerOutput | undefined;\n\n if (output === undefined || !(\"output\" in output)) {\n throw new Error(`Failed to bundle ${options.filename}: Vite/Rolldown produced no output.`);\n }\n\n const chunk = output.output.find((item): item is RouterBundlerChunk => item.type === \"chunk\");\n const map = output.output.find(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName === `${chunk?.fileName ?? outfile}.map`,\n );\n const assets = output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName !== `${chunk?.fileName ?? outfile}.map`,\n )\n .map((asset) => ({ fileName: asset.fileName, source: asset.source }));\n\n if (chunk === undefined) {\n throw new Error(`Failed to bundle ${options.filename}: Vite/Rolldown produced no chunk.`);\n }\n\n return {\n ...(assets.length === 0 ? {} : { assets }),\n code: stripSourceMappingUrl(chunk.code),\n ...(map !== undefined && typeof map.source === \"string\" ? { map: map.source } : {}),\n };\n}\n\nfunction cloneRouterBundleOutput(output: RouterBundleOutput): RouterBundleOutput {\n return {\n ...(output.assets === undefined\n ? {}\n : {\n assets: output.assets.map((asset) => ({\n fileName: asset.fileName,\n source:\n typeof asset.source === \"string\" ? asset.source : new Uint8Array(asset.source),\n })),\n }),\n code: output.code,\n ...(output.map === undefined ? {} : { map: output.map }),\n };\n}\n\nexport async function bundleRouterModules(\n options: RouterBundleModulesOptions,\n): Promise<RouterBundleModulesOutput> {\n if (options.entries.length === 0) {\n return { chunks: [] };\n }\n\n const entries = new Map(\n options.entries.map((entry) => [\n `${entry.filename}?mreact-router-entry=${encodeURIComponent(entry.name)}`,\n entry,\n ]),\n );\n const input = Object.fromEntries(\n Array.from(entries, ([entryId, entry]) => [entry.name, entryId]),\n );\n const config = {\n base: options.base ?? \"/\",\n ...(options.cacheDir === undefined ? {} : { cacheDir: options.cacheDir }),\n configFile: false,\n ...(options.define === undefined ? {} : { define: options.define }),\n logLevel: \"silent\",\n plugins: [\n nodeBuiltinsForBrowserPlugin(options.platform, options.nodeBuiltins ?? \"reject\"),\n mreactJsxRuntimeAliasPlugin(),\n ...(options.vitePlugins ?? []),\n virtualEntriesPlugin(entries),\n ...(options.plugins ?? []).map(routerCompatPlugin),\n ],\n publicDir: false,\n root: options.root ?? dirname(options.entries[0]?.filename ?? process.cwd()),\n ssr: {\n noExternal: true,\n },\n build: {\n emptyOutDir: false,\n minify: options.minify === true,\n sourcemap: options.sourceMap === true,\n ssr: options.platform === \"node\",\n target: options.target ?? \"es2022\",\n write: false,\n rolldownOptions: {\n input,\n ...routerBundleTreeshakeOptions(options.dropConsoleFunctions),\n output: {\n chunkFileNames: options.chunkFileNames ?? \"assets/chunks/[name].[hash].js\",\n entryFileNames: options.entryFileNames ?? \"assets/routes/[name].[hash].js\",\n format: \"es\",\n hashCharacters: \"hex\",\n },\n },\n },\n } satisfies InlineConfig;\n const result = await viteBuild(config);\n const output = (Array.isArray(result) ? result[0] : result) as RouterBundlerOutput | undefined;\n\n if (output === undefined || !(\"output\" in output)) {\n throw new Error(\"Failed to bundle client routes: Vite/Rolldown produced no output.\");\n }\n\n const mapAssets = new Map(\n output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName.endsWith(\".map\"),\n )\n .flatMap((asset) =>\n typeof asset.source === \"string\" ? [[asset.fileName, asset.source] as const] : [],\n ),\n );\n const chunks = output.output\n .filter((item): item is RouterBundlerChunk => item.type === \"chunk\")\n .map((chunk) => {\n const map = mapAssets.get(`${chunk.fileName}.map`);\n\n return {\n code: stripSourceMappingUrl(chunk.code),\n fileName: chunk.fileName,\n imports: chunk.imports ?? [],\n isEntry: chunk.isEntry === true,\n ...(map === undefined ? {} : { map }),\n name: chunk.name ?? chunk.fileName,\n };\n });\n const assets = output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && !item.fileName.endsWith(\".map\"),\n )\n .map((asset) => ({ fileName: asset.fileName, source: asset.source }));\n\n return {\n ...(assets.length === 0 ? {} : { assets }),\n chunks,\n };\n}\n\nfunction mreactJsxRuntimeAliasPlugin(): VitePlugin {\n return {\n name: \"mreact-router-jsx-runtime-alias\",\n enforce: \"pre\",\n resolveId(id) {\n return mreactJsxRuntimeAliasPaths.get(id);\n },\n };\n}\n\nfunction externalizeAppSourceModulesPlugin(\n entryFilename: string,\n sourceDirs: readonly string[],\n): VitePlugin {\n const normalizedSourceDirs = sourceDirs.map((directory) => resolve(directory));\n\n return {\n name: \"mreact-router-externalize-app-source-modules\",\n enforce: \"pre\",\n async resolveId(id, importer) {\n if (importer === undefined || !isAppSourceImport(id)) {\n return undefined;\n }\n\n const importerPath = cleanViteId(importer);\n const resolved = await resolveAppSourceImport(id, dirname(importerPath));\n\n if (\n resolved === undefined ||\n resolved === entryFilename ||\n !isExternalizableAppSourceModule(resolved) ||\n !isInsideAnyDirectory(normalizedSourceDirs, resolved)\n ) {\n return undefined;\n }\n\n return {\n external: true,\n id: pathToFileURL(resolved).href,\n };\n },\n };\n}\n\nfunction isInsideAnyDirectory(directories: readonly string[], path: string): boolean {\n return directories.some((directory) => path === directory || path.startsWith(`${directory}/`));\n}\n\nfunction isAppSourceImport(id: string): boolean {\n return id.startsWith(\".\") || id.startsWith(\"/\") || isAbsolute(id);\n}\n\nfunction isExternalizableAppSourceModule(path: string): boolean {\n return /\\.(?:[cm]?ts|[cm]?js)$/u.test(path);\n}\n\nasync function resolveAppSourceImport(id: string, resolveDir: string): Promise<string | undefined> {\n const base = isAbsolute(id) ? id : resolve(resolveDir, id);\n const extension = extname(base);\n const candidates =\n extension === \"\"\n ? [\n base,\n `${base}.ts`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}.js`,\n `${base}.mjs`,\n `${base}.cjs`,\n join(base, \"index.ts\"),\n join(base, \"index.mts\"),\n join(base, \"index.cts\"),\n join(base, \"index.js\"),\n join(base, \"index.mjs\"),\n join(base, \"index.cjs\"),\n ]\n : [base];\n\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return candidate;\n } catch {\n continue;\n }\n }\n\n return undefined;\n}\n\nfunction routerBundleTreeshakeOptions(\n dropConsoleFunctions: readonly string[] | undefined,\n): { treeshake: { manualPureFunctions: readonly string[] } } | {} {\n return dropConsoleFunctions === undefined || dropConsoleFunctions.length === 0\n ? {}\n : { treeshake: { manualPureFunctions: dropConsoleFunctions } };\n}\n\nfunction stripSourceMappingUrl(code: string): string {\n return code.replace(/\\n?\\/\\/# sourceMappingURL=[^\\n]+\\.map\\s*$/u, \"\");\n}\n\nfunction virtualEntryPlugin(entryId: string, code: string): VitePlugin {\n return {\n name: \"mreact-router-virtual-entry\",\n enforce: \"pre\",\n resolveId(id) {\n return id === entryId ? entryId : undefined;\n },\n load(id) {\n return id === entryId ? { code, moduleType: moduleTypeForFilename(entryId) } : undefined;\n },\n };\n}\n\nfunction virtualEntriesPlugin(entries: ReadonlyMap<string, RouterBundleEntryOptions>): VitePlugin {\n return {\n name: \"mreact-router-virtual-entries\",\n enforce: \"pre\",\n resolveId(id) {\n return entries.has(id) ? id : undefined;\n },\n load(id) {\n const entry = entries.get(id);\n\n return entry === undefined\n ? undefined\n : { code: entry.code, moduleType: moduleTypeForFilename(id) };\n },\n };\n}\n\nfunction moduleTypeForFilename(filename: string): \"js\" | \"jsx\" | \"ts\" | \"tsx\" {\n const clean = cleanViteId(filename);\n\n if (/\\.(?:mreact\\.)?[cm]?tsx$/u.test(clean) || clean.endsWith(\".jsx\")) {\n return \"tsx\";\n }\n\n if (/\\.(?:mreact\\.)?[cm]?ts$/u.test(clean)) {\n return \"ts\";\n }\n\n return \"js\";\n}\n\nfunction nodeBuiltinsForBrowserPlugin(\n platform: RouterBundleOptions[\"platform\"],\n policy: NonNullable<RouterBundleOptions[\"nodeBuiltins\"]>,\n): VitePlugin {\n return {\n name: \"mreact-router-browser-node-builtins\",\n enforce: \"pre\",\n resolveId(id) {\n if (platform === \"browser\" && nodeBuiltinSpecifiers.has(id)) {\n if (policy === \"externalize\") {\n return { external: true, id: id.startsWith(\"node:\") ? id : `node:${id}` };\n }\n\n this.error(`Browser build cannot import Node builtin ${JSON.stringify(id)}.`);\n }\n\n return undefined;\n },\n };\n}\n\nfunction routerCompatPlugin(plugin: RouterCompatPlugin): VitePlugin {\n const resolvers: Array<{\n filter: RegExp;\n callback: Parameters<RouterCompatBuildApi[\"onResolve\"]>[1];\n }> = [];\n const loaders: Array<{\n filter: RegExp;\n namespace?: string | undefined;\n callback: Parameters<RouterCompatBuildApi[\"onLoad\"]>[1];\n }> = [];\n\n plugin.setup({\n onLoad(options, callback) {\n loaders.push({ ...options, callback });\n },\n onResolve(options, callback) {\n resolvers.push({ ...options, callback });\n },\n });\n\n return {\n name: plugin.name,\n enforce: \"pre\",\n async resolveId(source, importer) {\n for (const resolver of resolvers) {\n if (!resolver.filter.test(source)) {\n continue;\n }\n\n const resolved = await resolver.callback({\n importer: importer === undefined ? undefined : cleanViteId(importer),\n path: source,\n resolveDir: importer === undefined ? \"\" : dirname(cleanViteId(importer)),\n });\n\n if (resolved === undefined) {\n continue;\n }\n\n if (resolved.errors !== undefined && resolved.errors.length > 0) {\n this.error(resolved.errors.map((error) => error.text).join(\"\\n\"));\n }\n\n if (resolved.path === undefined) {\n continue;\n }\n\n if (resolved.external === true) {\n return { external: true, id: resolved.path };\n }\n\n return resolved.namespace === undefined\n ? resolved.path\n : compatVirtualId(resolved.namespace, resolved.path);\n }\n\n return undefined;\n },\n async load(id) {\n const virtual = parseCompatVirtualId(id);\n const path = virtual?.path ?? cleanViteId(id);\n const namespace = virtual?.namespace;\n\n for (const loader of loaders) {\n if (loader.namespace !== namespace || !loader.filter.test(path)) {\n continue;\n }\n\n const loaded = await loader.callback({ path });\n\n if (loaded !== undefined) {\n return loaded.contents;\n }\n }\n\n return undefined;\n },\n };\n}\n\nfunction compatVirtualId(namespace: string, path: string): string {\n return `\\0mreact-router-compat:${encodeURIComponent(namespace)}:${encodeURIComponent(path)}`;\n}\n\nfunction parseCompatVirtualId(id: string): { namespace: string; path: string } | undefined {\n const prefix = \"\\0mreact-router-compat:\";\n\n if (!id.startsWith(prefix)) {\n return undefined;\n }\n\n const rest = id.slice(prefix.length);\n const separator = rest.indexOf(\":\");\n\n if (separator === -1) {\n return undefined;\n }\n\n return {\n namespace: decodeURIComponent(rest.slice(0, separator)),\n path: decodeURIComponent(rest.slice(separator + 1)),\n };\n}\n\nfunction cleanViteId(id: string): string {\n const withoutPrefix = id.startsWith(\"/@fs/\") ? id.slice(\"/@fs\".length) : id;\n const queryIndex = withoutPrefix.indexOf(\"?\");\n\n return queryIndex === -1 ? withoutPrefix : withoutPrefix.slice(0, queryIndex);\n}\n"]}
1
+ {"version":3,"file":"bundle-pipeline.js","sourceRoot":"","sources":["../src/bundle-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,KAAK,IAAI,SAAS,GAInB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,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AAS,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;AAC/F,CAAC;AAED,SAAS,oBAAoB,CAAC,EAAU;IACtC,MAAM,MAAM,GAAG,yBAAyB,CAAC;IAEzC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO;QACL,SAAS,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACvD,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAU;IAC7B,MAAM,aAAa,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9C,OAAO,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import { builtinModules } from \"node:module\";\nimport { access } from \"node:fs/promises\";\nimport { dirname, extname, isAbsolute, join, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n build as viteBuild,\n type InlineConfig,\n type PluginOption,\n type Plugin as VitePlugin,\n} from \"vite\";\nimport { workspacePackageFile } from \"./workspace-packages.js\";\n\nexport interface RouterBundleOptions {\n base?: string | undefined;\n cache?: Map<string, Promise<RouterBundleOutput>> | undefined;\n cacheDir?: string | undefined;\n cacheKey?: string | undefined;\n code: string;\n define?: Record<string, string> | undefined;\n dropConsoleFunctions?: readonly string[] | undefined;\n externalizeAppSourceModuleDirs?: readonly string[] | undefined;\n filename: string;\n minify?: boolean | undefined;\n modulePreload?: boolean | undefined;\n nodeBuiltins?: \"externalize\" | \"reject\" | undefined;\n outfile?: string | undefined;\n platform: \"browser\" | \"node\";\n preserveExports?: boolean | undefined;\n root?: string | undefined;\n plugins?: readonly RouterCompatPlugin[] | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n sourceMap?: boolean | undefined;\n target?: string | undefined;\n}\n\nexport interface RouterBundleModulesOptions {\n base?: string | undefined;\n cacheDir?: string | undefined;\n chunkFileNames?: string | undefined;\n define?: Record<string, string> | undefined;\n dropConsoleFunctions?: readonly string[] | undefined;\n entries: readonly RouterBundleEntryOptions[];\n entryFileNames?: string | undefined;\n minify?: boolean | undefined;\n nodeBuiltins?: \"externalize\" | \"reject\" | undefined;\n platform: \"browser\" | \"node\";\n plugins?: readonly RouterCompatPlugin[] | undefined;\n root?: string | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n sourceMap?: boolean | undefined;\n target?: string | undefined;\n}\n\nexport interface RouterBundleEntryOptions {\n code: string;\n filename: string;\n name: string;\n}\n\nexport interface RouterBundleOutput {\n assets?: RouterBundleAssetOutput[] | undefined;\n code: string;\n map?: string | undefined;\n}\n\nexport interface RouterBundleModulesOutput {\n assets?: RouterBundleAssetOutput[] | undefined;\n chunks: RouterBundleChunkOutput[];\n}\n\nexport interface RouterBundleChunkOutput {\n code: string;\n fileName: string;\n imports: string[];\n isEntry: boolean;\n map?: string | undefined;\n name: string;\n}\n\nexport interface RouterBundleAssetOutput {\n fileName: string;\n source: string | Uint8Array;\n}\n\ninterface RouterBundlerChunk {\n code: string;\n fileName: string;\n imports?: string[] | undefined;\n isEntry?: boolean | undefined;\n name?: string | undefined;\n type: \"chunk\";\n}\n\ninterface RouterBundlerAsset {\n fileName: string;\n source: string | Uint8Array;\n type: \"asset\";\n}\n\ninterface RouterBundlerOutput {\n output: Array<RouterBundlerAsset | RouterBundlerChunk>;\n}\n\nexport interface RouterCompatPlugin {\n name: string;\n setup(buildApi: RouterCompatBuildApi): void;\n}\n\nexport interface RouterCompatBuildApi {\n onLoad(\n options: { filter: RegExp; namespace?: string | undefined },\n callback: (args: { path: string }) => RouterCompatLoadResult | Promise<RouterCompatLoadResult>,\n ): void;\n onResolve(\n options: { filter: RegExp },\n callback: (args: {\n importer?: string | undefined;\n path: string;\n resolveDir: string;\n }) => RouterCompatResolveResult | Promise<RouterCompatResolveResult>,\n ): void;\n}\n\nexport type RouterCompatLoadResult =\n | {\n contents: string;\n loader?: string | undefined;\n resolveDir?: string | undefined;\n }\n | undefined;\n\nexport type RouterCompatResolveResult =\n | {\n errors?: Array<{ text: string }> | undefined;\n external?: boolean | undefined;\n namespace?: string | undefined;\n path?: string | undefined;\n }\n | undefined;\n\nconst nodeBuiltinSpecifiers = new Set(builtinModules.flatMap((name) => [name, `node:${name}`]));\nconst mreactJsxRuntimeAliasPaths = new Map([\n [\n \"react\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom/client\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react-dom/server\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"index\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react/jsx-dev-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-dev-runtime\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"react/jsx-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-runtime\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n [\n \"@reckona/mreact/jsx-dev-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-dev-runtime\",\n monorepoDir: \"react\",\n packageName: \"@reckona/mreact\",\n }),\n ],\n [\n \"@reckona/mreact/jsx-runtime\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"jsx-runtime\",\n monorepoDir: \"react\",\n packageName: \"@reckona/mreact\",\n }),\n ],\n [\n \"@reckona/mreact-compat/hooks\",\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry: \"hooks-entry\",\n monorepoDir: \"react-compat\",\n packageName: \"@reckona/mreact-compat\",\n }),\n ],\n]);\n\nexport async function bundleRouterModule(\n options: RouterBundleOptions,\n): Promise<RouterBundleOutput> {\n if (options.cache !== undefined && options.cacheKey !== undefined) {\n const cached = options.cache.get(options.cacheKey);\n\n if (cached !== undefined) {\n return cloneRouterBundleOutput(await cached);\n }\n\n const pending = bundleRouterModuleUncached(options);\n options.cache.set(options.cacheKey, pending);\n\n try {\n return cloneRouterBundleOutput(await pending);\n } catch (error) {\n options.cache.delete(options.cacheKey);\n throw error;\n }\n }\n\n return await bundleRouterModuleUncached(options);\n}\n\nasync function bundleRouterModuleUncached(\n options: RouterBundleOptions,\n): Promise<RouterBundleOutput> {\n const entryId = `${options.filename}?mreact-router-entry`;\n const outfile = options.outfile ?? \"entry.js\";\n const config = {\n base: options.base ?? \"/\",\n ...(options.cacheDir === undefined ? {} : { cacheDir: options.cacheDir }),\n configFile: false,\n ...(options.define === undefined ? {} : { define: options.define }),\n logLevel: \"silent\",\n plugins: [\n nodeBuiltinsForBrowserPlugin(options.platform, options.nodeBuiltins ?? \"reject\"),\n mreactJsxRuntimeAliasPlugin(),\n ...(options.vitePlugins ?? []),\n virtualEntryPlugin(entryId, options.code),\n ...(options.externalizeAppSourceModuleDirs === undefined\n ? []\n : [\n externalizeAppSourceModulesPlugin(\n options.filename,\n options.externalizeAppSourceModuleDirs,\n ),\n ]),\n ...(options.plugins ?? []).map(routerCompatPlugin),\n ],\n publicDir: false,\n root: options.root ?? dirname(options.filename),\n ssr: {\n noExternal: true,\n },\n build: {\n emptyOutDir: false,\n lib:\n options.preserveExports === true\n ? {\n entry: entryId,\n fileName: () => outfile,\n formats: [\"es\"],\n }\n : false,\n minify: options.minify === true,\n modulePreload: options.modulePreload ?? true,\n sourcemap: options.sourceMap === true,\n ssr: options.platform === \"node\",\n target: options.target ?? \"es2022\",\n write: false,\n rolldownOptions: {\n input: entryId,\n ...routerBundleTreeshakeOptions(options.dropConsoleFunctions),\n output: {\n codeSplitting: false,\n entryFileNames: outfile,\n format: \"es\",\n },\n },\n },\n } satisfies InlineConfig;\n const result = await viteBuild(config);\n const output = (Array.isArray(result) ? result[0] : result) as RouterBundlerOutput | undefined;\n\n if (output === undefined || !(\"output\" in output)) {\n throw new Error(`Failed to bundle ${options.filename}: Vite/Rolldown produced no output.`);\n }\n\n const chunk = output.output.find((item): item is RouterBundlerChunk => item.type === \"chunk\");\n const map = output.output.find(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName === `${chunk?.fileName ?? outfile}.map`,\n );\n const assets = output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName !== `${chunk?.fileName ?? outfile}.map`,\n )\n .map((asset) => ({ fileName: asset.fileName, source: asset.source }));\n\n if (chunk === undefined) {\n throw new Error(`Failed to bundle ${options.filename}: Vite/Rolldown produced no chunk.`);\n }\n\n return {\n ...(assets.length === 0 ? {} : { assets }),\n code: stripSourceMappingUrl(chunk.code),\n ...(map !== undefined && typeof map.source === \"string\" ? { map: map.source } : {}),\n };\n}\n\nfunction cloneRouterBundleOutput(output: RouterBundleOutput): RouterBundleOutput {\n return {\n ...(output.assets === undefined\n ? {}\n : {\n assets: output.assets.map((asset) => ({\n fileName: asset.fileName,\n source:\n typeof asset.source === \"string\" ? asset.source : new Uint8Array(asset.source),\n })),\n }),\n code: output.code,\n ...(output.map === undefined ? {} : { map: output.map }),\n };\n}\n\nexport async function bundleRouterModules(\n options: RouterBundleModulesOptions,\n): Promise<RouterBundleModulesOutput> {\n if (options.entries.length === 0) {\n return { chunks: [] };\n }\n\n const entries = new Map(\n options.entries.map((entry) => [\n `${entry.filename}?mreact-router-entry=${encodeURIComponent(entry.name)}`,\n entry,\n ]),\n );\n const input = Object.fromEntries(\n Array.from(entries, ([entryId, entry]) => [entry.name, entryId]),\n );\n const config = {\n base: options.base ?? \"/\",\n ...(options.cacheDir === undefined ? {} : { cacheDir: options.cacheDir }),\n configFile: false,\n ...(options.define === undefined ? {} : { define: options.define }),\n logLevel: \"silent\",\n plugins: [\n nodeBuiltinsForBrowserPlugin(options.platform, options.nodeBuiltins ?? \"reject\"),\n mreactJsxRuntimeAliasPlugin(),\n ...(options.vitePlugins ?? []),\n virtualEntriesPlugin(entries),\n ...(options.plugins ?? []).map(routerCompatPlugin),\n ],\n publicDir: false,\n root: options.root ?? dirname(options.entries[0]?.filename ?? process.cwd()),\n ssr: {\n noExternal: true,\n },\n build: {\n emptyOutDir: false,\n minify: options.minify === true,\n sourcemap: options.sourceMap === true,\n ssr: options.platform === \"node\",\n target: options.target ?? \"es2022\",\n write: false,\n rolldownOptions: {\n input,\n ...routerBundleTreeshakeOptions(options.dropConsoleFunctions),\n output: {\n chunkFileNames: options.chunkFileNames ?? \"assets/chunks/[name].[hash].js\",\n entryFileNames: options.entryFileNames ?? \"assets/routes/[name].[hash].js\",\n format: \"es\",\n hashCharacters: \"hex\",\n },\n },\n },\n } satisfies InlineConfig;\n const result = await viteBuild(config);\n const output = (Array.isArray(result) ? result[0] : result) as RouterBundlerOutput | undefined;\n\n if (output === undefined || !(\"output\" in output)) {\n throw new Error(\"Failed to bundle client routes: Vite/Rolldown produced no output.\");\n }\n\n const mapAssets = new Map(\n output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && item.fileName.endsWith(\".map\"),\n )\n .flatMap((asset) =>\n typeof asset.source === \"string\" ? [[asset.fileName, asset.source] as const] : [],\n ),\n );\n const chunks = output.output\n .filter((item): item is RouterBundlerChunk => item.type === \"chunk\")\n .map((chunk) => {\n const map = mapAssets.get(`${chunk.fileName}.map`);\n\n return {\n code: stripSourceMappingUrl(chunk.code),\n fileName: chunk.fileName,\n imports: chunk.imports ?? [],\n isEntry: chunk.isEntry === true,\n ...(map === undefined ? {} : { map }),\n name: chunk.name ?? chunk.fileName,\n };\n });\n const assets = output.output\n .filter(\n (item): item is RouterBundlerAsset =>\n item.type === \"asset\" && !item.fileName.endsWith(\".map\"),\n )\n .map((asset) => ({ fileName: asset.fileName, source: asset.source }));\n\n return {\n ...(assets.length === 0 ? {} : { assets }),\n chunks,\n };\n}\n\nfunction mreactJsxRuntimeAliasPlugin(): VitePlugin {\n return {\n name: \"mreact-router-jsx-runtime-alias\",\n enforce: \"pre\",\n resolveId(id) {\n return mreactJsxRuntimeAliasPaths.get(id);\n },\n };\n}\n\nfunction externalizeAppSourceModulesPlugin(\n entryFilename: string,\n sourceDirs: readonly string[],\n): VitePlugin {\n const normalizedSourceDirs = sourceDirs.map((directory) => resolve(directory));\n\n return {\n name: \"mreact-router-externalize-app-source-modules\",\n enforce: \"pre\",\n async resolveId(id, importer) {\n if (importer === undefined || !isAppSourceImport(id)) {\n return undefined;\n }\n\n const importerPath = cleanViteId(importer);\n const resolved = await resolveAppSourceImport(id, dirname(importerPath));\n\n if (\n resolved === undefined ||\n resolved === entryFilename ||\n !isExternalizableAppSourceModule(resolved) ||\n !isInsideAnyDirectory(normalizedSourceDirs, resolved)\n ) {\n return undefined;\n }\n\n return {\n external: true,\n id: pathToFileURL(resolved).href,\n };\n },\n };\n}\n\nfunction isInsideAnyDirectory(directories: readonly string[], path: string): boolean {\n return directories.some((directory) => path === directory || path.startsWith(`${directory}/`));\n}\n\nfunction isAppSourceImport(id: string): boolean {\n return id.startsWith(\".\") || id.startsWith(\"/\") || isAbsolute(id);\n}\n\nfunction isExternalizableAppSourceModule(path: string): boolean {\n return /\\.(?:[cm]?ts|[cm]?js)$/u.test(path);\n}\n\nasync function resolveAppSourceImport(id: string, resolveDir: string): Promise<string | undefined> {\n const base = isAbsolute(id) ? id : resolve(resolveDir, id);\n const extension = extname(base);\n const candidates =\n extension === \"\"\n ? [\n base,\n `${base}.ts`,\n `${base}.mts`,\n `${base}.cts`,\n `${base}.js`,\n `${base}.mjs`,\n `${base}.cjs`,\n join(base, \"index.ts\"),\n join(base, \"index.mts\"),\n join(base, \"index.cts\"),\n join(base, \"index.js\"),\n join(base, \"index.mjs\"),\n join(base, \"index.cjs\"),\n ]\n : [base];\n\n for (const candidate of candidates) {\n try {\n await access(candidate);\n return candidate;\n } catch {\n continue;\n }\n }\n\n return undefined;\n}\n\nfunction routerBundleTreeshakeOptions(\n dropConsoleFunctions: readonly string[] | undefined,\n): { treeshake: { manualPureFunctions: readonly string[] } } | {} {\n return dropConsoleFunctions === undefined || dropConsoleFunctions.length === 0\n ? {}\n : { treeshake: { manualPureFunctions: dropConsoleFunctions } };\n}\n\nfunction stripSourceMappingUrl(code: string): string {\n return code.replace(/\\n?\\/\\/# sourceMappingURL=[^\\n]+\\.map\\s*$/u, \"\");\n}\n\nfunction virtualEntryPlugin(entryId: string, code: string): VitePlugin {\n return {\n name: \"mreact-router-virtual-entry\",\n enforce: \"pre\",\n resolveId(id) {\n return id === entryId ? entryId : undefined;\n },\n load(id) {\n return id === entryId ? { code, moduleType: moduleTypeForFilename(entryId) } : undefined;\n },\n };\n}\n\nfunction virtualEntriesPlugin(entries: ReadonlyMap<string, RouterBundleEntryOptions>): VitePlugin {\n return {\n name: \"mreact-router-virtual-entries\",\n enforce: \"pre\",\n resolveId(id) {\n return entries.has(id) ? id : undefined;\n },\n load(id) {\n const entry = entries.get(id);\n\n return entry === undefined\n ? undefined\n : { code: entry.code, moduleType: moduleTypeForFilename(id) };\n },\n };\n}\n\nfunction moduleTypeForFilename(filename: string): \"js\" | \"jsx\" | \"ts\" | \"tsx\" {\n const clean = cleanViteId(filename);\n\n if (/\\.(?:mreact\\.)?[cm]?tsx$/u.test(clean) || clean.endsWith(\".jsx\")) {\n return \"tsx\";\n }\n\n if (/\\.(?:mreact\\.)?[cm]?ts$/u.test(clean)) {\n return \"ts\";\n }\n\n return \"js\";\n}\n\nfunction nodeBuiltinsForBrowserPlugin(\n platform: RouterBundleOptions[\"platform\"],\n policy: NonNullable<RouterBundleOptions[\"nodeBuiltins\"]>,\n): VitePlugin {\n const nodeModuleShimId = \"\\0mreact-router-node-module-shim\";\n\n return {\n name: \"mreact-router-browser-node-builtins\",\n enforce: \"pre\",\n resolveId(id) {\n if (platform === \"browser\" && nodeBuiltinSpecifiers.has(id)) {\n if (policy === \"externalize\") {\n if (id === \"node:module\" || id === \"module\") {\n return nodeModuleShimId;\n }\n\n return { external: true, id: id.startsWith(\"node:\") ? id : `node:${id}` };\n }\n\n this.error(`Browser build cannot import Node builtin ${JSON.stringify(id)}.`);\n }\n\n return undefined;\n },\n load(id) {\n if (id !== nodeModuleShimId) {\n return undefined;\n }\n\n return `export const builtinModules = [];\n\nexport function createRequire() {\n return function cloudflareRequire() {\n throw new Error(\"CommonJS require is not available in browser worker bundles.\");\n };\n}\n\nexport default { builtinModules, createRequire };\n`;\n },\n };\n}\n\nfunction routerCompatPlugin(plugin: RouterCompatPlugin): VitePlugin {\n const resolvers: Array<{\n filter: RegExp;\n callback: Parameters<RouterCompatBuildApi[\"onResolve\"]>[1];\n }> = [];\n const loaders: Array<{\n filter: RegExp;\n namespace?: string | undefined;\n callback: Parameters<RouterCompatBuildApi[\"onLoad\"]>[1];\n }> = [];\n\n plugin.setup({\n onLoad(options, callback) {\n loaders.push({ ...options, callback });\n },\n onResolve(options, callback) {\n resolvers.push({ ...options, callback });\n },\n });\n\n return {\n name: plugin.name,\n enforce: \"pre\",\n async resolveId(source, importer) {\n for (const resolver of resolvers) {\n if (!resolver.filter.test(source)) {\n continue;\n }\n\n const resolved = await resolver.callback({\n importer: importer === undefined ? undefined : cleanViteId(importer),\n path: source,\n resolveDir: importer === undefined ? \"\" : dirname(cleanViteId(importer)),\n });\n\n if (resolved === undefined) {\n continue;\n }\n\n if (resolved.errors !== undefined && resolved.errors.length > 0) {\n this.error(resolved.errors.map((error) => error.text).join(\"\\n\"));\n }\n\n if (resolved.path === undefined) {\n continue;\n }\n\n if (resolved.external === true) {\n return { external: true, id: resolved.path };\n }\n\n return resolved.namespace === undefined\n ? resolved.path\n : compatVirtualId(resolved.namespace, resolved.path);\n }\n\n return undefined;\n },\n async load(id) {\n const virtual = parseCompatVirtualId(id);\n const path = virtual?.path ?? cleanViteId(id);\n const namespace = virtual?.namespace;\n\n for (const loader of loaders) {\n if (loader.namespace !== namespace || !loader.filter.test(path)) {\n continue;\n }\n\n const loaded = await loader.callback({ path });\n\n if (loaded !== undefined) {\n return loaded.contents;\n }\n }\n\n return undefined;\n },\n };\n}\n\nfunction compatVirtualId(namespace: string, path: string): string {\n return `\\0mreact-router-compat:${encodeURIComponent(namespace)}:${encodeURIComponent(path)}`;\n}\n\nfunction parseCompatVirtualId(id: string): { namespace: string; path: string } | undefined {\n const prefix = \"\\0mreact-router-compat:\";\n\n if (!id.startsWith(prefix)) {\n return undefined;\n }\n\n const rest = id.slice(prefix.length);\n const separator = rest.indexOf(\":\");\n\n if (separator === -1) {\n return undefined;\n }\n\n return {\n namespace: decodeURIComponent(rest.slice(0, separator)),\n path: decodeURIComponent(rest.slice(separator + 1)),\n };\n}\n\nfunction cleanViteId(id: string): string {\n const withoutPrefix = id.startsWith(\"/@fs/\") ? id.slice(\"/@fs\".length) : id;\n const queryIndex = withoutPrefix.indexOf(\"?\");\n\n return queryIndex === -1 ? withoutPrefix : withoutPrefix.slice(0, queryIndex);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.113",
3
+ "version": "0.0.115",
4
4
  "description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
5
5
  "keywords": [
6
6
  "jsx",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "typescript": "^6.0.3",
108
- "@reckona/mreact-compiler": "0.0.113",
109
- "@reckona/mreact-compat": "0.0.113",
110
- "@reckona/mreact-devtools": "0.0.113",
111
- "@reckona/mreact-query": "0.0.113",
112
- "@reckona/mreact-reactive-dom": "0.0.113",
113
- "@reckona/mreact-reactive-core": "0.0.113",
114
- "@reckona/mreact-server": "0.0.113",
115
- "@reckona/mreact-shared": "0.0.113",
116
- "@reckona/mreact": "0.0.113"
108
+ "@reckona/mreact": "0.0.115",
109
+ "@reckona/mreact-compat": "0.0.115",
110
+ "@reckona/mreact-devtools": "0.0.115",
111
+ "@reckona/mreact-query": "0.0.115",
112
+ "@reckona/mreact-reactive-core": "0.0.115",
113
+ "@reckona/mreact-compiler": "0.0.115",
114
+ "@reckona/mreact-reactive-dom": "0.0.115",
115
+ "@reckona/mreact-server": "0.0.115",
116
+ "@reckona/mreact-shared": "0.0.115"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.113"
122
+ "@reckona/mreact-router-native": "0.0.115"
123
123
  }
124
124
  }
package/src/build.ts CHANGED
@@ -2611,24 +2611,42 @@ async function writeCloudflareRouteModules(options: {
2611
2611
  function cloudflarePageRouteFacadeModuleSource(componentImport: string): string {
2612
2612
  return `import * as componentModule from ${JSON.stringify(componentImport)};
2613
2613
 
2614
- const componentDefault = readComponentModuleExport(componentModule, "default");
2615
- const componentApp = readComponentModuleExport(componentModule, "App");
2616
2614
  const componentSlots = readComponentModuleExport(componentModule, "slots");
2617
- const routeComponent = typeof componentDefault === "function"
2618
- ? componentDefault
2619
- : typeof componentApp === "function"
2620
- ? componentApp
2621
- : undefined;
2622
2615
 
2623
- export const App = routeComponent === undefined
2624
- ? undefined
2625
- : function CloudflareRouteComponent(props) {
2626
- return routeComponent(props);
2627
- };
2628
- export default App;
2629
- export const CloudflareRouteComponent = App;
2616
+ export function App(props) {
2617
+ return renderCloudflareRouteComponent(props);
2618
+ }
2619
+ export default function CloudflareDefaultRouteComponent(props) {
2620
+ return renderCloudflareRouteComponent(props);
2621
+ }
2622
+ export function CloudflareRouteComponent(props) {
2623
+ return renderCloudflareRouteComponent(props);
2624
+ }
2630
2625
  export const slots = componentSlots === undefined ? undefined : { ...componentSlots };
2631
2626
 
2627
+ function renderCloudflareRouteComponent(props) {
2628
+ const routeComponent = resolveCloudflareRouteComponent();
2629
+ if (routeComponent === undefined) {
2630
+ throw new Error("No Cloudflare component export was found for ${componentImport}.");
2631
+ }
2632
+
2633
+ return routeComponent(props);
2634
+ }
2635
+
2636
+ function resolveCloudflareRouteComponent() {
2637
+ const componentDefault = readComponentModuleExport(componentModule, "default");
2638
+ if (typeof componentDefault === "function") {
2639
+ return componentDefault;
2640
+ }
2641
+
2642
+ const componentApp = readComponentModuleExport(componentModule, "App");
2643
+ if (typeof componentApp === "function") {
2644
+ return componentApp;
2645
+ }
2646
+
2647
+ return undefined;
2648
+ }
2649
+
2632
2650
  function readComponentModuleExport(module, name) {
2633
2651
  const descriptor = Object.getOwnPropertyDescriptor(module, name);
2634
2652
  if (descriptor === undefined) {
@@ -598,12 +598,18 @@ function nodeBuiltinsForBrowserPlugin(
598
598
  platform: RouterBundleOptions["platform"],
599
599
  policy: NonNullable<RouterBundleOptions["nodeBuiltins"]>,
600
600
  ): VitePlugin {
601
+ const nodeModuleShimId = "\0mreact-router-node-module-shim";
602
+
601
603
  return {
602
604
  name: "mreact-router-browser-node-builtins",
603
605
  enforce: "pre",
604
606
  resolveId(id) {
605
607
  if (platform === "browser" && nodeBuiltinSpecifiers.has(id)) {
606
608
  if (policy === "externalize") {
609
+ if (id === "node:module" || id === "module") {
610
+ return nodeModuleShimId;
611
+ }
612
+
607
613
  return { external: true, id: id.startsWith("node:") ? id : `node:${id}` };
608
614
  }
609
615
 
@@ -612,6 +618,22 @@ function nodeBuiltinsForBrowserPlugin(
612
618
 
613
619
  return undefined;
614
620
  },
621
+ load(id) {
622
+ if (id !== nodeModuleShimId) {
623
+ return undefined;
624
+ }
625
+
626
+ return `export const builtinModules = [];
627
+
628
+ export function createRequire() {
629
+ return function cloudflareRequire() {
630
+ throw new Error("CommonJS require is not available in browser worker bundles.");
631
+ };
632
+ }
633
+
634
+ export default { builtinModules, createRequire };
635
+ `;
636
+ },
615
637
  };
616
638
  }
617
639