@react-router/dev 0.0.0-experimental-b2bc694a6 → 0.0.0-experimental-a25eed86d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v0.0.0-experimental-b2bc694a6
3
+ * @react-router/dev v0.0.0-experimental-a25eed86d
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -933,18 +933,21 @@ function register(ctx) {
933
933
  }
934
934
  `;
935
935
  const { t: t2 } = babel_exports;
936
- const indexPaths = new Set(
937
- Object.values(ctx.config.routes).filter((route) => route.index).map((route) => route.path)
938
- );
936
+ const fullpaths = {};
937
+ for (const route of Object.values(ctx.config.routes)) {
938
+ if (route.id !== "root" && !route.path) continue;
939
+ const lineage2 = lineage(ctx.config.routes, route);
940
+ const fullpath2 = fullpath(lineage2);
941
+ const existing = fullpaths[fullpath2];
942
+ if (!existing || existing.length < lineage2.length) {
943
+ fullpaths[fullpath2] = lineage2;
944
+ }
945
+ }
939
946
  const typeParams = t2.tsTypeAliasDeclaration(
940
947
  t2.identifier("Params"),
941
948
  null,
942
949
  t2.tsTypeLiteral(
943
- Object.values(ctx.config.routes).map((route) => {
944
- if (route.id !== "root" && !route.path) return void 0;
945
- if (!route.index && indexPaths.has(route.path)) return void 0;
946
- const lineage2 = lineage(ctx.config.routes, route);
947
- const fullpath2 = fullpath(lineage2);
950
+ Object.keys(fullpaths).map((fullpath2) => {
948
951
  const params = parse2(fullpath2);
949
952
  return t2.tsPropertySignature(
950
953
  t2.stringLiteral(fullpath2),
@@ -961,7 +964,7 @@ function register(ctx) {
961
964
  )
962
965
  )
963
966
  );
964
- }).filter((x) => x !== void 0)
967
+ })
965
968
  )
966
969
  );
967
970
  return [register2, generate(typeParams).code].join("\n\n");
@@ -1031,6 +1034,7 @@ var init_styles = __esm({
1031
1034
  path6 = __toESM(require("path"));
1032
1035
  import_react_router = require("react-router");
1033
1036
  init_resolve_file_url();
1037
+ init_babel();
1034
1038
  cssFileRegExp = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
1035
1039
  cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
1036
1040
  }
@@ -1353,9 +1357,6 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1353
1357
  }
1354
1358
  });
1355
1359
  }
1356
- if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
1357
- environmentOptionsResolvers[CSS_DEV_HELPER_ENVIRONMENT_NAME] = () => ({});
1358
- }
1359
1360
  return environmentOptionsResolvers;
1360
1361
  }
1361
1362
  function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
@@ -1370,7 +1371,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1370
1371
  function isNonNullable(x) {
1371
1372
  return x != null;
1372
1373
  }
1373
- var import_node_crypto, fs4, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, CSS_DEV_HELPER_ENVIRONMENT_NAME, virtualHmrRuntime, virtualInjectHmrRuntime, virtual2, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1374
+ var import_node_crypto, fs4, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual2, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1374
1375
  var init_plugin = __esm({
1375
1376
  "vite/plugin.ts"() {
1376
1377
  "use strict";
@@ -1418,7 +1419,6 @@ var init_plugin = __esm({
1418
1419
  ];
1419
1420
  BUILD_CLIENT_ROUTE_QUERY_STRING = "?__react-router-build-client-route";
1420
1421
  SSR_BUNDLE_PREFIX = "ssrBundle_";
1421
- CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
1422
1422
  virtualHmrRuntime = create("hmr-runtime");
1423
1423
  virtualInjectHmrRuntime = create("inject-hmr-runtime");
1424
1424
  virtual2 = {
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-b2bc694a6
2
+ * @react-router/dev v0.0.0-experimental-a25eed86d
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-b2bc694a6
2
+ * @react-router/dev v0.0.0-experimental-a25eed86d
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-b2bc694a6
2
+ * @react-router/dev v0.0.0-experimental-a25eed86d
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-b2bc694a6
2
+ * @react-router/dev v0.0.0-experimental-a25eed86d
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -906,18 +906,21 @@ function register(ctx) {
906
906
  }
907
907
  `;
908
908
  const { t: t2 } = babel_exports;
909
- const indexPaths = new Set(
910
- Object.values(ctx.config.routes).filter((route) => route.index).map((route) => route.path)
911
- );
909
+ const fullpaths = {};
910
+ for (const route of Object.values(ctx.config.routes)) {
911
+ if (route.id !== "root" && !route.path) continue;
912
+ const lineage2 = lineage(ctx.config.routes, route);
913
+ const fullpath2 = fullpath(lineage2);
914
+ const existing = fullpaths[fullpath2];
915
+ if (!existing || existing.length < lineage2.length) {
916
+ fullpaths[fullpath2] = lineage2;
917
+ }
918
+ }
912
919
  const typeParams = t2.tsTypeAliasDeclaration(
913
920
  t2.identifier("Params"),
914
921
  null,
915
922
  t2.tsTypeLiteral(
916
- Object.values(ctx.config.routes).map((route) => {
917
- if (route.id !== "root" && !route.path) return void 0;
918
- if (!route.index && indexPaths.has(route.path)) return void 0;
919
- const lineage2 = lineage(ctx.config.routes, route);
920
- const fullpath2 = fullpath(lineage2);
923
+ Object.keys(fullpaths).map((fullpath2) => {
921
924
  const params = parse2(fullpath2);
922
925
  return t2.tsPropertySignature(
923
926
  t2.stringLiteral(fullpath2),
@@ -934,7 +937,7 @@ function register(ctx) {
934
937
  )
935
938
  )
936
939
  );
937
- }).filter((x) => x !== void 0)
940
+ })
938
941
  )
939
942
  );
940
943
  return [register2, generate(typeParams).code].join("\n\n");
@@ -1199,6 +1202,20 @@ var getStylesForPathname = async ({
1199
1202
  });
1200
1203
  return styles;
1201
1204
  };
1205
+ var getCssStringFromViteDevModuleCode = (code) => {
1206
+ let cssContent = void 0;
1207
+ const ast = import_parser.parse(code, { sourceType: "module" });
1208
+ traverse(ast, {
1209
+ VariableDeclaration(path7) {
1210
+ const declaration = path7.node.declarations[0];
1211
+ if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
1212
+ cssContent = declaration.init.value;
1213
+ path7.stop();
1214
+ }
1215
+ }
1216
+ });
1217
+ return cssContent;
1218
+ };
1202
1219
 
1203
1220
  // vite/virtual-module.ts
1204
1221
  function create(name) {
@@ -2085,7 +2102,6 @@ var SSR_BUNDLE_PREFIX = "ssrBundle_";
2085
2102
  function isSsrBundleEnvironmentName(name) {
2086
2103
  return name.startsWith(SSR_BUNDLE_PREFIX);
2087
2104
  }
2088
- var CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
2089
2105
  function getServerEnvironmentEntries(ctx, record) {
2090
2106
  return Object.entries(record).filter(
2091
2107
  ([name]) => ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr"
@@ -2306,7 +2322,6 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2306
2322
  );
2307
2323
  return Object.keys(serverBundleRoutes);
2308
2324
  };
2309
- var injectQuery = (url2, query) => url2.includes("?") ? url2.replace("?", `?${query}&`) : `${url2}?${query}`;
2310
2325
  var defaultEntriesDir = path6.resolve(
2311
2326
  path6.dirname(require.resolve("@react-router/dev/package.json")),
2312
2327
  "dist",
@@ -2716,31 +2731,17 @@ var reactRouterVitePlugin = () => {
2716
2731
  if (dep.file && isCssModulesFile(dep.file)) {
2717
2732
  return cssModulesManifest[dep.file];
2718
2733
  }
2719
- const vite2 = getVite();
2720
- const viteMajor = parseInt(vite2.version.split(".")[0], 10);
2721
- const url2 = viteMajor >= 6 ? (
2722
- // We need the ?inline query in Vite v6 when loading CSS in SSR
2723
- // since it does not expose the default export for CSS in a
2724
- // server environment. This is to align with non-SSR
2725
- // environments. For backwards compatibility with v5 we keep
2726
- // using the URL without ?inline query because the HMR code was
2727
- // relying on the implicit SSR-client module graph relationship.
2728
- injectQuery(dep.url, "inline")
2729
- ) : dep.url;
2730
- let cssMod;
2731
- if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) {
2732
- const cssDevHelperEnvironment = viteDevServer.environments[CSS_DEV_HELPER_ENVIRONMENT_NAME];
2733
- invariant(cssDevHelperEnvironment, "Missing CSS dev helper environment");
2734
- invariant(vite2.isRunnableDevEnvironment(cssDevHelperEnvironment));
2735
- cssMod = await cssDevHelperEnvironment.runner.import(url2);
2736
- } else {
2737
- cssMod = await viteDevServer.ssrLoadModule(url2);
2738
- }
2734
+ let transformedCssCode = (await viteDevServer.transformRequest(dep.url))?.code;
2739
2735
  invariant(
2740
- typeof cssMod === "object" && cssMod !== null && "default" in cssMod && typeof cssMod.default === "string",
2736
+ transformedCssCode,
2741
2737
  `Failed to load CSS for ${dep.file ?? dep.url}`
2742
2738
  );
2743
- return cssMod.default;
2739
+ let cssString = getCssStringFromViteDevModuleCode(transformedCssCode);
2740
+ invariant(
2741
+ typeof cssString === "string",
2742
+ `Failed to extract CSS for ${dep.file ?? dep.url}`
2743
+ );
2744
+ return cssString;
2744
2745
  };
2745
2746
  return [
2746
2747
  {
@@ -4482,9 +4483,6 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4482
4483
  }
4483
4484
  });
4484
4485
  }
4485
- if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
4486
- environmentOptionsResolvers[CSS_DEV_HELPER_ENVIRONMENT_NAME] = () => ({});
4487
- }
4488
4486
  return environmentOptionsResolvers;
4489
4487
  }
4490
4488
  function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "0.0.0-experimental-b2bc694a6",
3
+ "version": "0.0.0-experimental-a25eed86d",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -86,7 +86,7 @@
86
86
  "set-cookie-parser": "^2.6.0",
87
87
  "valibot": "^0.41.0",
88
88
  "vite-node": "3.0.0-beta.2",
89
- "@react-router/node": "0.0.0-experimental-b2bc694a6"
89
+ "@react-router/node": "0.0.0-experimental-a25eed86d"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/babel__core": "^7.20.5",
@@ -110,15 +110,15 @@
110
110
  "vite": "^6.1.0",
111
111
  "wireit": "0.14.9",
112
112
  "wrangler": "^4.2.0",
113
- "react-router": "^0.0.0-experimental-b2bc694a6",
114
- "@react-router/serve": "0.0.0-experimental-b2bc694a6"
113
+ "@react-router/serve": "0.0.0-experimental-a25eed86d",
114
+ "react-router": "^0.0.0-experimental-a25eed86d"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "typescript": "^5.1.0",
118
118
  "vite": "^5.1.0 || ^6.0.0",
119
119
  "wrangler": "^3.28.2 || ^4.0.0",
120
- "@react-router/serve": "^0.0.0-experimental-b2bc694a6",
121
- "react-router": "^0.0.0-experimental-b2bc694a6"
120
+ "@react-router/serve": "^0.0.0-experimental-a25eed86d",
121
+ "react-router": "^0.0.0-experimental-a25eed86d"
122
122
  },
123
123
  "peerDependenciesMeta": {
124
124
  "@react-router/serve": {