@react-router/dev 0.0.0-experimental-a25eed86d → 0.0.0-experimental-818f8e08d

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-a25eed86d
3
+ * @react-router/dev v0.0.0-experimental-818f8e08d
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -933,21 +933,18 @@ function register(ctx) {
933
933
  }
934
934
  `;
935
935
  const { t: t2 } = babel_exports;
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
- }
936
+ const indexPaths = new Set(
937
+ Object.values(ctx.config.routes).filter((route) => route.index).map((route) => route.path)
938
+ );
946
939
  const typeParams = t2.tsTypeAliasDeclaration(
947
940
  t2.identifier("Params"),
948
941
  null,
949
942
  t2.tsTypeLiteral(
950
- Object.keys(fullpaths).map((fullpath2) => {
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);
951
948
  const params = parse2(fullpath2);
952
949
  return t2.tsPropertySignature(
953
950
  t2.stringLiteral(fullpath2),
@@ -964,7 +961,7 @@ function register(ctx) {
964
961
  )
965
962
  )
966
963
  );
967
- })
964
+ }).filter((x) => x !== void 0)
968
965
  )
969
966
  );
970
967
  return [register2, generate(typeParams).code].join("\n\n");
@@ -1034,7 +1031,6 @@ var init_styles = __esm({
1034
1031
  path6 = __toESM(require("path"));
1035
1032
  import_react_router = require("react-router");
1036
1033
  init_resolve_file_url();
1037
- init_babel();
1038
1034
  cssFileRegExp = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
1039
1035
  cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
1040
1036
  }
@@ -1357,6 +1353,9 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1357
1353
  }
1358
1354
  });
1359
1355
  }
1356
+ if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
1357
+ environmentOptionsResolvers[CSS_DEV_HELPER_ENVIRONMENT_NAME] = () => ({});
1358
+ }
1360
1359
  return environmentOptionsResolvers;
1361
1360
  }
1362
1361
  function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
@@ -1371,7 +1370,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1371
1370
  function isNonNullable(x) {
1372
1371
  return x != null;
1373
1372
  }
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;
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;
1375
1374
  var init_plugin = __esm({
1376
1375
  "vite/plugin.ts"() {
1377
1376
  "use strict";
@@ -1419,6 +1418,7 @@ var init_plugin = __esm({
1419
1418
  ];
1420
1419
  BUILD_CLIENT_ROUTE_QUERY_STRING = "?__react-router-build-client-route";
1421
1420
  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-a25eed86d
2
+ * @react-router/dev v0.0.0-experimental-818f8e08d
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-a25eed86d
2
+ * @react-router/dev v0.0.0-experimental-818f8e08d
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-a25eed86d
2
+ * @react-router/dev v0.0.0-experimental-818f8e08d
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-a25eed86d
2
+ * @react-router/dev v0.0.0-experimental-818f8e08d
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -906,21 +906,18 @@ function register(ctx) {
906
906
  }
907
907
  `;
908
908
  const { t: t2 } = babel_exports;
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
- }
909
+ const indexPaths = new Set(
910
+ Object.values(ctx.config.routes).filter((route) => route.index).map((route) => route.path)
911
+ );
919
912
  const typeParams = t2.tsTypeAliasDeclaration(
920
913
  t2.identifier("Params"),
921
914
  null,
922
915
  t2.tsTypeLiteral(
923
- Object.keys(fullpaths).map((fullpath2) => {
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);
924
921
  const params = parse2(fullpath2);
925
922
  return t2.tsPropertySignature(
926
923
  t2.stringLiteral(fullpath2),
@@ -937,7 +934,7 @@ function register(ctx) {
937
934
  )
938
935
  )
939
936
  );
940
- })
937
+ }).filter((x) => x !== void 0)
941
938
  )
942
939
  );
943
940
  return [register2, generate(typeParams).code].join("\n\n");
@@ -1202,20 +1199,6 @@ var getStylesForPathname = async ({
1202
1199
  });
1203
1200
  return styles;
1204
1201
  };
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
- };
1219
1202
 
1220
1203
  // vite/virtual-module.ts
1221
1204
  function create(name) {
@@ -2102,6 +2085,7 @@ var SSR_BUNDLE_PREFIX = "ssrBundle_";
2102
2085
  function isSsrBundleEnvironmentName(name) {
2103
2086
  return name.startsWith(SSR_BUNDLE_PREFIX);
2104
2087
  }
2088
+ var CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
2105
2089
  function getServerEnvironmentEntries(ctx, record) {
2106
2090
  return Object.entries(record).filter(
2107
2091
  ([name]) => ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr"
@@ -2322,6 +2306,7 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2322
2306
  );
2323
2307
  return Object.keys(serverBundleRoutes);
2324
2308
  };
2309
+ var injectQuery = (url2, query) => url2.includes("?") ? url2.replace("?", `?${query}&`) : `${url2}?${query}`;
2325
2310
  var defaultEntriesDir = path6.resolve(
2326
2311
  path6.dirname(require.resolve("@react-router/dev/package.json")),
2327
2312
  "dist",
@@ -2731,17 +2716,31 @@ var reactRouterVitePlugin = () => {
2731
2716
  if (dep.file && isCssModulesFile(dep.file)) {
2732
2717
  return cssModulesManifest[dep.file];
2733
2718
  }
2734
- let transformedCssCode = (await viteDevServer.transformRequest(dep.url))?.code;
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
+ }
2735
2739
  invariant(
2736
- transformedCssCode,
2740
+ typeof cssMod === "object" && cssMod !== null && "default" in cssMod && typeof cssMod.default === "string",
2737
2741
  `Failed to load CSS for ${dep.file ?? dep.url}`
2738
2742
  );
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;
2743
+ return cssMod.default;
2745
2744
  };
2746
2745
  return [
2747
2746
  {
@@ -4483,6 +4482,9 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4483
4482
  }
4484
4483
  });
4485
4484
  }
4485
+ if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
4486
+ environmentOptionsResolvers[CSS_DEV_HELPER_ENVIRONMENT_NAME] = () => ({});
4487
+ }
4486
4488
  return environmentOptionsResolvers;
4487
4489
  }
4488
4490
  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-a25eed86d",
3
+ "version": "0.0.0-experimental-818f8e08d",
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-a25eed86d"
89
+ "@react-router/node": "0.0.0-experimental-818f8e08d"
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/serve": "0.0.0-experimental-a25eed86d",
114
- "react-router": "^0.0.0-experimental-a25eed86d"
113
+ "react-router": "^0.0.0-experimental-818f8e08d",
114
+ "@react-router/serve": "0.0.0-experimental-818f8e08d"
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-a25eed86d",
121
- "react-router": "^0.0.0-experimental-a25eed86d"
120
+ "@react-router/serve": "^0.0.0-experimental-818f8e08d",
121
+ "react-router": "^0.0.0-experimental-818f8e08d"
122
122
  },
123
123
  "peerDependenciesMeta": {
124
124
  "@react-router/serve": {