@reckona/mreact-router 0.0.86 → 0.0.88

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.
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAsB,MAAM,MAAM,CAAC;AACvG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAkBhE,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIxE,MAAM,WAAW,8BAA+B,SAAQ,uBAAuB;IAC7E,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,UAAU,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,aAAa,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD;AAMD,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IACzE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,UAAU,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,aAA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AAS,CAAC;IACjD,UAAU,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,aAAa,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD;AAMD,MAAM,WAAW,0BAA2B,SAAQ,uBAAuB;IACzE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7C,UAAU,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC3C,YAAY,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;IACjD,UAAU,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACxC,aAAa,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CAC1D;AAcD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,MAAM,CAwPrF;AAqBD,eAAO,MAAM,YAAY,kCAA4B,CAAC;AAEtD,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,SAAS,OAAO,EAAE,GAC1B,wBAAwB,GAAG,SAAS,CAQtC;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,kBAAkB,CAS5B;AAoED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAA;CAAO,GACjF,OAAO,CAAC,QAAQ,CAAC,CAuEnB"}
package/dist/vite.js CHANGED
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
2
2
  import { dirname } from "node:path";
3
3
  import { formatDiagnostic } from "@reckona/mreact-compiler";
4
4
  import { createCompilerModuleContext, transformCompilerModuleContext, } from "@reckona/mreact-compiler/internal";
5
- import { normalizePath } from "vite";
5
+ import { normalizePath, } from "vite";
6
6
  import { resolveAppRouterProjectOptions, } from "./config.js";
7
7
  import { collectClientRouteReferences, detectNavigationRuntimeHint, isClientRouteSource, } from "./client-route-inference.js";
8
8
  import { buildNavigationRuntimeBundle, buildClientRouteBundle, buildClientRouteEntrySource, clientScriptForPath, navigationRuntimeScriptForDev, } from "./navigation-runtime.js";
@@ -43,18 +43,21 @@ export function createAppRouterVitePlugin(options) {
43
43
  "@reckona/mreact-compat",
44
44
  ];
45
45
  const runtimePaths = new Map([
46
+ ["react", reactCompatPath],
47
+ ["react-dom", reactCompatPath],
48
+ ["react-dom/client", reactCompatPath],
49
+ ["react-dom/server", reactCompatPath],
46
50
  [
47
- "@reckona/mreact-reactive-core/internal",
48
- packageFile("reactive-core", "@reckona/mreact-reactive-core", "internal"),
49
- ],
50
- [
51
- "@reckona/mreact-reactive-dom",
52
- reactiveDomPath,
51
+ "react/jsx-dev-runtime",
52
+ packageFile("react-compat", "@reckona/mreact-compat", "jsx-dev-runtime"),
53
53
  ],
54
+ ["react/jsx-runtime", packageFile("react-compat", "@reckona/mreact-compat", "jsx-runtime")],
54
55
  [
55
- "@reckona/mreact-compat",
56
- reactCompatPath,
56
+ "@reckona/mreact-reactive-core/internal",
57
+ packageFile("reactive-core", "@reckona/mreact-reactive-core", "internal"),
57
58
  ],
59
+ ["@reckona/mreact-reactive-dom", reactiveDomPath],
60
+ ["@reckona/mreact-compat", reactCompatPath],
58
61
  [
59
62
  "@reckona/mreact-compat/event-priority",
60
63
  packageFile("react-compat", "@reckona/mreact-compat", "event-priority"),
@@ -79,10 +82,7 @@ export function createAppRouterVitePlugin(options) {
79
82
  "@reckona/mreact-compat/scheduler",
80
83
  packageFile("react-compat", "@reckona/mreact-compat", "scheduler"),
81
84
  ],
82
- [
83
- "@reckona/mreact-router/link",
84
- packageFile("router", "@reckona/mreact-router", "link"),
85
- ],
85
+ ["@reckona/mreact-router/link", packageFile("router", "@reckona/mreact-router", "link")],
86
86
  [
87
87
  "@reckona/mreact-router/navigation-state",
88
88
  packageFile("router", "@reckona/mreact-router", "navigation-state"),
@@ -96,6 +96,20 @@ export function createAppRouterVitePlugin(options) {
96
96
  [mreactRouterConfigKey]: project,
97
97
  enforce: "pre",
98
98
  name: "mreact-router",
99
+ config() {
100
+ return {
101
+ optimizeDeps: {
102
+ exclude: [
103
+ "react",
104
+ "react-dom",
105
+ "react-dom/client",
106
+ "react-dom/server",
107
+ "react/jsx-dev-runtime",
108
+ "react/jsx-runtime",
109
+ ],
110
+ },
111
+ };
112
+ },
99
113
  configureServer(server) {
100
114
  server.middlewares.use(createDevCssProxyMiddleware());
101
115
  return () => {
@@ -144,7 +158,9 @@ export function hasReactiveDevtoolsEmitter() { return false; }
144
158
  export function currentDevtoolsEmitter() { return undefined; }`;
145
159
  }
146
160
  if (id.startsWith(virtualClientPrefix)) {
147
- return renderAppRouterClientAsset(project.routesDir, id.slice(virtualClientPrefix.length), { dev: true }).then(async (response) => {
161
+ return renderAppRouterClientAsset(project.routesDir, id.slice(virtualClientPrefix.length), {
162
+ dev: true,
163
+ }).then(async (response) => {
148
164
  if (!response.ok) {
149
165
  const message = await response.text();
150
166
  throw new Error(message || `MReact client route asset was not found: ${id}`);
@@ -181,9 +197,7 @@ export function currentDevtoolsEmitter() { return undefined; }`;
181
197
  target: "client",
182
198
  });
183
199
  if (output.diagnostics.length > 0) {
184
- throw new Error(output.diagnostics
185
- .map((diagnostic) => formatDiagnostic(filename, diagnostic))
186
- .join("\n"));
200
+ throw new Error(output.diagnostics.map((diagnostic) => formatDiagnostic(filename, diagnostic)).join("\n"));
187
201
  }
188
202
  return {
189
203
  code: output.code,
@@ -230,9 +244,7 @@ function isCompatSourcePath(filename) {
230
244
  export const mreactRouter = createAppRouterVitePlugin;
231
245
  export function mreactRouterConfigFromPlugins(plugins) {
232
246
  for (const plugin of plugins.flat(Infinity)) {
233
- if (plugin !== null &&
234
- typeof plugin === "object" &&
235
- mreactRouterConfigKey in plugin) {
247
+ if (plugin !== null && typeof plugin === "object" && mreactRouterConfigKey in plugin) {
236
248
  return plugin[mreactRouterConfigKey];
237
249
  }
238
250
  }
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAoE,MAAM,MAAM,CAAC;AAGvG,OAAO,EACL,8BAA8B,GAG/B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAA0B,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAuB/D,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,YAAY,GAAG,mBAAmB,CAAC;AACzC,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAC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,MAAM,GAAG,cAAc,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,GAAG,GAAG,GAAG,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QAC5C,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,oBAAoB,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO;;;;EAIP,IAAI;;;;;;;;;;CAUL,CAAC;AACF,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { ServerResponse } from \"node:http\";\nimport { dirname } from \"node:path\";\nimport { formatDiagnostic } from \"@reckona/mreact-compiler\";\nimport {\n createCompilerModuleContext,\n transformCompilerModuleContext,\n} from \"@reckona/mreact-compiler/internal\";\nimport { normalizePath, type Connect, type Plugin, type PluginOption, type ViteDevServer } from \"vite\";\nimport type { AppRouterServerActionOptions } from \"./actions.js\";\nimport type { AppRouterCache } from \"./cache.js\";\nimport {\n resolveAppRouterProjectOptions,\n type AppRouterProjectOptions,\n type ResolvedAppRouterProject,\n} from \"./config.js\";\nimport type { AppRouterImportPolicy } from \"./import-policy.js\";\nimport {\n collectClientRouteReferences,\n detectNavigationRuntimeHint,\n isClientRouteSource,\n} from \"./client-route-inference.js\";\nimport {\n buildNavigationRuntimeBundle,\n buildClientRouteBundle,\n buildClientRouteEntrySource,\n clientScriptForPath,\n navigationRuntimeScriptForDev,\n} from \"./navigation-runtime.js\";\nimport { nodeRequestToWebRequest, sendResponse } from \"./http.js\";\nimport { renderAppRequest } from \"./render.js\";\nimport { stripRouteClientOnlyExports } from \"./route-source.js\";\nimport { collectRouteCssHrefs } from \"./route-styles.js\";\nimport { scanAppRoutes } from \"./routes.js\";\nimport { resolveRequestHost, type RequestHostPolicy } from \"./serve.js\";\nimport { hasJsxSyntax } from \"./source-jsx.js\";\nimport { workspacePackageFile } from \"./workspace-packages.js\";\n\nexport interface AppRouterViteMiddlewareOptions extends AppRouterProjectOptions {\n allowedHosts?: readonly string[] | undefined;\n hostPolicy?: RequestHostPolicy | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n}\n\ntype AppRouterViteRuntimeMiddlewareOptions = AppRouterViteMiddlewareOptions & {\n viteDevServer?: ViteDevServer | undefined;\n};\n\nexport interface AppRouterVitePluginOptions extends AppRouterProjectOptions {\n allowedHosts?: readonly string[] | undefined;\n hostPolicy?: RequestHostPolicy | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}\n\nconst clientPrefix = \"/_mreact/client/\";\nconst devCssPrefix = \"/_mreact/dev-css/\";\nconst clientRouteModuleQuery = \"mreact-router-client-route\";\nconst virtualClientPrefix = \"\\0mreact-router-client:\";\nconst virtualReactiveCoreId = \"\\0mreact-router-reactive-core\";\nconst virtualReactiveDevtoolsId = \"\\0mreact-router-reactive-devtools\";\nconst mreactRouterConfigKey = \"__mreactRouterConfig\";\n\ntype MreactRouterPlugin = Plugin & {\n [mreactRouterConfigKey]: ResolvedAppRouterProject;\n};\n\nexport function createAppRouterVitePlugin(\n options: AppRouterVitePluginOptions,\n): Plugin {\n const project = resolveAppRouterProjectOptions(options);\n const normalizedSourceDirs = project.allowedSourceDirs.map((directory) => normalizePath(directory));\n const packageFile = (monorepoDir: string, packageName: string, entry: string): string =>\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry,\n monorepoDir,\n packageName,\n });\n const reactiveCorePath = packageFile(\"reactive-core\", \"@reckona/mreact-reactive-core\", \"index\");\n const reactiveCoreDir = normalizePath(dirname(reactiveCorePath));\n const reactiveDomPath = packageFile(\"reactive-dom\", \"@reckona/mreact-reactive-dom\", \"index\");\n const reactiveDomDir = normalizePath(dirname(reactiveDomPath));\n const reactCompatPath = packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"index\");\n const reactCompatDir = normalizePath(dirname(reactCompatPath));\n const runtimePackageDirs = [reactiveCoreDir, reactiveDomDir, reactCompatDir];\n const runtimePackageNames = [\n \"@reckona/mreact-reactive-core\",\n \"@reckona/mreact-reactive-dom\",\n \"@reckona/mreact-compat\",\n ];\n const runtimePaths = new Map([\n [\n \"@reckona/mreact-reactive-core/internal\",\n packageFile(\"reactive-core\", \"@reckona/mreact-reactive-core\", \"internal\"),\n ],\n [\n \"@reckona/mreact-reactive-dom\",\n reactiveDomPath,\n ],\n [\n \"@reckona/mreact-compat\",\n reactCompatPath,\n ],\n [\n \"@reckona/mreact-compat/event-priority\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"event-priority\"),\n ],\n [\n \"@reckona/mreact-compat/flight\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"flight\"),\n ],\n [\n \"@reckona/mreact-compat/internal\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"internal\"),\n ],\n [\n \"@reckona/mreact-compat/jsx-dev-runtime\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-dev-runtime\"),\n ],\n [\n \"@reckona/mreact-compat/jsx-runtime\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-runtime\"),\n ],\n [\n \"@reckona/mreact-compat/scheduler\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"scheduler\"),\n ],\n [\n \"@reckona/mreact-router/link\",\n packageFile(\"router\", \"@reckona/mreact-router\", \"link\"),\n ],\n [\n \"@reckona/mreact-router/navigation-state\",\n packageFile(\"router\", \"@reckona/mreact-router\", \"navigation-state\"),\n ],\n [\n \"@reckona/mreact-shared/url-safety\",\n packageFile(\"shared\", \"@reckona/mreact-shared\", \"url-safety\"),\n ],\n ]);\n\n const plugin: MreactRouterPlugin = {\n [mreactRouterConfigKey]: project,\n enforce: \"pre\",\n name: \"mreact-router\",\n configureServer(server) {\n server.middlewares.use(createDevCssProxyMiddleware());\n\n return () => {\n const middlewareOptions: AppRouterViteRuntimeMiddlewareOptions = {\n ...options,\n viteDevServer: server,\n vitePlugins: server.config.plugins,\n };\n\n server.middlewares.use(\n createAppRouterViteMiddleware(middlewareOptions),\n );\n };\n },\n handleHotUpdate(context) {\n const normalizedFile = normalizePath(context.file);\n\n if (!normalizedSourceDirs.some((directory) => normalizedFile.startsWith(directory))) {\n return;\n }\n\n const timestamp = Date.now();\n const updates = Array.from(context.server.moduleGraph.idToModuleMap.values())\n .filter((moduleNode) => isMreactClientDevModuleId(moduleNode.id))\n .map((moduleNode) => {\n context.server.moduleGraph.invalidateModule(moduleNode);\n\n return {\n acceptedPath: moduleNode.url,\n path: moduleNode.url,\n timestamp,\n type: \"js-update\" as const,\n };\n });\n\n if (updates.length > 0) {\n context.server.ws.send({ type: \"update\", updates });\n }\n\n return [];\n },\n load(id) {\n if (id === virtualReactiveCoreId) {\n return `import { cell as nativeCell } from ${JSON.stringify(reactiveCorePath)};\nexport * from ${JSON.stringify(reactiveCorePath)};\nexport function cell(initial) {\n const routeCell = globalThis.__mreactRouteCell;\n return typeof routeCell === \"function\" ? routeCell(nativeCell, initial) : nativeCell(initial);\n}`;\n }\n\n if (id === virtualReactiveDevtoolsId) {\n return `export function emitReactiveDevtoolsEvent() {}\nexport function hasReactiveDevtoolsEmitter() { return false; }\nexport function currentDevtoolsEmitter() { return undefined; }`;\n }\n\n if (id.startsWith(virtualClientPrefix)) {\n return renderAppRouterClientAsset(\n project.routesDir,\n id.slice(virtualClientPrefix.length),\n { dev: true },\n ).then(async (response) => {\n if (!response.ok) {\n const message = await response.text();\n throw new Error(message || `MReact client route asset was not found: ${id}`);\n }\n\n return response.text();\n });\n }\n\n const requestPath = clientRouteModuleRequestPath(id);\n\n return requestPath === undefined\n ? undefined\n : renderAppRouterClientRouteDevModule(project.routesDir, requestPath);\n },\n transform(code, id, options) {\n if (options?.ssr === true) {\n return undefined;\n }\n\n if (isMreactClientDevModuleId(id)) {\n return undefined;\n }\n\n const filename = clientRequestPath(id);\n\n if (!isMreactClientSourceDependency(filename, normalizedSourceDirs)) {\n return undefined;\n }\n\n const moduleContext = createCompilerModuleContext({ code, filename });\n\n if (!hasJsxSyntax(moduleContext.program)) {\n return undefined;\n }\n\n const output = transformCompilerModuleContext({\n code,\n dev: true,\n filename,\n mode: isCompatSourcePath(filename) ? \"compat\" : \"reactive\",\n moduleContext,\n target: \"client\",\n });\n\n if (output.diagnostics.length > 0) {\n throw new Error(\n output.diagnostics\n .map((diagnostic) => formatDiagnostic(filename, diagnostic))\n .join(\"\\n\"),\n );\n }\n\n return {\n code: output.code,\n map: null,\n };\n },\n async resolveId(id, importer) {\n const runtimePath = runtimePaths.get(id);\n\n if (id === \"@reckona/mreact-reactive-core\") {\n if (importerInRuntimePackage(importer, runtimePackageDirs, runtimePackageNames)) {\n return reactiveCorePath;\n }\n\n return virtualReactiveCoreId;\n }\n\n if (\n id === \"./devtools.js\" &&\n importerInRuntimePackage(importer, [reactiveCoreDir], [\"@reckona/mreact-reactive-core\"])\n ) {\n return virtualReactiveDevtoolsId;\n }\n\n if (runtimePath !== undefined) {\n return runtimePath;\n }\n\n const requestPath = clientRequestPath(id);\n\n if (requestPath === `${clientPrefix}${navigationRuntimeScriptForDev()}`) {\n return `${virtualClientPrefix}${requestPath}`;\n }\n\n if (!requestPath.startsWith(clientPrefix)) {\n return undefined;\n }\n\n const route = await clientRouteForRequestPath(project.routesDir, requestPath);\n\n return route === undefined ? undefined : clientRouteModuleId(route.file, requestPath);\n },\n };\n\n return plugin;\n}\n\nfunction isMreactClientSourceDependency(\n filename: string,\n normalizedSourceDirs: readonly string[],\n): boolean {\n const normalized = normalizePath(filename);\n\n return (\n /\\.(?:mreact\\.)?[cm]?[jt]sx?$/.test(normalized) &&\n !normalized.includes(\"/node_modules/\") &&\n normalizedSourceDirs.some(\n (directory) => normalized === directory || normalized.startsWith(`${directory}/`),\n )\n );\n}\n\nfunction isCompatSourcePath(filename: string): boolean {\n return /\\.compat(?:\\.mreact)?(?:\\.[cm]?[jt]sx?)?$/.test(filename);\n}\n\nexport const mreactRouter = createAppRouterVitePlugin;\n\nexport function mreactRouterConfigFromPlugins(\n plugins: readonly unknown[],\n): ResolvedAppRouterProject | undefined {\n for (const plugin of plugins.flat(Infinity)) {\n if (\n plugin !== null &&\n typeof plugin === \"object\" &&\n mreactRouterConfigKey in plugin\n ) {\n return (plugin as MreactRouterPlugin)[mreactRouterConfigKey];\n }\n }\n\n return undefined;\n}\n\nexport function createAppRouterViteMiddleware(\n options: AppRouterViteMiddlewareOptions,\n): Connect.NextHandleFunction {\n return (request, response, next) => {\n void handleAppRouterViteRequest(\n options as AppRouterViteRuntimeMiddlewareOptions,\n request,\n response,\n next,\n );\n };\n}\n\nasync function handleAppRouterViteRequest(\n options: AppRouterViteRuntimeMiddlewareOptions,\n incoming: Connect.IncomingMessage,\n outgoing: ServerResponse,\n next: Connect.NextFunction,\n): Promise<void> {\n try {\n const project = resolveAppRouterProjectOptions(options);\n const host = resolveRequestHost({\n allowedHosts: options.allowedHosts,\n fallbackHost: \"localhost\",\n hostPolicy: options.hostPolicy,\n rawHost: incoming.headers.host,\n });\n const origin = `http://${host}`;\n const url = new URL(incoming.url ?? \"/\", origin);\n\n if (url.pathname.startsWith(clientPrefix)) {\n if (options.viteDevServer !== undefined) {\n const transformed = await options.viteDevServer.transformRequest(\n `${url.pathname}${url.search}`,\n );\n\n if (transformed !== null) {\n await sendResponse(\n outgoing,\n new Response(transformed.code, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n }),\n );\n return;\n }\n }\n\n await sendResponse(\n outgoing,\n await renderAppRouterClientAsset(project.routesDir, url.pathname, {\n vitePlugins: options.vitePlugins,\n }),\n );\n return;\n }\n\n const request = nodeRequestToWebRequest(incoming, origin);\n\n await sendResponse(\n outgoing,\n await renderAppRequest({\n appDir: project.routesDir,\n importPolicy: {\n ...options.importPolicy,\n allowedSourceDirs: project.allowedSourceDirs,\n projectRoot: project.projectRoot,\n },\n clientStyles: await devRouteStyles(project),\n navigationScripts: await devNavigationScripts(project.routesDir),\n request,\n routeCache: options.routeCache,\n serverActions: options.serverActions,\n }),\n );\n } catch (error) {\n next(error);\n }\n}\n\nexport async function renderAppRouterClientAsset(\n appDir: string,\n pathname: string,\n options: { dev?: boolean; vitePlugins?: readonly PluginOption[] | undefined } = {},\n): Promise<Response> {\n if (pathname === `/_mreact/client/${navigationRuntimeScriptForDev()}`) {\n const output = await buildNavigationRuntimeBundle();\n\n return new Response(options.dev === true ? withViteHmrRuntime(output.code) : output.code, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n }\n\n const routes = await scanAppRoutes({ appDir });\n const route = routes.find(\n (candidate) =>\n candidate.kind === \"page\" &&\n `/_mreact/client/${clientScriptForPath(candidate.path)}` === pathname,\n );\n\n if (route === undefined || route.kind !== \"page\") {\n return new Response(\"Not Found\", { status: 404 });\n }\n\n const code = await readFile(route.file, \"utf8\");\n const clientSource = stripRouteClientOnlyExports(code);\n let references: Awaited<ReturnType<typeof collectClientRouteReferences>>;\n\n try {\n references = await collectClientRouteReferences({\n appDir,\n code: clientSource,\n filename: route.file,\n vitePlugins: options.vitePlugins,\n });\n } catch (error) {\n return clientAssetBuildErrorResponse(route.file, error);\n }\n\n if (!references.client) {\n if (isClientRouteSource(clientSource)) {\n return clientAssetBuildErrorResponse(\n route.file,\n new Error(\n [\n \"Client route analysis did not produce a client asset.\",\n \"Browser build cannot import Node builtins or other server-only modules.\",\n ...references.diagnostics.map((diagnostic) => diagnostic.message),\n ].join(\"\\n\"),\n ),\n );\n }\n\n return new Response(\"Not Found\", { status: 404 });\n }\n\n let bundle: string;\n\n try {\n bundle = await buildClientRouteBundle({\n code: clientSource,\n clientBoundaryImports: references.clientBoundaryImports,\n clientReferenceImports: references.clientReferenceImports,\n clientReferenceManifest: references.clientReferenceManifest,\n filename: route.file,\n routePath: route.path,\n vitePlugins: options.vitePlugins,\n });\n } catch (error) {\n return clientAssetBuildErrorResponse(route.file, error);\n }\n\n return new Response(options.dev === true ? withViteHmrRuntime(bundle) : bundle, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n}\n\nasync function renderAppRouterClientRouteDevModule(\n appDir: string,\n pathname: string,\n options: { vitePlugins?: readonly PluginOption[] | undefined } = {},\n): Promise<string> {\n const route = await clientRouteForRequestPath(appDir, pathname);\n\n if (route === undefined) {\n throw new Error(`MReact client route asset was not found: ${pathname}`);\n }\n\n const code = await readFile(route.file, \"utf8\");\n const clientSource = stripRouteClientOnlyExports(code);\n const references = await collectClientRouteReferences({\n appDir,\n code: clientSource,\n filename: route.file,\n vitePlugins: options.vitePlugins,\n });\n\n if (!references.client) {\n throw new Error(\n isClientRouteSource(clientSource)\n ? [\n \"Client route analysis did not produce a client asset.\",\n \"Browser build cannot import Node builtins or other server-only modules.\",\n ...references.diagnostics.map((diagnostic) => diagnostic.message),\n ].join(\"\\n\")\n : `MReact client route asset was not found: ${pathname}`,\n );\n }\n\n const entry = await buildClientRouteEntrySource({\n code: clientSource,\n clientBoundaryImports: references.clientBoundaryImports,\n clientReferenceImports: references.clientReferenceImports,\n clientReferenceManifest: references.clientReferenceManifest,\n filename: route.file,\n routePath: route.path,\n vitePlugins: options.vitePlugins,\n });\n\n return withViteHmrRuntime(entry.code);\n}\n\nasync function clientRouteForRequestPath(appDir: string, pathname: string) {\n const routes = await scanAppRoutes({ appDir });\n\n return routes.find(\n (candidate) =>\n candidate.kind === \"page\" &&\n `/_mreact/client/${clientScriptForPath(candidate.path)}` === pathname,\n );\n}\n\nfunction clientRequestPath(id: string): string {\n const [path] = id.split(/[?#]/, 1);\n\n return path ?? id;\n}\n\nfunction clientRouteModuleId(filename: string, requestPath: string): string {\n return `${normalizePath(filename)}?${clientRouteModuleQuery}=${encodeURIComponent(requestPath)}`;\n}\n\nfunction clientRouteModuleRequestPath(id: string): string | undefined {\n const queryStart = id.indexOf(\"?\");\n\n if (queryStart === -1) {\n return undefined;\n }\n\n const params = new URLSearchParams(id.slice(queryStart + 1));\n const value = params.get(clientRouteModuleQuery);\n\n return value === null ? undefined : value;\n}\n\nfunction isMreactClientDevModuleId(id: string | null | undefined): boolean {\n return (\n id?.startsWith(virtualClientPrefix) === true ||\n id?.includes(`?${clientRouteModuleQuery}=`) === true ||\n id?.includes(`&${clientRouteModuleQuery}=`) === true\n );\n}\n\nfunction importerInRuntimePackage(\n importer: string | undefined,\n directories: readonly string[],\n packageNames: readonly string[],\n): boolean {\n if (importer === undefined) {\n return false;\n }\n\n const normalizedImporter = normalizePath(importer);\n return (\n directories.some((directory) => normalizedImporter.startsWith(`${directory}/`)) ||\n packageNames.some((packageName) =>\n normalizedImporter.includes(`/node_modules/${packageName}/`),\n )\n );\n}\n\nfunction clientAssetBuildErrorResponse(filename: string, error: unknown): Response {\n const message = [\n `Failed to build mreact client route asset for ${filename}.`,\n error instanceof Error ? error.message : String(error),\n ].join(\"\\n\");\n\n return new Response(`throw new Error(${JSON.stringify(message)});\\n`, {\n status: 500,\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n}\n\nasync function devRouteStyles(\n project: ResolvedAppRouterProject,\n): Promise<ReadonlyMap<string, readonly string[]>> {\n const entries = await Promise.all(\n (await scanAppRoutes({ appDir: project.routesDir })).map(async (route) => {\n if (route.kind !== \"page\") {\n return undefined;\n }\n\n const hrefs = await collectRouteCssHrefs({\n appDir: project.routesDir,\n hrefPrefix: devCssPrefix,\n pageFile: route.file,\n projectRoot: project.projectRoot,\n });\n\n return hrefs.length === 0 ? undefined : ([route.path, hrefs as readonly string[]] as const);\n }),\n );\n const routeStyles = entries.filter(\n (entry): entry is readonly [string, readonly string[]] => entry !== undefined,\n );\n\n return new Map<string, readonly string[]>(routeStyles);\n}\n\nasync function devNavigationScripts(appDir: string): Promise<ReadonlyMap<string, string>> {\n const entries = await Promise.all(\n (await scanAppRoutes({ appDir })).map(async (route) => {\n if (route.kind !== \"page\") {\n return undefined;\n }\n\n const source = await readFile(route.file, \"utf8\");\n\n return detectNavigationRuntimeHint(source)\n ? ([route.path, navigationRuntimeScriptForDev()] as const)\n : undefined;\n }),\n );\n\n return new Map(entries.filter((entry): entry is readonly [string, string] => entry !== undefined));\n}\n\nfunction createDevCssProxyMiddleware(): Connect.NextHandleFunction {\n return (incoming, outgoing, next) => {\n const originalUrl = incoming.url ?? \"/\";\n const url = new URL(originalUrl, \"http://mreact.local\");\n\n if (!url.pathname.startsWith(devCssPrefix)) {\n next();\n return;\n }\n\n const sourcePath = `/${url.pathname.slice(devCssPrefix.length)}`;\n\n if (sourcePath === \"/\" || sourcePath.includes(\"\\0\")) {\n next();\n return;\n }\n\n const originalAccept = incoming.headers.accept;\n let restored = false;\n const restore = () => {\n if (restored) {\n return;\n }\n restored = true;\n incoming.url = originalUrl;\n if (originalAccept === undefined) {\n delete incoming.headers.accept;\n } else {\n incoming.headers.accept = originalAccept;\n }\n };\n\n incoming.url = `${sourcePath}${url.search}`;\n incoming.headers.accept = \"text/css,*/*;q=0.1\";\n outgoing.once(\"finish\", restore);\n outgoing.once(\"close\", restore);\n next();\n };\n}\n\nfunction withViteHmrRuntime(code: string): string {\n return `import \"/@vite/client\";\nif (import.meta.hot?.data.__mreactRouteStates) {\n globalThis.__mreactRouteStates = import.meta.hot.data.__mreactRouteStates;\n}\n${code}\nif (import.meta.hot) {\n const __mreactPreserveRouteState = () => {\n import.meta.hot.data.__mreactRouteStates = globalThis.__mreactRouteStates;\n };\n import.meta.hot.dispose(__mreactPreserveRouteState);\n import.meta.hot.accept((module) => {\n module?.__mreactHydrateRoute?.();\n });\n}\n`;\n}\n"]}
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QA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KAAK,CAAC;QACrB,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;YACD,QAAQ,GAAG,IAAI,CAAC;YAChB,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC;YAC3B,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;gBACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC;QAEF,QAAQ,CAAC,GAAG,GAAG,GAAG,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QAC5C,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,oBAAoB,CAAC;QAC/C,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAO;;;;EAIP,IAAI;;;;;;;;;;CAUL,CAAC;AACF,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport type { ServerResponse } from \"node:http\";\nimport { dirname } from \"node:path\";\nimport { formatDiagnostic } from \"@reckona/mreact-compiler\";\nimport {\n createCompilerModuleContext,\n transformCompilerModuleContext,\n} from \"@reckona/mreact-compiler/internal\";\nimport {\n normalizePath,\n type Connect,\n type Plugin,\n type PluginOption,\n type ViteDevServer,\n} from \"vite\";\nimport type { AppRouterServerActionOptions } from \"./actions.js\";\nimport type { AppRouterCache } from \"./cache.js\";\nimport {\n resolveAppRouterProjectOptions,\n type AppRouterProjectOptions,\n type ResolvedAppRouterProject,\n} from \"./config.js\";\nimport type { AppRouterImportPolicy } from \"./import-policy.js\";\nimport {\n collectClientRouteReferences,\n detectNavigationRuntimeHint,\n isClientRouteSource,\n} from \"./client-route-inference.js\";\nimport {\n buildNavigationRuntimeBundle,\n buildClientRouteBundle,\n buildClientRouteEntrySource,\n clientScriptForPath,\n navigationRuntimeScriptForDev,\n} from \"./navigation-runtime.js\";\nimport { nodeRequestToWebRequest, sendResponse } from \"./http.js\";\nimport { renderAppRequest } from \"./render.js\";\nimport { stripRouteClientOnlyExports } from \"./route-source.js\";\nimport { collectRouteCssHrefs } from \"./route-styles.js\";\nimport { scanAppRoutes } from \"./routes.js\";\nimport { resolveRequestHost, type RequestHostPolicy } from \"./serve.js\";\nimport { hasJsxSyntax } from \"./source-jsx.js\";\nimport { workspacePackageFile } from \"./workspace-packages.js\";\n\nexport interface AppRouterViteMiddlewareOptions extends AppRouterProjectOptions {\n allowedHosts?: readonly string[] | undefined;\n hostPolicy?: RequestHostPolicy | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n vitePlugins?: readonly PluginOption[] | undefined;\n}\n\ntype AppRouterViteRuntimeMiddlewareOptions = AppRouterViteMiddlewareOptions & {\n viteDevServer?: ViteDevServer | undefined;\n};\n\nexport interface AppRouterVitePluginOptions extends AppRouterProjectOptions {\n allowedHosts?: readonly string[] | undefined;\n hostPolicy?: RequestHostPolicy | undefined;\n importPolicy?: AppRouterImportPolicy | undefined;\n routeCache?: AppRouterCache | undefined;\n serverActions?: AppRouterServerActionOptions | undefined;\n}\n\nconst clientPrefix = \"/_mreact/client/\";\nconst devCssPrefix = \"/_mreact/dev-css/\";\nconst clientRouteModuleQuery = \"mreact-router-client-route\";\nconst virtualClientPrefix = \"\\0mreact-router-client:\";\nconst virtualReactiveCoreId = \"\\0mreact-router-reactive-core\";\nconst virtualReactiveDevtoolsId = \"\\0mreact-router-reactive-devtools\";\nconst mreactRouterConfigKey = \"__mreactRouterConfig\";\n\ntype MreactRouterPlugin = Plugin & {\n [mreactRouterConfigKey]: ResolvedAppRouterProject;\n};\n\nexport function createAppRouterVitePlugin(options: AppRouterVitePluginOptions): Plugin {\n const project = resolveAppRouterProjectOptions(options);\n const normalizedSourceDirs = project.allowedSourceDirs.map((directory) =>\n normalizePath(directory),\n );\n const packageFile = (monorepoDir: string, packageName: string, entry: string): string =>\n workspacePackageFile({\n currentFileUrl: import.meta.url,\n entry,\n monorepoDir,\n packageName,\n });\n const reactiveCorePath = packageFile(\"reactive-core\", \"@reckona/mreact-reactive-core\", \"index\");\n const reactiveCoreDir = normalizePath(dirname(reactiveCorePath));\n const reactiveDomPath = packageFile(\"reactive-dom\", \"@reckona/mreact-reactive-dom\", \"index\");\n const reactiveDomDir = normalizePath(dirname(reactiveDomPath));\n const reactCompatPath = packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"index\");\n const reactCompatDir = normalizePath(dirname(reactCompatPath));\n const runtimePackageDirs = [reactiveCoreDir, reactiveDomDir, reactCompatDir];\n const runtimePackageNames = [\n \"@reckona/mreact-reactive-core\",\n \"@reckona/mreact-reactive-dom\",\n \"@reckona/mreact-compat\",\n ];\n const runtimePaths = new Map([\n [\"react\", reactCompatPath],\n [\"react-dom\", reactCompatPath],\n [\"react-dom/client\", reactCompatPath],\n [\"react-dom/server\", reactCompatPath],\n [\n \"react/jsx-dev-runtime\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-dev-runtime\"),\n ],\n [\"react/jsx-runtime\", packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-runtime\")],\n [\n \"@reckona/mreact-reactive-core/internal\",\n packageFile(\"reactive-core\", \"@reckona/mreact-reactive-core\", \"internal\"),\n ],\n [\"@reckona/mreact-reactive-dom\", reactiveDomPath],\n [\"@reckona/mreact-compat\", reactCompatPath],\n [\n \"@reckona/mreact-compat/event-priority\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"event-priority\"),\n ],\n [\n \"@reckona/mreact-compat/flight\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"flight\"),\n ],\n [\n \"@reckona/mreact-compat/internal\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"internal\"),\n ],\n [\n \"@reckona/mreact-compat/jsx-dev-runtime\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-dev-runtime\"),\n ],\n [\n \"@reckona/mreact-compat/jsx-runtime\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"jsx-runtime\"),\n ],\n [\n \"@reckona/mreact-compat/scheduler\",\n packageFile(\"react-compat\", \"@reckona/mreact-compat\", \"scheduler\"),\n ],\n [\"@reckona/mreact-router/link\", packageFile(\"router\", \"@reckona/mreact-router\", \"link\")],\n [\n \"@reckona/mreact-router/navigation-state\",\n packageFile(\"router\", \"@reckona/mreact-router\", \"navigation-state\"),\n ],\n [\n \"@reckona/mreact-shared/url-safety\",\n packageFile(\"shared\", \"@reckona/mreact-shared\", \"url-safety\"),\n ],\n ]);\n\n const plugin: MreactRouterPlugin = {\n [mreactRouterConfigKey]: project,\n enforce: \"pre\",\n name: \"mreact-router\",\n config() {\n return {\n optimizeDeps: {\n exclude: [\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react-dom/server\",\n \"react/jsx-dev-runtime\",\n \"react/jsx-runtime\",\n ],\n },\n };\n },\n configureServer(server) {\n server.middlewares.use(createDevCssProxyMiddleware());\n\n return () => {\n const middlewareOptions: AppRouterViteRuntimeMiddlewareOptions = {\n ...options,\n viteDevServer: server,\n vitePlugins: server.config.plugins,\n };\n\n server.middlewares.use(createAppRouterViteMiddleware(middlewareOptions));\n };\n },\n handleHotUpdate(context) {\n const normalizedFile = normalizePath(context.file);\n\n if (!normalizedSourceDirs.some((directory) => normalizedFile.startsWith(directory))) {\n return;\n }\n\n const timestamp = Date.now();\n const updates = Array.from(context.server.moduleGraph.idToModuleMap.values())\n .filter((moduleNode) => isMreactClientDevModuleId(moduleNode.id))\n .map((moduleNode) => {\n context.server.moduleGraph.invalidateModule(moduleNode);\n\n return {\n acceptedPath: moduleNode.url,\n path: moduleNode.url,\n timestamp,\n type: \"js-update\" as const,\n };\n });\n\n if (updates.length > 0) {\n context.server.ws.send({ type: \"update\", updates });\n }\n\n return [];\n },\n load(id) {\n if (id === virtualReactiveCoreId) {\n return `import { cell as nativeCell } from ${JSON.stringify(reactiveCorePath)};\nexport * from ${JSON.stringify(reactiveCorePath)};\nexport function cell(initial) {\n const routeCell = globalThis.__mreactRouteCell;\n return typeof routeCell === \"function\" ? routeCell(nativeCell, initial) : nativeCell(initial);\n}`;\n }\n\n if (id === virtualReactiveDevtoolsId) {\n return `export function emitReactiveDevtoolsEvent() {}\nexport function hasReactiveDevtoolsEmitter() { return false; }\nexport function currentDevtoolsEmitter() { return undefined; }`;\n }\n\n if (id.startsWith(virtualClientPrefix)) {\n return renderAppRouterClientAsset(project.routesDir, id.slice(virtualClientPrefix.length), {\n dev: true,\n }).then(async (response) => {\n if (!response.ok) {\n const message = await response.text();\n throw new Error(message || `MReact client route asset was not found: ${id}`);\n }\n\n return response.text();\n });\n }\n\n const requestPath = clientRouteModuleRequestPath(id);\n\n return requestPath === undefined\n ? undefined\n : renderAppRouterClientRouteDevModule(project.routesDir, requestPath);\n },\n transform(code, id, options) {\n if (options?.ssr === true) {\n return undefined;\n }\n\n if (isMreactClientDevModuleId(id)) {\n return undefined;\n }\n\n const filename = clientRequestPath(id);\n\n if (!isMreactClientSourceDependency(filename, normalizedSourceDirs)) {\n return undefined;\n }\n\n const moduleContext = createCompilerModuleContext({ code, filename });\n\n if (!hasJsxSyntax(moduleContext.program)) {\n return undefined;\n }\n\n const output = transformCompilerModuleContext({\n code,\n dev: true,\n filename,\n mode: isCompatSourcePath(filename) ? \"compat\" : \"reactive\",\n moduleContext,\n target: \"client\",\n });\n\n if (output.diagnostics.length > 0) {\n throw new Error(\n output.diagnostics.map((diagnostic) => formatDiagnostic(filename, diagnostic)).join(\"\\n\"),\n );\n }\n\n return {\n code: output.code,\n map: null,\n };\n },\n async resolveId(id, importer) {\n const runtimePath = runtimePaths.get(id);\n\n if (id === \"@reckona/mreact-reactive-core\") {\n if (importerInRuntimePackage(importer, runtimePackageDirs, runtimePackageNames)) {\n return reactiveCorePath;\n }\n\n return virtualReactiveCoreId;\n }\n\n if (\n id === \"./devtools.js\" &&\n importerInRuntimePackage(importer, [reactiveCoreDir], [\"@reckona/mreact-reactive-core\"])\n ) {\n return virtualReactiveDevtoolsId;\n }\n\n if (runtimePath !== undefined) {\n return runtimePath;\n }\n\n const requestPath = clientRequestPath(id);\n\n if (requestPath === `${clientPrefix}${navigationRuntimeScriptForDev()}`) {\n return `${virtualClientPrefix}${requestPath}`;\n }\n\n if (!requestPath.startsWith(clientPrefix)) {\n return undefined;\n }\n\n const route = await clientRouteForRequestPath(project.routesDir, requestPath);\n\n return route === undefined ? undefined : clientRouteModuleId(route.file, requestPath);\n },\n };\n\n return plugin;\n}\n\nfunction isMreactClientSourceDependency(\n filename: string,\n normalizedSourceDirs: readonly string[],\n): boolean {\n const normalized = normalizePath(filename);\n\n return (\n /\\.(?:mreact\\.)?[cm]?[jt]sx?$/.test(normalized) &&\n !normalized.includes(\"/node_modules/\") &&\n normalizedSourceDirs.some(\n (directory) => normalized === directory || normalized.startsWith(`${directory}/`),\n )\n );\n}\n\nfunction isCompatSourcePath(filename: string): boolean {\n return /\\.compat(?:\\.mreact)?(?:\\.[cm]?[jt]sx?)?$/.test(filename);\n}\n\nexport const mreactRouter = createAppRouterVitePlugin;\n\nexport function mreactRouterConfigFromPlugins(\n plugins: readonly unknown[],\n): ResolvedAppRouterProject | undefined {\n for (const plugin of plugins.flat(Infinity)) {\n if (plugin !== null && typeof plugin === \"object\" && mreactRouterConfigKey in plugin) {\n return (plugin as MreactRouterPlugin)[mreactRouterConfigKey];\n }\n }\n\n return undefined;\n}\n\nexport function createAppRouterViteMiddleware(\n options: AppRouterViteMiddlewareOptions,\n): Connect.NextHandleFunction {\n return (request, response, next) => {\n void handleAppRouterViteRequest(\n options as AppRouterViteRuntimeMiddlewareOptions,\n request,\n response,\n next,\n );\n };\n}\n\nasync function handleAppRouterViteRequest(\n options: AppRouterViteRuntimeMiddlewareOptions,\n incoming: Connect.IncomingMessage,\n outgoing: ServerResponse,\n next: Connect.NextFunction,\n): Promise<void> {\n try {\n const project = resolveAppRouterProjectOptions(options);\n const host = resolveRequestHost({\n allowedHosts: options.allowedHosts,\n fallbackHost: \"localhost\",\n hostPolicy: options.hostPolicy,\n rawHost: incoming.headers.host,\n });\n const origin = `http://${host}`;\n const url = new URL(incoming.url ?? \"/\", origin);\n\n if (url.pathname.startsWith(clientPrefix)) {\n if (options.viteDevServer !== undefined) {\n const transformed = await options.viteDevServer.transformRequest(\n `${url.pathname}${url.search}`,\n );\n\n if (transformed !== null) {\n await sendResponse(\n outgoing,\n new Response(transformed.code, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n }),\n );\n return;\n }\n }\n\n await sendResponse(\n outgoing,\n await renderAppRouterClientAsset(project.routesDir, url.pathname, {\n vitePlugins: options.vitePlugins,\n }),\n );\n return;\n }\n\n const request = nodeRequestToWebRequest(incoming, origin);\n\n await sendResponse(\n outgoing,\n await renderAppRequest({\n appDir: project.routesDir,\n importPolicy: {\n ...options.importPolicy,\n allowedSourceDirs: project.allowedSourceDirs,\n projectRoot: project.projectRoot,\n },\n clientStyles: await devRouteStyles(project),\n navigationScripts: await devNavigationScripts(project.routesDir),\n request,\n routeCache: options.routeCache,\n serverActions: options.serverActions,\n }),\n );\n } catch (error) {\n next(error);\n }\n}\n\nexport async function renderAppRouterClientAsset(\n appDir: string,\n pathname: string,\n options: { dev?: boolean; vitePlugins?: readonly PluginOption[] | undefined } = {},\n): Promise<Response> {\n if (pathname === `/_mreact/client/${navigationRuntimeScriptForDev()}`) {\n const output = await buildNavigationRuntimeBundle();\n\n return new Response(options.dev === true ? withViteHmrRuntime(output.code) : output.code, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n }\n\n const routes = await scanAppRoutes({ appDir });\n const route = routes.find(\n (candidate) =>\n candidate.kind === \"page\" &&\n `/_mreact/client/${clientScriptForPath(candidate.path)}` === pathname,\n );\n\n if (route === undefined || route.kind !== \"page\") {\n return new Response(\"Not Found\", { status: 404 });\n }\n\n const code = await readFile(route.file, \"utf8\");\n const clientSource = stripRouteClientOnlyExports(code);\n let references: Awaited<ReturnType<typeof collectClientRouteReferences>>;\n\n try {\n references = await collectClientRouteReferences({\n appDir,\n code: clientSource,\n filename: route.file,\n vitePlugins: options.vitePlugins,\n });\n } catch (error) {\n return clientAssetBuildErrorResponse(route.file, error);\n }\n\n if (!references.client) {\n if (isClientRouteSource(clientSource)) {\n return clientAssetBuildErrorResponse(\n route.file,\n new Error(\n [\n \"Client route analysis did not produce a client asset.\",\n \"Browser build cannot import Node builtins or other server-only modules.\",\n ...references.diagnostics.map((diagnostic) => diagnostic.message),\n ].join(\"\\n\"),\n ),\n );\n }\n\n return new Response(\"Not Found\", { status: 404 });\n }\n\n let bundle: string;\n\n try {\n bundle = await buildClientRouteBundle({\n code: clientSource,\n clientBoundaryImports: references.clientBoundaryImports,\n clientReferenceImports: references.clientReferenceImports,\n clientReferenceManifest: references.clientReferenceManifest,\n filename: route.file,\n routePath: route.path,\n vitePlugins: options.vitePlugins,\n });\n } catch (error) {\n return clientAssetBuildErrorResponse(route.file, error);\n }\n\n return new Response(options.dev === true ? withViteHmrRuntime(bundle) : bundle, {\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n}\n\nasync function renderAppRouterClientRouteDevModule(\n appDir: string,\n pathname: string,\n options: { vitePlugins?: readonly PluginOption[] | undefined } = {},\n): Promise<string> {\n const route = await clientRouteForRequestPath(appDir, pathname);\n\n if (route === undefined) {\n throw new Error(`MReact client route asset was not found: ${pathname}`);\n }\n\n const code = await readFile(route.file, \"utf8\");\n const clientSource = stripRouteClientOnlyExports(code);\n const references = await collectClientRouteReferences({\n appDir,\n code: clientSource,\n filename: route.file,\n vitePlugins: options.vitePlugins,\n });\n\n if (!references.client) {\n throw new Error(\n isClientRouteSource(clientSource)\n ? [\n \"Client route analysis did not produce a client asset.\",\n \"Browser build cannot import Node builtins or other server-only modules.\",\n ...references.diagnostics.map((diagnostic) => diagnostic.message),\n ].join(\"\\n\")\n : `MReact client route asset was not found: ${pathname}`,\n );\n }\n\n const entry = await buildClientRouteEntrySource({\n code: clientSource,\n clientBoundaryImports: references.clientBoundaryImports,\n clientReferenceImports: references.clientReferenceImports,\n clientReferenceManifest: references.clientReferenceManifest,\n filename: route.file,\n routePath: route.path,\n vitePlugins: options.vitePlugins,\n });\n\n return withViteHmrRuntime(entry.code);\n}\n\nasync function clientRouteForRequestPath(appDir: string, pathname: string) {\n const routes = await scanAppRoutes({ appDir });\n\n return routes.find(\n (candidate) =>\n candidate.kind === \"page\" &&\n `/_mreact/client/${clientScriptForPath(candidate.path)}` === pathname,\n );\n}\n\nfunction clientRequestPath(id: string): string {\n const [path] = id.split(/[?#]/, 1);\n\n return path ?? id;\n}\n\nfunction clientRouteModuleId(filename: string, requestPath: string): string {\n return `${normalizePath(filename)}?${clientRouteModuleQuery}=${encodeURIComponent(requestPath)}`;\n}\n\nfunction clientRouteModuleRequestPath(id: string): string | undefined {\n const queryStart = id.indexOf(\"?\");\n\n if (queryStart === -1) {\n return undefined;\n }\n\n const params = new URLSearchParams(id.slice(queryStart + 1));\n const value = params.get(clientRouteModuleQuery);\n\n return value === null ? undefined : value;\n}\n\nfunction isMreactClientDevModuleId(id: string | null | undefined): boolean {\n return (\n id?.startsWith(virtualClientPrefix) === true ||\n id?.includes(`?${clientRouteModuleQuery}=`) === true ||\n id?.includes(`&${clientRouteModuleQuery}=`) === true\n );\n}\n\nfunction importerInRuntimePackage(\n importer: string | undefined,\n directories: readonly string[],\n packageNames: readonly string[],\n): boolean {\n if (importer === undefined) {\n return false;\n }\n\n const normalizedImporter = normalizePath(importer);\n return (\n directories.some((directory) => normalizedImporter.startsWith(`${directory}/`)) ||\n packageNames.some((packageName) => normalizedImporter.includes(`/node_modules/${packageName}/`))\n );\n}\n\nfunction clientAssetBuildErrorResponse(filename: string, error: unknown): Response {\n const message = [\n `Failed to build mreact client route asset for ${filename}.`,\n error instanceof Error ? error.message : String(error),\n ].join(\"\\n\");\n\n return new Response(`throw new Error(${JSON.stringify(message)});\\n`, {\n status: 500,\n headers: { \"content-type\": \"text/javascript; charset=utf-8\" },\n });\n}\n\nasync function devRouteStyles(\n project: ResolvedAppRouterProject,\n): Promise<ReadonlyMap<string, readonly string[]>> {\n const entries = await Promise.all(\n (await scanAppRoutes({ appDir: project.routesDir })).map(async (route) => {\n if (route.kind !== \"page\") {\n return undefined;\n }\n\n const hrefs = await collectRouteCssHrefs({\n appDir: project.routesDir,\n hrefPrefix: devCssPrefix,\n pageFile: route.file,\n projectRoot: project.projectRoot,\n });\n\n return hrefs.length === 0 ? undefined : ([route.path, hrefs as readonly string[]] as const);\n }),\n );\n const routeStyles = entries.filter(\n (entry): entry is readonly [string, readonly string[]] => entry !== undefined,\n );\n\n return new Map<string, readonly string[]>(routeStyles);\n}\n\nasync function devNavigationScripts(appDir: string): Promise<ReadonlyMap<string, string>> {\n const entries = await Promise.all(\n (await scanAppRoutes({ appDir })).map(async (route) => {\n if (route.kind !== \"page\") {\n return undefined;\n }\n\n const source = await readFile(route.file, \"utf8\");\n\n return detectNavigationRuntimeHint(source)\n ? ([route.path, navigationRuntimeScriptForDev()] as const)\n : undefined;\n }),\n );\n\n return new Map(\n entries.filter((entry): entry is readonly [string, string] => entry !== undefined),\n );\n}\n\nfunction createDevCssProxyMiddleware(): Connect.NextHandleFunction {\n return (incoming, outgoing, next) => {\n const originalUrl = incoming.url ?? \"/\";\n const url = new URL(originalUrl, \"http://mreact.local\");\n\n if (!url.pathname.startsWith(devCssPrefix)) {\n next();\n return;\n }\n\n const sourcePath = `/${url.pathname.slice(devCssPrefix.length)}`;\n\n if (sourcePath === \"/\" || sourcePath.includes(\"\\0\")) {\n next();\n return;\n }\n\n const originalAccept = incoming.headers.accept;\n let restored = false;\n const restore = () => {\n if (restored) {\n return;\n }\n restored = true;\n incoming.url = originalUrl;\n if (originalAccept === undefined) {\n delete incoming.headers.accept;\n } else {\n incoming.headers.accept = originalAccept;\n }\n };\n\n incoming.url = `${sourcePath}${url.search}`;\n incoming.headers.accept = \"text/css,*/*;q=0.1\";\n outgoing.once(\"finish\", restore);\n outgoing.once(\"close\", restore);\n next();\n };\n}\n\nfunction withViteHmrRuntime(code: string): string {\n return `import \"/@vite/client\";\nif (import.meta.hot?.data.__mreactRouteStates) {\n globalThis.__mreactRouteStates = import.meta.hot.data.__mreactRouteStates;\n}\n${code}\nif (import.meta.hot) {\n const __mreactPreserveRouteState = () => {\n import.meta.hot.data.__mreactRouteStates = globalThis.__mreactRouteStates;\n };\n import.meta.hot.dispose(__mreactPreserveRouteState);\n import.meta.hot.accept((module) => {\n module?.__mreactHydrateRoute?.();\n });\n}\n`;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
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-compat": "0.0.86",
109
- "@reckona/mreact": "0.0.86",
110
- "@reckona/mreact-compiler": "0.0.86",
111
- "@reckona/mreact-query": "0.0.86",
112
- "@reckona/mreact-devtools": "0.0.86",
113
- "@reckona/mreact-reactive-core": "0.0.86",
114
- "@reckona/mreact-reactive-dom": "0.0.86",
115
- "@reckona/mreact-server": "0.0.86",
116
- "@reckona/mreact-shared": "0.0.86"
108
+ "@reckona/mreact-compat": "0.0.88",
109
+ "@reckona/mreact-compiler": "0.0.88",
110
+ "@reckona/mreact-query": "0.0.88",
111
+ "@reckona/mreact-devtools": "0.0.88",
112
+ "@reckona/mreact-reactive-core": "0.0.88",
113
+ "@reckona/mreact": "0.0.88",
114
+ "@reckona/mreact-reactive-dom": "0.0.88",
115
+ "@reckona/mreact-server": "0.0.88",
116
+ "@reckona/mreact-shared": "0.0.88"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.86"
122
+ "@reckona/mreact-router-native": "0.0.88"
123
123
  }
124
124
  }
@@ -1,5 +1,7 @@
1
1
  import { builtinModules } from "node:module";
2
- import { dirname } from "node:path";
2
+ import { access } from "node:fs/promises";
3
+ import { dirname, extname, isAbsolute, join, resolve } from "node:path";
4
+ import { pathToFileURL } from "node:url";
3
5
  import {
4
6
  build as viteBuild,
5
7
  type InlineConfig,
@@ -12,6 +14,7 @@ export interface RouterBundleOptions {
12
14
  base?: string | undefined;
13
15
  code: string;
14
16
  define?: Record<string, string> | undefined;
17
+ externalizeAppSourceModuleDirs?: readonly string[] | undefined;
15
18
  filename: string;
16
19
  minify?: boolean | undefined;
17
20
  modulePreload?: boolean | undefined;
@@ -124,11 +127,11 @@ export type RouterCompatResolveResult =
124
127
  }
125
128
  | undefined;
126
129
 
127
- const nodeBuiltinSpecifiers = new Set(
128
- builtinModules.flatMap((name) => [name, `node:${name}`]),
129
- );
130
+ const nodeBuiltinSpecifiers = new Set(builtinModules.flatMap((name) => [name, `node:${name}`]));
130
131
 
131
- export async function bundleRouterModule(options: RouterBundleOptions): Promise<RouterBundleOutput> {
132
+ export async function bundleRouterModule(
133
+ options: RouterBundleOptions,
134
+ ): Promise<RouterBundleOutput> {
132
135
  const entryId = `${options.filename}?mreact-router-entry`;
133
136
  const outfile = options.outfile ?? "entry.js";
134
137
  const config = {
@@ -141,6 +144,14 @@ export async function bundleRouterModule(options: RouterBundleOptions): Promise<
141
144
  mreactJsxRuntimeAliasPlugin(),
142
145
  ...(options.vitePlugins ?? []),
143
146
  virtualEntryPlugin(entryId, options.code),
147
+ ...(options.externalizeAppSourceModuleDirs === undefined
148
+ ? []
149
+ : [
150
+ externalizeAppSourceModulesPlugin(
151
+ options.filename,
152
+ options.externalizeAppSourceModuleDirs,
153
+ ),
154
+ ]),
144
155
  ...(options.plugins ?? []).map(routerCompatPlugin),
145
156
  ],
146
157
  publicDir: false,
@@ -150,13 +161,14 @@ export async function bundleRouterModule(options: RouterBundleOptions): Promise<
150
161
  },
151
162
  build: {
152
163
  emptyOutDir: false,
153
- lib: options.preserveExports === true
154
- ? {
155
- entry: entryId,
156
- fileName: () => outfile,
157
- formats: ["es"],
158
- }
159
- : false,
164
+ lib:
165
+ options.preserveExports === true
166
+ ? {
167
+ entry: entryId,
168
+ fileName: () => outfile,
169
+ formats: ["es"],
170
+ }
171
+ : false,
160
172
  minify: options.minify === true,
161
173
  modulePreload: options.modulePreload ?? true,
162
174
  sourcemap: options.sourceMap === true,
@@ -186,8 +198,9 @@ export async function bundleRouterModule(options: RouterBundleOptions): Promise<
186
198
  item.type === "asset" && item.fileName === `${chunk?.fileName ?? outfile}.map`,
187
199
  );
188
200
  const assets = output.output
189
- .filter((item): item is RouterBundlerAsset =>
190
- item.type === "asset" && item.fileName !== `${chunk?.fileName ?? outfile}.map`
201
+ .filter(
202
+ (item): item is RouterBundlerAsset =>
203
+ item.type === "asset" && item.fileName !== `${chunk?.fileName ?? outfile}.map`,
191
204
  )
192
205
  .map((asset) => ({ fileName: asset.fileName, source: asset.source }));
193
206
 
@@ -262,11 +275,12 @@ export async function bundleRouterModules(
262
275
 
263
276
  const mapAssets = new Map(
264
277
  output.output
265
- .filter((item): item is RouterBundlerAsset =>
266
- item.type === "asset" && item.fileName.endsWith(".map")
278
+ .filter(
279
+ (item): item is RouterBundlerAsset =>
280
+ item.type === "asset" && item.fileName.endsWith(".map"),
267
281
  )
268
282
  .flatMap((asset) =>
269
- typeof asset.source === "string" ? [[asset.fileName, asset.source] as const] : []
283
+ typeof asset.source === "string" ? [[asset.fileName, asset.source] as const] : [],
270
284
  ),
271
285
  );
272
286
  const chunks = output.output
@@ -284,8 +298,9 @@ export async function bundleRouterModules(
284
298
  };
285
299
  });
286
300
  const assets = output.output
287
- .filter((item): item is RouterBundlerAsset =>
288
- item.type === "asset" && !item.fileName.endsWith(".map")
301
+ .filter(
302
+ (item): item is RouterBundlerAsset =>
303
+ item.type === "asset" && !item.fileName.endsWith(".map"),
289
304
  )
290
305
  .map((asset) => ({ fileName: asset.fileName, source: asset.source }));
291
306
 
@@ -297,13 +312,49 @@ export async function bundleRouterModules(
297
312
 
298
313
  function mreactJsxRuntimeAliasPlugin(): VitePlugin {
299
314
  const runtimePaths = new Map([
315
+ [
316
+ "react",
317
+ workspacePackageFile({
318
+ currentFileUrl: import.meta.url,
319
+ entry: "index",
320
+ monorepoDir: "react-compat",
321
+ packageName: "@reckona/mreact-compat",
322
+ }),
323
+ ],
324
+ [
325
+ "react-dom",
326
+ workspacePackageFile({
327
+ currentFileUrl: import.meta.url,
328
+ entry: "index",
329
+ monorepoDir: "react-compat",
330
+ packageName: "@reckona/mreact-compat",
331
+ }),
332
+ ],
333
+ [
334
+ "react-dom/client",
335
+ workspacePackageFile({
336
+ currentFileUrl: import.meta.url,
337
+ entry: "index",
338
+ monorepoDir: "react-compat",
339
+ packageName: "@reckona/mreact-compat",
340
+ }),
341
+ ],
342
+ [
343
+ "react-dom/server",
344
+ workspacePackageFile({
345
+ currentFileUrl: import.meta.url,
346
+ entry: "index",
347
+ monorepoDir: "react-compat",
348
+ packageName: "@reckona/mreact-compat",
349
+ }),
350
+ ],
300
351
  [
301
352
  "react/jsx-dev-runtime",
302
353
  workspacePackageFile({
303
354
  currentFileUrl: import.meta.url,
304
355
  entry: "jsx-dev-runtime",
305
- monorepoDir: "react",
306
- packageName: "@reckona/mreact",
356
+ monorepoDir: "react-compat",
357
+ packageName: "@reckona/mreact-compat",
307
358
  }),
308
359
  ],
309
360
  [
@@ -311,8 +362,8 @@ function mreactJsxRuntimeAliasPlugin(): VitePlugin {
311
362
  workspacePackageFile({
312
363
  currentFileUrl: import.meta.url,
313
364
  entry: "jsx-runtime",
314
- monorepoDir: "react",
315
- packageName: "@reckona/mreact",
365
+ monorepoDir: "react-compat",
366
+ packageName: "@reckona/mreact-compat",
316
367
  }),
317
368
  ],
318
369
  ]);
@@ -326,6 +377,86 @@ function mreactJsxRuntimeAliasPlugin(): VitePlugin {
326
377
  };
327
378
  }
328
379
 
380
+ function externalizeAppSourceModulesPlugin(
381
+ entryFilename: string,
382
+ sourceDirs: readonly string[],
383
+ ): VitePlugin {
384
+ const normalizedSourceDirs = sourceDirs.map((directory) => resolve(directory));
385
+
386
+ return {
387
+ name: "mreact-router-externalize-app-source-modules",
388
+ enforce: "pre",
389
+ async resolveId(id, importer) {
390
+ if (importer === undefined || !isAppSourceImport(id)) {
391
+ return undefined;
392
+ }
393
+
394
+ const importerPath = cleanViteId(importer);
395
+ const resolved = await resolveAppSourceImport(id, dirname(importerPath));
396
+
397
+ if (
398
+ resolved === undefined ||
399
+ resolved === entryFilename ||
400
+ !isExternalizableAppSourceModule(resolved) ||
401
+ !isInsideAnyDirectory(normalizedSourceDirs, resolved)
402
+ ) {
403
+ return undefined;
404
+ }
405
+
406
+ return {
407
+ external: true,
408
+ id: pathToFileURL(resolved).href,
409
+ };
410
+ },
411
+ };
412
+ }
413
+
414
+ function isInsideAnyDirectory(directories: readonly string[], path: string): boolean {
415
+ return directories.some((directory) => path === directory || path.startsWith(`${directory}/`));
416
+ }
417
+
418
+ function isAppSourceImport(id: string): boolean {
419
+ return id.startsWith(".") || id.startsWith("/") || isAbsolute(id);
420
+ }
421
+
422
+ function isExternalizableAppSourceModule(path: string): boolean {
423
+ return /\.(?:[cm]?ts|[cm]?js)$/u.test(path);
424
+ }
425
+
426
+ async function resolveAppSourceImport(id: string, resolveDir: string): Promise<string | undefined> {
427
+ const base = isAbsolute(id) ? id : resolve(resolveDir, id);
428
+ const extension = extname(base);
429
+ const candidates =
430
+ extension === ""
431
+ ? [
432
+ base,
433
+ `${base}.ts`,
434
+ `${base}.mts`,
435
+ `${base}.cts`,
436
+ `${base}.js`,
437
+ `${base}.mjs`,
438
+ `${base}.cjs`,
439
+ join(base, "index.ts"),
440
+ join(base, "index.mts"),
441
+ join(base, "index.cts"),
442
+ join(base, "index.js"),
443
+ join(base, "index.mjs"),
444
+ join(base, "index.cjs"),
445
+ ]
446
+ : [base];
447
+
448
+ for (const candidate of candidates) {
449
+ try {
450
+ await access(candidate);
451
+ return candidate;
452
+ } catch {
453
+ continue;
454
+ }
455
+ }
456
+
457
+ return undefined;
458
+ }
459
+
329
460
  function stripSourceMappingUrl(code: string): string {
330
461
  return code.replace(/\n?\/\/# sourceMappingURL=[^\n]+\.map\s*$/u, "");
331
462
  }
@@ -353,7 +484,9 @@ function virtualEntriesPlugin(entries: ReadonlyMap<string, RouterBundleEntryOpti
353
484
  load(id) {
354
485
  const entry = entries.get(id);
355
486
 
356
- return entry === undefined ? undefined : { code: entry.code, moduleType: moduleTypeForFilename(id) };
487
+ return entry === undefined
488
+ ? undefined
489
+ : { code: entry.code, moduleType: moduleTypeForFilename(id) };
357
490
  },
358
491
  };
359
492
  }