@tanstack/router-plugin 1.166.9 → 1.166.11

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.
Files changed (80) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/cjs/core/code-splitter/compilers.cjs +866 -1324
  3. package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
  4. package/dist/cjs/core/code-splitter/framework-options.cjs +39 -41
  5. package/dist/cjs/core/code-splitter/framework-options.cjs.map +1 -1
  6. package/dist/cjs/core/code-splitter/path-ids.cjs +26 -31
  7. package/dist/cjs/core/code-splitter/path-ids.cjs.map +1 -1
  8. package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs +11 -14
  9. package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs.map +1 -1
  10. package/dist/cjs/core/code-splitter/plugins/react-refresh-route-components.cjs +31 -65
  11. package/dist/cjs/core/code-splitter/plugins/react-refresh-route-components.cjs.map +1 -1
  12. package/dist/cjs/core/config.cjs +36 -46
  13. package/dist/cjs/core/config.cjs.map +1 -1
  14. package/dist/cjs/core/constants.cjs +16 -15
  15. package/dist/cjs/core/constants.cjs.map +1 -1
  16. package/dist/cjs/core/route-autoimport-plugin.cjs +81 -115
  17. package/dist/cjs/core/route-autoimport-plugin.cjs.map +1 -1
  18. package/dist/cjs/core/route-hmr-statement.cjs +34 -56
  19. package/dist/cjs/core/route-hmr-statement.cjs.map +1 -1
  20. package/dist/cjs/core/router-code-splitter-plugin.cjs +236 -306
  21. package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
  22. package/dist/cjs/core/router-composed-plugin.cjs +28 -34
  23. package/dist/cjs/core/router-composed-plugin.cjs.map +1 -1
  24. package/dist/cjs/core/router-generator-plugin.cjs +101 -133
  25. package/dist/cjs/core/router-generator-plugin.cjs.map +1 -1
  26. package/dist/cjs/core/router-hmr-plugin.cjs +81 -81
  27. package/dist/cjs/core/router-hmr-plugin.cjs.map +1 -1
  28. package/dist/cjs/core/utils.cjs +23 -30
  29. package/dist/cjs/core/utils.cjs.map +1 -1
  30. package/dist/cjs/esbuild.cjs +47 -18
  31. package/dist/cjs/esbuild.cjs.map +1 -1
  32. package/dist/cjs/index.cjs +11 -13
  33. package/dist/cjs/rspack.cjs +58 -19
  34. package/dist/cjs/rspack.cjs.map +1 -1
  35. package/dist/cjs/vite.cjs +52 -20
  36. package/dist/cjs/vite.cjs.map +1 -1
  37. package/dist/cjs/webpack.cjs +46 -19
  38. package/dist/cjs/webpack.cjs.map +1 -1
  39. package/dist/esm/core/code-splitter/compilers.js +859 -1307
  40. package/dist/esm/core/code-splitter/compilers.js.map +1 -1
  41. package/dist/esm/core/code-splitter/framework-options.js +40 -42
  42. package/dist/esm/core/code-splitter/framework-options.js.map +1 -1
  43. package/dist/esm/core/code-splitter/path-ids.js +27 -33
  44. package/dist/esm/core/code-splitter/path-ids.js.map +1 -1
  45. package/dist/esm/core/code-splitter/plugins/framework-plugins.js +11 -14
  46. package/dist/esm/core/code-splitter/plugins/framework-plugins.js.map +1 -1
  47. package/dist/esm/core/code-splitter/plugins/react-refresh-route-components.js +29 -48
  48. package/dist/esm/core/code-splitter/plugins/react-refresh-route-components.js.map +1 -1
  49. package/dist/esm/core/config.js +35 -48
  50. package/dist/esm/core/config.js.map +1 -1
  51. package/dist/esm/core/constants.js +17 -19
  52. package/dist/esm/core/constants.js.map +1 -1
  53. package/dist/esm/core/route-autoimport-plugin.js +78 -98
  54. package/dist/esm/core/route-autoimport-plugin.js.map +1 -1
  55. package/dist/esm/core/route-hmr-statement.js +32 -39
  56. package/dist/esm/core/route-hmr-statement.js.map +1 -1
  57. package/dist/esm/core/router-code-splitter-plugin.js +234 -305
  58. package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
  59. package/dist/esm/core/router-composed-plugin.js +25 -32
  60. package/dist/esm/core/router-composed-plugin.js.map +1 -1
  61. package/dist/esm/core/router-generator-plugin.js +100 -111
  62. package/dist/esm/core/router-generator-plugin.js.map +1 -1
  63. package/dist/esm/core/router-hmr-plugin.js +79 -80
  64. package/dist/esm/core/router-hmr-plugin.js.map +1 -1
  65. package/dist/esm/core/utils.js +21 -15
  66. package/dist/esm/core/utils.js.map +1 -1
  67. package/dist/esm/esbuild.js +37 -18
  68. package/dist/esm/esbuild.js.map +1 -1
  69. package/dist/esm/index.js +2 -11
  70. package/dist/esm/rspack.js +49 -20
  71. package/dist/esm/rspack.js.map +1 -1
  72. package/dist/esm/vite.js +42 -21
  73. package/dist/esm/vite.js.map +1 -1
  74. package/dist/esm/webpack.js +37 -20
  75. package/dist/esm/webpack.js.map +1 -1
  76. package/package.json +6 -6
  77. package/src/core/code-splitter/compilers.ts +1 -1
  78. package/src/core/route-autoimport-plugin.ts +1 -1
  79. package/dist/cjs/index.cjs.map +0 -1
  80. package/dist/esm/index.js.map +0 -1
@@ -1,37 +1,31 @@
1
+ //#region src/core/code-splitter/path-ids.ts
1
2
  function createIdentifier(strings) {
2
- if (strings.length === 0) {
3
- throw new Error("Cannot create an identifier from an empty array");
4
- }
5
- const sortedStrings = [...strings].sort();
6
- const combinedString = sortedStrings.join("---");
7
- let safeString = combinedString.replace(/\//g, "--slash--");
8
- safeString = safeString.replace(/\\/g, "--backslash--");
9
- safeString = safeString.replace(/\?/g, "--question--");
10
- safeString = safeString.replace(/%/g, "--percent--");
11
- safeString = safeString.replace(/#/g, "--hash--");
12
- safeString = safeString.replace(/\+/g, "--plus--");
13
- safeString = safeString.replace(/=/g, "--equals--");
14
- safeString = safeString.replace(/&/g, "--ampersand--");
15
- safeString = safeString.replace(/\s/g, "_");
16
- return safeString;
3
+ if (strings.length === 0) throw new Error("Cannot create an identifier from an empty array");
4
+ let safeString = [...strings].sort().join("---").replace(/\//g, "--slash--");
5
+ safeString = safeString.replace(/\\/g, "--backslash--");
6
+ safeString = safeString.replace(/\?/g, "--question--");
7
+ safeString = safeString.replace(/%/g, "--percent--");
8
+ safeString = safeString.replace(/#/g, "--hash--");
9
+ safeString = safeString.replace(/\+/g, "--plus--");
10
+ safeString = safeString.replace(/=/g, "--equals--");
11
+ safeString = safeString.replace(/&/g, "--ampersand--");
12
+ safeString = safeString.replace(/\s/g, "_");
13
+ return safeString;
17
14
  }
18
15
  function decodeIdentifier(identifier) {
19
- if (!identifier) {
20
- return [];
21
- }
22
- let combinedString = identifier.replace(/--slash--/g, "/");
23
- combinedString = combinedString.replace(/--backslash--/g, "\\");
24
- combinedString = combinedString.replace(/--question--/g, "?");
25
- combinedString = combinedString.replace(/--percent--/g, "%");
26
- combinedString = combinedString.replace(/--hash--/g, "#");
27
- combinedString = combinedString.replace(/--plus--/g, "+");
28
- combinedString = combinedString.replace(/--equals--/g, "=");
29
- combinedString = combinedString.replace(/--ampersand--/g, "&");
30
- combinedString = combinedString.replace(/_/g, " ");
31
- return combinedString.split("---");
16
+ if (!identifier) return [];
17
+ let combinedString = identifier.replace(/--slash--/g, "/");
18
+ combinedString = combinedString.replace(/--backslash--/g, "\\");
19
+ combinedString = combinedString.replace(/--question--/g, "?");
20
+ combinedString = combinedString.replace(/--percent--/g, "%");
21
+ combinedString = combinedString.replace(/--hash--/g, "#");
22
+ combinedString = combinedString.replace(/--plus--/g, "+");
23
+ combinedString = combinedString.replace(/--equals--/g, "=");
24
+ combinedString = combinedString.replace(/--ampersand--/g, "&");
25
+ combinedString = combinedString.replace(/_/g, " ");
26
+ return combinedString.split("---");
32
27
  }
33
- export {
34
- createIdentifier,
35
- decodeIdentifier
36
- };
37
- //# sourceMappingURL=path-ids.js.map
28
+ //#endregion
29
+ export { createIdentifier, decodeIdentifier };
30
+
31
+ //# sourceMappingURL=path-ids.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-ids.js","sources":["../../../../src/core/code-splitter/path-ids.ts"],"sourcesContent":["export function createIdentifier(strings: Array<string>): string {\n if (strings.length === 0) {\n throw new Error('Cannot create an identifier from an empty array')\n }\n\n const sortedStrings = [...strings].sort()\n const combinedString = sortedStrings.join('---') // Delimiter\n\n // Replace unsafe characters\n let safeString = combinedString.replace(/\\//g, '--slash--')\n safeString = safeString.replace(/\\\\/g, '--backslash--')\n safeString = safeString.replace(/\\?/g, '--question--')\n safeString = safeString.replace(/%/g, '--percent--')\n safeString = safeString.replace(/#/g, '--hash--')\n safeString = safeString.replace(/\\+/g, '--plus--')\n safeString = safeString.replace(/=/g, '--equals--')\n safeString = safeString.replace(/&/g, '--ampersand--')\n safeString = safeString.replace(/\\s/g, '_') // Replace spaces with underscores\n\n return safeString\n}\n\nexport function decodeIdentifier(identifier: string): Array<string> {\n if (!identifier) {\n return []\n }\n\n let combinedString = identifier.replace(/--slash--/g, '/')\n combinedString = combinedString.replace(/--backslash--/g, '\\\\')\n combinedString = combinedString.replace(/--question--/g, '?')\n combinedString = combinedString.replace(/--percent--/g, '%')\n combinedString = combinedString.replace(/--hash--/g, '#')\n combinedString = combinedString.replace(/--plus--/g, '+')\n combinedString = combinedString.replace(/--equals--/g, '=')\n combinedString = combinedString.replace(/--ampersand--/g, '&')\n combinedString = combinedString.replace(/_/g, ' ') // Restore spaces\n\n return combinedString.split('---')\n}\n"],"names":[],"mappings":"AAAO,SAAS,iBAAiB,SAAgC;AAC/D,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,MAAM,iDAAiD;AAAA,EACnE;AAEA,QAAM,gBAAgB,CAAC,GAAG,OAAO,EAAE,KAAA;AACnC,QAAM,iBAAiB,cAAc,KAAK,KAAK;AAG/C,MAAI,aAAa,eAAe,QAAQ,OAAO,WAAW;AAC1D,eAAa,WAAW,QAAQ,OAAO,eAAe;AACtD,eAAa,WAAW,QAAQ,OAAO,cAAc;AACrD,eAAa,WAAW,QAAQ,MAAM,aAAa;AACnD,eAAa,WAAW,QAAQ,MAAM,UAAU;AAChD,eAAa,WAAW,QAAQ,OAAO,UAAU;AACjD,eAAa,WAAW,QAAQ,MAAM,YAAY;AAClD,eAAa,WAAW,QAAQ,MAAM,eAAe;AACrD,eAAa,WAAW,QAAQ,OAAO,GAAG;AAE1C,SAAO;AACT;AAEO,SAAS,iBAAiB,YAAmC;AAClE,MAAI,CAAC,YAAY;AACf,WAAO,CAAA;AAAA,EACT;AAEA,MAAI,iBAAiB,WAAW,QAAQ,cAAc,GAAG;AACzD,mBAAiB,eAAe,QAAQ,kBAAkB,IAAI;AAC9D,mBAAiB,eAAe,QAAQ,iBAAiB,GAAG;AAC5D,mBAAiB,eAAe,QAAQ,gBAAgB,GAAG;AAC3D,mBAAiB,eAAe,QAAQ,aAAa,GAAG;AACxD,mBAAiB,eAAe,QAAQ,aAAa,GAAG;AACxD,mBAAiB,eAAe,QAAQ,eAAe,GAAG;AAC1D,mBAAiB,eAAe,QAAQ,kBAAkB,GAAG;AAC7D,mBAAiB,eAAe,QAAQ,MAAM,GAAG;AAEjD,SAAO,eAAe,MAAM,KAAK;AACnC;"}
1
+ {"version":3,"file":"path-ids.js","names":[],"sources":["../../../../src/core/code-splitter/path-ids.ts"],"sourcesContent":["export function createIdentifier(strings: Array<string>): string {\n if (strings.length === 0) {\n throw new Error('Cannot create an identifier from an empty array')\n }\n\n const sortedStrings = [...strings].sort()\n const combinedString = sortedStrings.join('---') // Delimiter\n\n // Replace unsafe characters\n let safeString = combinedString.replace(/\\//g, '--slash--')\n safeString = safeString.replace(/\\\\/g, '--backslash--')\n safeString = safeString.replace(/\\?/g, '--question--')\n safeString = safeString.replace(/%/g, '--percent--')\n safeString = safeString.replace(/#/g, '--hash--')\n safeString = safeString.replace(/\\+/g, '--plus--')\n safeString = safeString.replace(/=/g, '--equals--')\n safeString = safeString.replace(/&/g, '--ampersand--')\n safeString = safeString.replace(/\\s/g, '_') // Replace spaces with underscores\n\n return safeString\n}\n\nexport function decodeIdentifier(identifier: string): Array<string> {\n if (!identifier) {\n return []\n }\n\n let combinedString = identifier.replace(/--slash--/g, '/')\n combinedString = combinedString.replace(/--backslash--/g, '\\\\')\n combinedString = combinedString.replace(/--question--/g, '?')\n combinedString = combinedString.replace(/--percent--/g, '%')\n combinedString = combinedString.replace(/--hash--/g, '#')\n combinedString = combinedString.replace(/--plus--/g, '+')\n combinedString = combinedString.replace(/--equals--/g, '=')\n combinedString = combinedString.replace(/--ampersand--/g, '&')\n combinedString = combinedString.replace(/_/g, ' ') // Restore spaces\n\n return combinedString.split('---')\n}\n"],"mappings":";AAAA,SAAgB,iBAAiB,SAAgC;AAC/D,KAAI,QAAQ,WAAW,EACrB,OAAM,IAAI,MAAM,kDAAkD;CAOpE,IAAI,aAJkB,CAAC,GAAG,QAAQ,CAAC,MAAM,CACJ,KAAK,MAAM,CAGhB,QAAQ,OAAO,YAAY;AAC3D,cAAa,WAAW,QAAQ,OAAO,gBAAgB;AACvD,cAAa,WAAW,QAAQ,OAAO,eAAe;AACtD,cAAa,WAAW,QAAQ,MAAM,cAAc;AACpD,cAAa,WAAW,QAAQ,MAAM,WAAW;AACjD,cAAa,WAAW,QAAQ,OAAO,WAAW;AAClD,cAAa,WAAW,QAAQ,MAAM,aAAa;AACnD,cAAa,WAAW,QAAQ,MAAM,gBAAgB;AACtD,cAAa,WAAW,QAAQ,OAAO,IAAI;AAE3C,QAAO;;AAGT,SAAgB,iBAAiB,YAAmC;AAClE,KAAI,CAAC,WACH,QAAO,EAAE;CAGX,IAAI,iBAAiB,WAAW,QAAQ,cAAc,IAAI;AAC1D,kBAAiB,eAAe,QAAQ,kBAAkB,KAAK;AAC/D,kBAAiB,eAAe,QAAQ,iBAAiB,IAAI;AAC7D,kBAAiB,eAAe,QAAQ,gBAAgB,IAAI;AAC5D,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,aAAa,IAAI;AACzD,kBAAiB,eAAe,QAAQ,eAAe,IAAI;AAC3D,kBAAiB,eAAe,QAAQ,kBAAkB,IAAI;AAC9D,kBAAiB,eAAe,QAAQ,MAAM,IAAI;AAElD,QAAO,eAAe,MAAM,MAAM"}
@@ -1,17 +1,14 @@
1
1
  import { createReactRefreshRouteComponentsPlugin } from "./react-refresh-route-components.js";
2
+ //#region src/core/code-splitter/plugins/framework-plugins.ts
2
3
  function getReferenceRouteCompilerPlugins(opts) {
3
- switch (opts.targetFramework) {
4
- case "react": {
5
- if (opts.addHmr) {
6
- return [createReactRefreshRouteComponentsPlugin()];
7
- }
8
- return void 0;
9
- }
10
- default:
11
- return void 0;
12
- }
4
+ switch (opts.targetFramework) {
5
+ case "react":
6
+ if (opts.addHmr) return [createReactRefreshRouteComponentsPlugin()];
7
+ return;
8
+ default: return;
9
+ }
13
10
  }
14
- export {
15
- getReferenceRouteCompilerPlugins
16
- };
17
- //# sourceMappingURL=framework-plugins.js.map
11
+ //#endregion
12
+ export { getReferenceRouteCompilerPlugins };
13
+
14
+ //# sourceMappingURL=framework-plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"framework-plugins.js","sources":["../../../../../src/core/code-splitter/plugins/framework-plugins.ts"],"sourcesContent":["import { createReactRefreshRouteComponentsPlugin } from './react-refresh-route-components'\nimport type { ReferenceRouteCompilerPlugin } from '../plugins'\nimport type { Config } from '../../config'\n\nexport function getReferenceRouteCompilerPlugins(opts: {\n targetFramework: Config['target']\n addHmr?: boolean\n}): Array<ReferenceRouteCompilerPlugin> | undefined {\n switch (opts.targetFramework) {\n case 'react': {\n if (opts.addHmr) {\n return [createReactRefreshRouteComponentsPlugin()]\n }\n return undefined\n }\n default:\n return undefined\n }\n}\n"],"names":[],"mappings":";AAIO,SAAS,iCAAiC,MAGG;AAClD,UAAQ,KAAK,iBAAA;AAAA,IACX,KAAK,SAAS;AACZ,UAAI,KAAK,QAAQ;AACf,eAAO,CAAC,yCAAyC;AAAA,MACnD;AACA,aAAO;AAAA,IACT;AAAA,IACA;AACE,aAAO;AAAA,EAAA;AAEb;"}
1
+ {"version":3,"file":"framework-plugins.js","names":[],"sources":["../../../../../src/core/code-splitter/plugins/framework-plugins.ts"],"sourcesContent":["import { createReactRefreshRouteComponentsPlugin } from './react-refresh-route-components'\nimport type { ReferenceRouteCompilerPlugin } from '../plugins'\nimport type { Config } from '../../config'\n\nexport function getReferenceRouteCompilerPlugins(opts: {\n targetFramework: Config['target']\n addHmr?: boolean\n}): Array<ReferenceRouteCompilerPlugin> | undefined {\n switch (opts.targetFramework) {\n case 'react': {\n if (opts.addHmr) {\n return [createReactRefreshRouteComponentsPlugin()]\n }\n return undefined\n }\n default:\n return undefined\n }\n}\n"],"mappings":";;AAIA,SAAgB,iCAAiC,MAGG;AAClD,SAAQ,KAAK,iBAAb;EACE,KAAK;AACH,OAAI,KAAK,OACP,QAAO,CAAC,yCAAyC,CAAC;AAEpD;EAEF,QACE"}
@@ -1,52 +1,33 @@
1
- import * as t from "@babel/types";
2
1
  import { getUniqueProgramIdentifier } from "../../utils.js";
3
- const REACT_REFRESH_ROUTE_COMPONENT_IDENTS = /* @__PURE__ */ new Set([
4
- "component",
5
- "pendingComponent",
6
- "errorComponent",
7
- "notFoundComponent"
2
+ import * as t from "@babel/types";
3
+ //#region src/core/code-splitter/plugins/react-refresh-route-components.ts
4
+ var REACT_REFRESH_ROUTE_COMPONENT_IDENTS = new Set([
5
+ "component",
6
+ "pendingComponent",
7
+ "errorComponent",
8
+ "notFoundComponent"
8
9
  ]);
9
10
  function createReactRefreshRouteComponentsPlugin() {
10
- return {
11
- name: "react-refresh-route-components",
12
- onUnsplittableRoute(ctx) {
13
- if (!ctx.opts.addHmr) {
14
- return;
15
- }
16
- const hoistedDeclarations = [];
17
- ctx.routeOptions.properties.forEach((prop) => {
18
- if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) {
19
- return;
20
- }
21
- if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) {
22
- return;
23
- }
24
- if (!t.isArrowFunctionExpression(prop.value) && !t.isFunctionExpression(prop.value)) {
25
- return;
26
- }
27
- const hoistedIdentifier = getUniqueProgramIdentifier(
28
- ctx.programPath,
29
- `TSR${prop.key.name[0].toUpperCase()}${prop.key.name.slice(1)}`
30
- );
31
- hoistedDeclarations.push(
32
- t.variableDeclaration("const", [
33
- t.variableDeclarator(
34
- hoistedIdentifier,
35
- t.cloneNode(prop.value, true)
36
- )
37
- ])
38
- );
39
- prop.value = t.cloneNode(hoistedIdentifier);
40
- });
41
- if (hoistedDeclarations.length === 0) {
42
- return;
43
- }
44
- ctx.insertionPath.insertBefore(hoistedDeclarations);
45
- return { modified: true };
46
- }
47
- };
11
+ return {
12
+ name: "react-refresh-route-components",
13
+ onUnsplittableRoute(ctx) {
14
+ if (!ctx.opts.addHmr) return;
15
+ const hoistedDeclarations = [];
16
+ ctx.routeOptions.properties.forEach((prop) => {
17
+ if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) return;
18
+ if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) return;
19
+ if (!t.isArrowFunctionExpression(prop.value) && !t.isFunctionExpression(prop.value)) return;
20
+ const hoistedIdentifier = getUniqueProgramIdentifier(ctx.programPath, `TSR${prop.key.name[0].toUpperCase()}${prop.key.name.slice(1)}`);
21
+ hoistedDeclarations.push(t.variableDeclaration("const", [t.variableDeclarator(hoistedIdentifier, t.cloneNode(prop.value, true))]));
22
+ prop.value = t.cloneNode(hoistedIdentifier);
23
+ });
24
+ if (hoistedDeclarations.length === 0) return;
25
+ ctx.insertionPath.insertBefore(hoistedDeclarations);
26
+ return { modified: true };
27
+ }
28
+ };
48
29
  }
49
- export {
50
- createReactRefreshRouteComponentsPlugin
51
- };
52
- //# sourceMappingURL=react-refresh-route-components.js.map
30
+ //#endregion
31
+ export { createReactRefreshRouteComponentsPlugin };
32
+
33
+ //# sourceMappingURL=react-refresh-route-components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-refresh-route-components.js","sources":["../../../../../src/core/code-splitter/plugins/react-refresh-route-components.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport { getUniqueProgramIdentifier } from '../../utils'\nimport type { ReferenceRouteCompilerPlugin } from '../plugins'\n\nconst REACT_REFRESH_ROUTE_COMPONENT_IDENTS = new Set([\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n])\n\nexport function createReactRefreshRouteComponentsPlugin(): ReferenceRouteCompilerPlugin {\n return {\n name: 'react-refresh-route-components',\n onUnsplittableRoute(ctx) {\n if (!ctx.opts.addHmr) {\n return\n }\n\n const hoistedDeclarations: Array<t.VariableDeclaration> = []\n\n ctx.routeOptions.properties.forEach((prop) => {\n if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) {\n return\n }\n\n if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) {\n return\n }\n\n if (\n !t.isArrowFunctionExpression(prop.value) &&\n !t.isFunctionExpression(prop.value)\n ) {\n return\n }\n\n const hoistedIdentifier = getUniqueProgramIdentifier(\n ctx.programPath,\n `TSR${prop.key.name[0]!.toUpperCase()}${prop.key.name.slice(1)}`,\n )\n\n hoistedDeclarations.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n hoistedIdentifier,\n t.cloneNode(prop.value, true),\n ),\n ]),\n )\n\n prop.value = t.cloneNode(hoistedIdentifier)\n })\n\n if (hoistedDeclarations.length === 0) {\n return\n }\n\n ctx.insertionPath.insertBefore(hoistedDeclarations)\n return { modified: true }\n },\n }\n}\n"],"names":[],"mappings":";;AAIA,MAAM,2DAA2C,IAAI;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,SAAS,0CAAwE;AACtF,SAAO;AAAA,IACL,MAAM;AAAA,IACN,oBAAoB,KAAK;AACvB,UAAI,CAAC,IAAI,KAAK,QAAQ;AACpB;AAAA,MACF;AAEA,YAAM,sBAAoD,CAAA;AAE1D,UAAI,aAAa,WAAW,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAAC,EAAE,iBAAiB,IAAI,KAAK,CAAC,EAAE,aAAa,KAAK,GAAG,GAAG;AAC1D;AAAA,QACF;AAEA,YAAI,CAAC,qCAAqC,IAAI,KAAK,IAAI,IAAI,GAAG;AAC5D;AAAA,QACF;AAEA,YACE,CAAC,EAAE,0BAA0B,KAAK,KAAK,KACvC,CAAC,EAAE,qBAAqB,KAAK,KAAK,GAClC;AACA;AAAA,QACF;AAEA,cAAM,oBAAoB;AAAA,UACxB,IAAI;AAAA,UACJ,MAAM,KAAK,IAAI,KAAK,CAAC,EAAG,aAAa,GAAG,KAAK,IAAI,KAAK,MAAM,CAAC,CAAC;AAAA,QAAA;AAGhE,4BAAoB;AAAA,UAClB,EAAE,oBAAoB,SAAS;AAAA,YAC7B,EAAE;AAAA,cACA;AAAA,cACA,EAAE,UAAU,KAAK,OAAO,IAAI;AAAA,YAAA;AAAA,UAC9B,CACD;AAAA,QAAA;AAGH,aAAK,QAAQ,EAAE,UAAU,iBAAiB;AAAA,MAC5C,CAAC;AAED,UAAI,oBAAoB,WAAW,GAAG;AACpC;AAAA,MACF;AAEA,UAAI,cAAc,aAAa,mBAAmB;AAClD,aAAO,EAAE,UAAU,KAAA;AAAA,IACrB;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"react-refresh-route-components.js","names":[],"sources":["../../../../../src/core/code-splitter/plugins/react-refresh-route-components.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport { getUniqueProgramIdentifier } from '../../utils'\nimport type { ReferenceRouteCompilerPlugin } from '../plugins'\n\nconst REACT_REFRESH_ROUTE_COMPONENT_IDENTS = new Set([\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n])\n\nexport function createReactRefreshRouteComponentsPlugin(): ReferenceRouteCompilerPlugin {\n return {\n name: 'react-refresh-route-components',\n onUnsplittableRoute(ctx) {\n if (!ctx.opts.addHmr) {\n return\n }\n\n const hoistedDeclarations: Array<t.VariableDeclaration> = []\n\n ctx.routeOptions.properties.forEach((prop) => {\n if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) {\n return\n }\n\n if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) {\n return\n }\n\n if (\n !t.isArrowFunctionExpression(prop.value) &&\n !t.isFunctionExpression(prop.value)\n ) {\n return\n }\n\n const hoistedIdentifier = getUniqueProgramIdentifier(\n ctx.programPath,\n `TSR${prop.key.name[0]!.toUpperCase()}${prop.key.name.slice(1)}`,\n )\n\n hoistedDeclarations.push(\n t.variableDeclaration('const', [\n t.variableDeclarator(\n hoistedIdentifier,\n t.cloneNode(prop.value, true),\n ),\n ]),\n )\n\n prop.value = t.cloneNode(hoistedIdentifier)\n })\n\n if (hoistedDeclarations.length === 0) {\n return\n }\n\n ctx.insertionPath.insertBefore(hoistedDeclarations)\n return { modified: true }\n },\n }\n}\n"],"mappings":";;;AAIA,IAAM,uCAAuC,IAAI,IAAI;CACnD;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,0CAAwE;AACtF,QAAO;EACL,MAAM;EACN,oBAAoB,KAAK;AACvB,OAAI,CAAC,IAAI,KAAK,OACZ;GAGF,MAAM,sBAAoD,EAAE;AAE5D,OAAI,aAAa,WAAW,SAAS,SAAS;AAC5C,QAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAC,EAAE,aAAa,KAAK,IAAI,CACxD;AAGF,QAAI,CAAC,qCAAqC,IAAI,KAAK,IAAI,KAAK,CAC1D;AAGF,QACE,CAAC,EAAE,0BAA0B,KAAK,MAAM,IACxC,CAAC,EAAE,qBAAqB,KAAK,MAAM,CAEnC;IAGF,MAAM,oBAAoB,2BACxB,IAAI,aACJ,MAAM,KAAK,IAAI,KAAK,GAAI,aAAa,GAAG,KAAK,IAAI,KAAK,MAAM,EAAE,GAC/D;AAED,wBAAoB,KAClB,EAAE,oBAAoB,SAAS,CAC7B,EAAE,mBACA,mBACA,EAAE,UAAU,KAAK,OAAO,KAAK,CAC9B,CACF,CAAC,CACH;AAED,SAAK,QAAQ,EAAE,UAAU,kBAAkB;KAC3C;AAEF,OAAI,oBAAoB,WAAW,EACjC;AAGF,OAAI,cAAc,aAAa,oBAAoB;AACnD,UAAO,EAAE,UAAU,MAAM;;EAE5B"}
@@ -1,53 +1,40 @@
1
1
  import { z } from "zod";
2
- import { getConfig as getConfig$1, configSchema as configSchema$1 } from "@tanstack/router-generator";
3
- const splitGroupingsSchema = z.array(
4
- z.array(
5
- z.union([
6
- z.literal("loader"),
7
- z.literal("component"),
8
- z.literal("pendingComponent"),
9
- z.literal("errorComponent"),
10
- z.literal("notFoundComponent")
11
- ])
12
- ),
13
- {
14
- message: " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]"
15
- }
16
- ).superRefine((val, ctx) => {
17
- const flattened = val.flat();
18
- const unique = [...new Set(flattened)];
19
- if (unique.length !== flattened.length) {
20
- ctx.addIssue({
21
- code: "custom",
22
- message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].
23
- You input was: ${JSON.stringify(val)}.`
24
- });
25
- }
2
+ import { configSchema, getConfig } from "@tanstack/router-generator";
3
+ //#region src/core/config.ts
4
+ var splitGroupingsSchema = z.array(z.array(z.union([
5
+ z.literal("loader"),
6
+ z.literal("component"),
7
+ z.literal("pendingComponent"),
8
+ z.literal("errorComponent"),
9
+ z.literal("notFoundComponent")
10
+ ])), { message: " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]" }).superRefine((val, ctx) => {
11
+ const flattened = val.flat();
12
+ if ([...new Set(flattened)].length !== flattened.length) ctx.addIssue({
13
+ code: "custom",
14
+ message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].\n You input was: ${JSON.stringify(val)}.`
15
+ });
26
16
  });
27
- const codeSplittingOptionsSchema = z.object({
28
- splitBehavior: z.function().optional(),
29
- defaultBehavior: splitGroupingsSchema.optional(),
30
- deleteNodes: z.array(z.string()).optional(),
31
- addHmr: z.boolean().optional().default(true)
17
+ var codeSplittingOptionsSchema = z.object({
18
+ splitBehavior: z.function().optional(),
19
+ defaultBehavior: splitGroupingsSchema.optional(),
20
+ deleteNodes: z.array(z.string()).optional(),
21
+ addHmr: z.boolean().optional().default(true)
32
22
  });
33
- const configSchema = configSchema$1.extend({
34
- enableRouteGeneration: z.boolean().optional(),
35
- codeSplittingOptions: z.custom((v) => {
36
- return codeSplittingOptionsSchema.parse(v);
37
- }).optional(),
38
- plugin: z.object({
39
- vite: z.object({
40
- environmentName: z.string().optional()
41
- }).optional()
42
- }).optional()
23
+ var configSchema$1 = configSchema.extend({
24
+ enableRouteGeneration: z.boolean().optional(),
25
+ codeSplittingOptions: z.custom((v) => {
26
+ return codeSplittingOptionsSchema.parse(v);
27
+ }).optional(),
28
+ plugin: z.object({ vite: z.object({ environmentName: z.string().optional() }).optional() }).optional()
43
29
  });
44
- const getConfig = (inlineConfig, root) => {
45
- const config = getConfig$1(inlineConfig, root);
46
- return configSchema.parse({ ...inlineConfig, ...config });
30
+ var getConfig$1 = (inlineConfig, root) => {
31
+ const config = getConfig(inlineConfig, root);
32
+ return configSchema$1.parse({
33
+ ...inlineConfig,
34
+ ...config
35
+ });
47
36
  };
48
- export {
49
- configSchema,
50
- getConfig,
51
- splitGroupingsSchema
52
- };
53
- //# sourceMappingURL=config.js.map
37
+ //#endregion
38
+ export { configSchema$1 as configSchema, getConfig$1 as getConfig, splitGroupingsSchema };
39
+
40
+ //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/core/config.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n configSchema as generatorConfigSchema,\n getConfig as getGeneratorConfig,\n} from '@tanstack/router-generator'\nimport type {\n CreateFileRoute,\n RegisteredRouter,\n RouteIds,\n} from '@tanstack/router-core'\nimport type { CodeSplitGroupings } from './constants'\n\nexport const splitGroupingsSchema = z\n .array(\n z.array(\n z.union([\n z.literal('loader'),\n z.literal('component'),\n z.literal('pendingComponent'),\n z.literal('errorComponent'),\n z.literal('notFoundComponent'),\n ]),\n ),\n {\n message:\n \" Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]\",\n },\n )\n .superRefine((val, ctx) => {\n const flattened = val.flat()\n const unique = [...new Set(flattened)]\n\n // Elements must be unique,\n // ie. this shouldn't be allows [['component'], ['component', 'loader']]\n if (unique.length !== flattened.length) {\n ctx.addIssue({\n code: 'custom',\n message:\n \" Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].\" +\n `\\n You input was: ${JSON.stringify(val)}.`,\n })\n }\n })\n\nexport type CodeSplittingOptions = {\n /**\n * Use this function to programmatically control the code splitting behavior\n * based on the `routeId` for each route.\n *\n * If you just need to change the default behavior, you can use the `defaultBehavior` option.\n * @param params\n */\n splitBehavior?: (params: {\n routeId: RouteIds<RegisteredRouter['routeTree']>\n }) => CodeSplitGroupings | undefined | void\n\n /**\n * The default/global configuration to control your code splitting behavior per route.\n * @default [['component'],['pendingComponent'],['errorComponent'],['notFoundComponent']]\n */\n defaultBehavior?: CodeSplitGroupings\n\n /**\n * The nodes that shall be deleted from the route.\n * @default undefined\n */\n deleteNodes?: Array<DeletableNodes>\n\n /**\n * @default true\n */\n addHmr?: boolean\n}\n\nconst codeSplittingOptionsSchema = z.object({\n splitBehavior: z.function().optional(),\n defaultBehavior: splitGroupingsSchema.optional(),\n deleteNodes: z.array(z.string()).optional(),\n addHmr: z.boolean().optional().default(true),\n})\n\ntype FileRouteKeys = keyof (Parameters<\n CreateFileRoute<any, any, any, any, any>\n>[0] & {})\nexport type DeletableNodes = FileRouteKeys | (string & {})\n\nexport const configSchema = generatorConfigSchema.extend({\n enableRouteGeneration: z.boolean().optional(),\n codeSplittingOptions: z\n .custom<CodeSplittingOptions>((v) => {\n return codeSplittingOptionsSchema.parse(v)\n })\n .optional(),\n plugin: z\n .object({\n vite: z\n .object({\n environmentName: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n})\n\nexport const getConfig = (inlineConfig: Partial<Config>, root: string) => {\n const config = getGeneratorConfig(inlineConfig, root)\n\n return configSchema.parse({ ...inlineConfig, ...config })\n}\n\nexport type Config = z.infer<typeof configSchema>\nexport type ConfigInput = z.input<typeof configSchema>\nexport type ConfigOutput = z.output<typeof configSchema>\n"],"names":["generatorConfigSchema","getGeneratorConfig"],"mappings":";;AAYO,MAAM,uBAAuB,EACjC;AAAA,EACC,EAAE;AAAA,IACA,EAAE,MAAM;AAAA,MACN,EAAE,QAAQ,QAAQ;AAAA,MAClB,EAAE,QAAQ,WAAW;AAAA,MACrB,EAAE,QAAQ,kBAAkB;AAAA,MAC5B,EAAE,QAAQ,gBAAgB;AAAA,MAC1B,EAAE,QAAQ,mBAAmB;AAAA,IAAA,CAC9B;AAAA,EAAA;AAAA,EAEH;AAAA,IACE,SACE;AAAA,EAAA;AAEN,EACC,YAAY,CAAC,KAAK,QAAQ;AACzB,QAAM,YAAY,IAAI,KAAA;AACtB,QAAM,SAAS,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC;AAIrC,MAAI,OAAO,WAAW,UAAU,QAAQ;AACtC,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,SACE;AAAA,mBACsB,KAAK,UAAU,GAAG,CAAC;AAAA,IAAA,CAC5C;AAAA,EACH;AACF,CAAC;AAgCH,MAAM,6BAA6B,EAAE,OAAO;AAAA,EAC1C,eAAe,EAAE,SAAA,EAAW,SAAA;AAAA,EAC5B,iBAAiB,qBAAqB,SAAA;AAAA,EACtC,aAAa,EAAE,MAAM,EAAE,OAAA,CAAQ,EAAE,SAAA;AAAA,EACjC,QAAQ,EAAE,QAAA,EAAU,SAAA,EAAW,QAAQ,IAAI;AAC7C,CAAC;AAOM,MAAM,eAAeA,eAAsB,OAAO;AAAA,EACvD,uBAAuB,EAAE,QAAA,EAAU,SAAA;AAAA,EACnC,sBAAsB,EACnB,OAA6B,CAAC,MAAM;AACnC,WAAO,2BAA2B,MAAM,CAAC;AAAA,EAC3C,CAAC,EACA,SAAA;AAAA,EACH,QAAQ,EACL,OAAO;AAAA,IACN,MAAM,EACH,OAAO;AAAA,MACN,iBAAiB,EAAE,OAAA,EAAS,SAAA;AAAA,IAAS,CACtC,EACA,SAAA;AAAA,EAAS,CACb,EACA,SAAA;AACL,CAAC;AAEM,MAAM,YAAY,CAAC,cAA+B,SAAiB;AACxE,QAAM,SAASC,YAAmB,cAAc,IAAI;AAEpD,SAAO,aAAa,MAAM,EAAE,GAAG,cAAc,GAAG,QAAQ;AAC1D;"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../../src/core/config.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n configSchema as generatorConfigSchema,\n getConfig as getGeneratorConfig,\n} from '@tanstack/router-generator'\nimport type {\n CreateFileRoute,\n RegisteredRouter,\n RouteIds,\n} from '@tanstack/router-core'\nimport type { CodeSplitGroupings } from './constants'\n\nexport const splitGroupingsSchema = z\n .array(\n z.array(\n z.union([\n z.literal('loader'),\n z.literal('component'),\n z.literal('pendingComponent'),\n z.literal('errorComponent'),\n z.literal('notFoundComponent'),\n ]),\n ),\n {\n message:\n \" Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]\",\n },\n )\n .superRefine((val, ctx) => {\n const flattened = val.flat()\n const unique = [...new Set(flattened)]\n\n // Elements must be unique,\n // ie. this shouldn't be allows [['component'], ['component', 'loader']]\n if (unique.length !== flattened.length) {\n ctx.addIssue({\n code: 'custom',\n message:\n \" Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].\" +\n `\\n You input was: ${JSON.stringify(val)}.`,\n })\n }\n })\n\nexport type CodeSplittingOptions = {\n /**\n * Use this function to programmatically control the code splitting behavior\n * based on the `routeId` for each route.\n *\n * If you just need to change the default behavior, you can use the `defaultBehavior` option.\n * @param params\n */\n splitBehavior?: (params: {\n routeId: RouteIds<RegisteredRouter['routeTree']>\n }) => CodeSplitGroupings | undefined | void\n\n /**\n * The default/global configuration to control your code splitting behavior per route.\n * @default [['component'],['pendingComponent'],['errorComponent'],['notFoundComponent']]\n */\n defaultBehavior?: CodeSplitGroupings\n\n /**\n * The nodes that shall be deleted from the route.\n * @default undefined\n */\n deleteNodes?: Array<DeletableNodes>\n\n /**\n * @default true\n */\n addHmr?: boolean\n}\n\nconst codeSplittingOptionsSchema = z.object({\n splitBehavior: z.function().optional(),\n defaultBehavior: splitGroupingsSchema.optional(),\n deleteNodes: z.array(z.string()).optional(),\n addHmr: z.boolean().optional().default(true),\n})\n\ntype FileRouteKeys = keyof (Parameters<\n CreateFileRoute<any, any, any, any, any>\n>[0] & {})\nexport type DeletableNodes = FileRouteKeys | (string & {})\n\nexport const configSchema = generatorConfigSchema.extend({\n enableRouteGeneration: z.boolean().optional(),\n codeSplittingOptions: z\n .custom<CodeSplittingOptions>((v) => {\n return codeSplittingOptionsSchema.parse(v)\n })\n .optional(),\n plugin: z\n .object({\n vite: z\n .object({\n environmentName: z.string().optional(),\n })\n .optional(),\n })\n .optional(),\n})\n\nexport const getConfig = (inlineConfig: Partial<Config>, root: string) => {\n const config = getGeneratorConfig(inlineConfig, root)\n\n return configSchema.parse({ ...inlineConfig, ...config })\n}\n\nexport type Config = z.infer<typeof configSchema>\nexport type ConfigInput = z.input<typeof configSchema>\nexport type ConfigOutput = z.output<typeof configSchema>\n"],"mappings":";;;AAYA,IAAa,uBAAuB,EACjC,MACC,EAAE,MACA,EAAE,MAAM;CACN,EAAE,QAAQ,SAAS;CACnB,EAAE,QAAQ,YAAY;CACtB,EAAE,QAAQ,mBAAmB;CAC7B,EAAE,QAAQ,iBAAiB;CAC3B,EAAE,QAAQ,oBAAoB;CAC/B,CAAC,CACH,EACD,EACE,SACE,oJACH,CACF,CACA,aAAa,KAAK,QAAQ;CACzB,MAAM,YAAY,IAAI,MAAM;AAK5B,KAJe,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC,CAI3B,WAAW,UAAU,OAC9B,KAAI,SAAS;EACX,MAAM;EACN,SACE,kKACsB,KAAK,UAAU,IAAI,CAAC;EAC7C,CAAC;EAEJ;AAgCJ,IAAM,6BAA6B,EAAE,OAAO;CAC1C,eAAe,EAAE,UAAU,CAAC,UAAU;CACtC,iBAAiB,qBAAqB,UAAU;CAChD,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAC3C,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,KAAK;CAC7C,CAAC;AAOF,IAAa,iBAAe,aAAsB,OAAO;CACvD,uBAAuB,EAAE,SAAS,CAAC,UAAU;CAC7C,sBAAsB,EACnB,QAA8B,MAAM;AACnC,SAAO,2BAA2B,MAAM,EAAE;GAC1C,CACD,UAAU;CACb,QAAQ,EACL,OAAO,EACN,MAAM,EACH,OAAO,EACN,iBAAiB,EAAE,QAAQ,CAAC,UAAU,EACvC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;CACd,CAAC;AAEF,IAAa,eAAa,cAA+B,SAAiB;CACxE,MAAM,SAAS,UAAmB,cAAc,KAAK;AAErD,QAAO,eAAa,MAAM;EAAE,GAAG;EAAc,GAAG;EAAQ,CAAC"}
@@ -1,21 +1,19 @@
1
- const tsrSplit = "tsr-split";
2
- const tsrShared = "tsr-shared";
3
- const splitRouteIdentNodes = [
4
- "loader",
5
- "component",
6
- "pendingComponent",
7
- "errorComponent",
8
- "notFoundComponent"
1
+ //#region src/core/constants.ts
2
+ var tsrSplit = "tsr-split";
3
+ var tsrShared = "tsr-shared";
4
+ var splitRouteIdentNodes = [
5
+ "loader",
6
+ "component",
7
+ "pendingComponent",
8
+ "errorComponent",
9
+ "notFoundComponent"
9
10
  ];
10
- const defaultCodeSplitGroupings = [
11
- ["component"],
12
- ["errorComponent"],
13
- ["notFoundComponent"]
11
+ var defaultCodeSplitGroupings = [
12
+ ["component"],
13
+ ["errorComponent"],
14
+ ["notFoundComponent"]
14
15
  ];
15
- export {
16
- defaultCodeSplitGroupings,
17
- splitRouteIdentNodes,
18
- tsrShared,
19
- tsrSplit
20
- };
21
- //# sourceMappingURL=constants.js.map
16
+ //#endregion
17
+ export { defaultCodeSplitGroupings, splitRouteIdentNodes, tsrShared, tsrSplit };
18
+
19
+ //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sources":["../../../src/core/constants.ts"],"sourcesContent":["export const tsrSplit = 'tsr-split'\nexport const tsrShared = 'tsr-shared'\n\nexport const splitRouteIdentNodes = [\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n] as const\nexport type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number]\nexport type CodeSplitGroupings = Array<Array<SplitRouteIdentNodes>>\n\nexport const defaultCodeSplitGroupings: CodeSplitGroupings = [\n ['component'],\n ['errorComponent'],\n ['notFoundComponent'],\n]\n"],"names":[],"mappings":"AAAO,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,MAAM,uBAAuB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,4BAAgD;AAAA,EAC3D,CAAC,WAAW;AAAA,EACZ,CAAC,gBAAgB;AAAA,EACjB,CAAC,mBAAmB;AACtB;"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../src/core/constants.ts"],"sourcesContent":["export const tsrSplit = 'tsr-split'\nexport const tsrShared = 'tsr-shared'\n\nexport const splitRouteIdentNodes = [\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n] as const\nexport type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number]\nexport type CodeSplitGroupings = Array<Array<SplitRouteIdentNodes>>\n\nexport const defaultCodeSplitGroupings: CodeSplitGroupings = [\n ['component'],\n ['errorComponent'],\n ['notFoundComponent'],\n]\n"],"mappings":";AAAA,IAAa,WAAW;AACxB,IAAa,YAAY;AAEzB,IAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACD;AAID,IAAa,4BAAgD;CAC3D,CAAC,YAAY;CACb,CAAC,iBAAiB;CAClB,CAAC,oBAAoB;CACtB"}
@@ -1,100 +1,80 @@
1
- import { parseAst, generateFromAst, logDiff } from "@tanstack/router-utils";
2
- import babel from "@babel/core";
3
- import * as template from "@babel/template";
4
1
  import { getConfig } from "./config.js";
5
- import { normalizePath, debug } from "./utils.js";
6
- const unpluginRouteAutoImportFactory = (options = {}) => {
7
- let ROOT = process.cwd();
8
- let userConfig;
9
- function initUserConfig() {
10
- if (typeof options === "function") {
11
- userConfig = options();
12
- } else {
13
- userConfig = getConfig(options, ROOT);
14
- }
15
- }
16
- return {
17
- name: "tanstack-router:autoimport",
18
- enforce: "pre",
19
- transform: {
20
- filter: {
21
- // this is necessary for webpack / rspack to avoid matching .html files
22
- id: /\.(m|c)?(j|t)sx?$/,
23
- code: /createFileRoute\(|createLazyFileRoute\(/
24
- },
25
- handler(code, id) {
26
- const normalizedId = normalizePath(id);
27
- if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) {
28
- return null;
29
- }
30
- let routeType;
31
- if (code.includes("createFileRoute(")) {
32
- routeType = "createFileRoute";
33
- } else if (code.includes("createLazyFileRoute(")) {
34
- routeType = "createLazyFileRoute";
35
- } else {
36
- return null;
37
- }
38
- const routerImportPath = `@tanstack/${userConfig.target}-router`;
39
- const ast = parseAst({ code });
40
- let isCreateRouteFunctionImported = false;
41
- babel.traverse(ast, {
42
- Program: {
43
- enter(programPath) {
44
- programPath.traverse({
45
- ImportDeclaration(path) {
46
- const importedSpecifiers = path.node.specifiers.map(
47
- (specifier) => specifier.local.name
48
- );
49
- if (importedSpecifiers.includes(routeType) && path.node.source.value === routerImportPath) {
50
- isCreateRouteFunctionImported = true;
51
- }
52
- }
53
- });
54
- }
55
- }
56
- });
57
- if (!isCreateRouteFunctionImported) {
58
- if (debug) console.info("Adding autoimports to route ", normalizedId);
59
- const autoImportStatement = template.statement(
60
- `import { ${routeType} } from '${routerImportPath}'`
61
- )();
62
- ast.program.body.unshift(autoImportStatement);
63
- const result = generateFromAst(ast, {
64
- sourceMaps: true,
65
- filename: normalizedId,
66
- sourceFileName: normalizedId
67
- });
68
- if (debug) {
69
- logDiff(code, result.code);
70
- console.log("Output:\n", result.code + "\n\n");
71
- }
72
- return result;
73
- }
74
- return null;
75
- }
76
- },
77
- vite: {
78
- configResolved(config) {
79
- ROOT = config.root;
80
- initUserConfig();
81
- },
82
- // this check may only happen after config is resolved, so we use applyToEnvironment (apply is too early)
83
- applyToEnvironment() {
84
- return userConfig.verboseFileRoutes === false;
85
- }
86
- },
87
- rspack() {
88
- ROOT = process.cwd();
89
- initUserConfig();
90
- },
91
- webpack() {
92
- ROOT = process.cwd();
93
- initUserConfig();
94
- }
95
- };
96
- };
97
- export {
98
- unpluginRouteAutoImportFactory
2
+ import { debug, normalizePath } from "./utils.js";
3
+ import { generateFromAst, logDiff, parseAst } from "@tanstack/router-utils";
4
+ import * as babel from "@babel/core";
5
+ import * as template from "@babel/template";
6
+ //#region src/core/route-autoimport-plugin.ts
7
+ /**
8
+ * This plugin adds imports for createFileRoute and createLazyFileRoute to the file route.
9
+ */
10
+ var unpluginRouteAutoImportFactory = (options = {}) => {
11
+ let ROOT = process.cwd();
12
+ let userConfig;
13
+ function initUserConfig() {
14
+ if (typeof options === "function") userConfig = options();
15
+ else userConfig = getConfig(options, ROOT);
16
+ }
17
+ return {
18
+ name: "tanstack-router:autoimport",
19
+ enforce: "pre",
20
+ transform: {
21
+ filter: {
22
+ id: /\.(m|c)?(j|t)sx?$/,
23
+ code: /createFileRoute\(|createLazyFileRoute\(/
24
+ },
25
+ handler(code, id) {
26
+ const normalizedId = normalizePath(id);
27
+ if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) return null;
28
+ let routeType;
29
+ if (code.includes("createFileRoute(")) routeType = "createFileRoute";
30
+ else if (code.includes("createLazyFileRoute(")) routeType = "createLazyFileRoute";
31
+ else return null;
32
+ const routerImportPath = `@tanstack/${userConfig.target}-router`;
33
+ const ast = parseAst({ code });
34
+ let isCreateRouteFunctionImported = false;
35
+ babel.traverse(ast, { Program: { enter(programPath) {
36
+ programPath.traverse({ ImportDeclaration(path) {
37
+ if (path.node.specifiers.map((specifier) => specifier.local.name).includes(routeType) && path.node.source.value === routerImportPath) isCreateRouteFunctionImported = true;
38
+ } });
39
+ } } });
40
+ if (!isCreateRouteFunctionImported) {
41
+ if (debug) console.info("Adding autoimports to route ", normalizedId);
42
+ const autoImportStatement = template.statement(`import { ${routeType} } from '${routerImportPath}'`)();
43
+ ast.program.body.unshift(autoImportStatement);
44
+ const result = generateFromAst(ast, {
45
+ sourceMaps: true,
46
+ filename: normalizedId,
47
+ sourceFileName: normalizedId
48
+ });
49
+ if (debug) {
50
+ logDiff(code, result.code);
51
+ console.log("Output:\n", result.code + "\n\n");
52
+ }
53
+ return result;
54
+ }
55
+ return null;
56
+ }
57
+ },
58
+ vite: {
59
+ configResolved(config) {
60
+ ROOT = config.root;
61
+ initUserConfig();
62
+ },
63
+ applyToEnvironment() {
64
+ return userConfig.verboseFileRoutes === false;
65
+ }
66
+ },
67
+ rspack() {
68
+ ROOT = process.cwd();
69
+ initUserConfig();
70
+ },
71
+ webpack() {
72
+ ROOT = process.cwd();
73
+ initUserConfig();
74
+ }
75
+ };
99
76
  };
100
- //# sourceMappingURL=route-autoimport-plugin.js.map
77
+ //#endregion
78
+ export { unpluginRouteAutoImportFactory };
79
+
80
+ //# sourceMappingURL=route-autoimport-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-autoimport-plugin.js","sources":["../../../src/core/route-autoimport-plugin.ts"],"sourcesContent":["import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport babel from '@babel/core'\nimport * as template from '@babel/template'\nimport { getConfig } from './config'\nimport { debug, normalizePath } from './utils'\nimport type { Config } from './config'\nimport type { UnpluginFactory } from 'unplugin'\n\n/**\n * This plugin adds imports for createFileRoute and createLazyFileRoute to the file route.\n */\nexport const unpluginRouteAutoImportFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n return {\n name: 'tanstack-router:autoimport',\n enforce: 'pre',\n\n transform: {\n filter: {\n // this is necessary for webpack / rspack to avoid matching .html files\n id: /\\.(m|c)?(j|t)sx?$/,\n code: /createFileRoute\\(|createLazyFileRoute\\(/,\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) {\n return null\n }\n let routeType: 'createFileRoute' | 'createLazyFileRoute'\n if (code.includes('createFileRoute(')) {\n routeType = 'createFileRoute'\n } else if (code.includes('createLazyFileRoute(')) {\n routeType = 'createLazyFileRoute'\n } else {\n return null\n }\n\n const routerImportPath = `@tanstack/${userConfig.target}-router`\n\n const ast = parseAst({ code })\n\n let isCreateRouteFunctionImported = false as boolean\n\n babel.traverse(ast, {\n Program: {\n enter(programPath) {\n programPath.traverse({\n ImportDeclaration(path) {\n const importedSpecifiers = path.node.specifiers.map(\n (specifier) => specifier.local.name,\n )\n if (\n importedSpecifiers.includes(routeType) &&\n path.node.source.value === routerImportPath\n ) {\n isCreateRouteFunctionImported = true\n }\n },\n })\n },\n },\n })\n\n if (!isCreateRouteFunctionImported) {\n if (debug) console.info('Adding autoimports to route ', normalizedId)\n\n const autoImportStatement = template.statement(\n `import { ${routeType} } from '${routerImportPath}'`,\n )()\n ast.program.body.unshift(autoImportStatement)\n\n const result = generateFromAst(ast, {\n sourceMaps: true,\n filename: normalizedId,\n sourceFileName: normalizedId,\n })\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n return result\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n },\n // this check may only happen after config is resolved, so we use applyToEnvironment (apply is too early)\n applyToEnvironment() {\n return userConfig.verboseFileRoutes === false\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n }\n}\n"],"names":[],"mappings":";;;;;AAWO,MAAM,iCAET,CAAC,UAAU,OAAO;AACpB,MAAI,OAAe,QAAQ,IAAA;AAC3B,MAAI;AAEJ,WAAS,iBAAiB;AACxB,QAAI,OAAO,YAAY,YAAY;AACjC,mBAAa,QAAA;AAAA,IACf,OAAO;AACL,mBAAa,UAAU,SAAS,IAAI;AAAA,IACtC;AAAA,EACF;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,WAAW;AAAA,MACT,QAAQ;AAAA;AAAA,QAEN,IAAI;AAAA,QACJ,MAAM;AAAA,MAAA;AAAA,MAER,QAAQ,MAAM,IAAI;AAChB,cAAM,eAAe,cAAc,EAAE;AACrC,YAAI,CAAC,WAAW,sBAAsB,IAAI,YAAY,GAAG;AACvD,iBAAO;AAAA,QACT;AACA,YAAI;AACJ,YAAI,KAAK,SAAS,kBAAkB,GAAG;AACrC,sBAAY;AAAA,QACd,WAAW,KAAK,SAAS,sBAAsB,GAAG;AAChD,sBAAY;AAAA,QACd,OAAO;AACL,iBAAO;AAAA,QACT;AAEA,cAAM,mBAAmB,aAAa,WAAW,MAAM;AAEvD,cAAM,MAAM,SAAS,EAAE,MAAM;AAE7B,YAAI,gCAAgC;AAEpC,cAAM,SAAS,KAAK;AAAA,UAClB,SAAS;AAAA,YACP,MAAM,aAAa;AACjB,0BAAY,SAAS;AAAA,gBACnB,kBAAkB,MAAM;AACtB,wBAAM,qBAAqB,KAAK,KAAK,WAAW;AAAA,oBAC9C,CAAC,cAAc,UAAU,MAAM;AAAA,kBAAA;AAEjC,sBACE,mBAAmB,SAAS,SAAS,KACrC,KAAK,KAAK,OAAO,UAAU,kBAC3B;AACA,oDAAgC;AAAA,kBAClC;AAAA,gBACF;AAAA,cAAA,CACD;AAAA,YACH;AAAA,UAAA;AAAA,QACF,CACD;AAED,YAAI,CAAC,+BAA+B;AAClC,cAAI,MAAO,SAAQ,KAAK,gCAAgC,YAAY;AAEpE,gBAAM,sBAAsB,SAAS;AAAA,YACnC,YAAY,SAAS,YAAY,gBAAgB;AAAA,UAAA,EACnD;AACA,cAAI,QAAQ,KAAK,QAAQ,mBAAmB;AAE5C,gBAAM,SAAS,gBAAgB,KAAK;AAAA,YAClC,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,gBAAgB;AAAA,UAAA,CACjB;AACD,cAAI,OAAO;AACT,oBAAQ,MAAM,OAAO,IAAI;AACzB,oBAAQ,IAAI,aAAa,OAAO,OAAO,MAAM;AAAA,UAC/C;AACA,iBAAO;AAAA,QACT;AAEA,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,IAGF,MAAM;AAAA,MACJ,eAAe,QAAQ;AACrB,eAAO,OAAO;AACd,uBAAA;AAAA,MACF;AAAA;AAAA,MAEA,qBAAqB;AACnB,eAAO,WAAW,sBAAsB;AAAA,MAC1C;AAAA,IAAA;AAAA,IAGF,SAAS;AACP,aAAO,QAAQ,IAAA;AACf,qBAAA;AAAA,IACF;AAAA,IAEA,UAAU;AACR,aAAO,QAAQ,IAAA;AACf,qBAAA;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"route-autoimport-plugin.js","names":[],"sources":["../../../src/core/route-autoimport-plugin.ts"],"sourcesContent":["import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport * as babel from '@babel/core'\nimport * as template from '@babel/template'\nimport { getConfig } from './config'\nimport { debug, normalizePath } from './utils'\nimport type { Config } from './config'\nimport type { UnpluginFactory } from 'unplugin'\n\n/**\n * This plugin adds imports for createFileRoute and createLazyFileRoute to the file route.\n */\nexport const unpluginRouteAutoImportFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n return {\n name: 'tanstack-router:autoimport',\n enforce: 'pre',\n\n transform: {\n filter: {\n // this is necessary for webpack / rspack to avoid matching .html files\n id: /\\.(m|c)?(j|t)sx?$/,\n code: /createFileRoute\\(|createLazyFileRoute\\(/,\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) {\n return null\n }\n let routeType: 'createFileRoute' | 'createLazyFileRoute'\n if (code.includes('createFileRoute(')) {\n routeType = 'createFileRoute'\n } else if (code.includes('createLazyFileRoute(')) {\n routeType = 'createLazyFileRoute'\n } else {\n return null\n }\n\n const routerImportPath = `@tanstack/${userConfig.target}-router`\n\n const ast = parseAst({ code })\n\n let isCreateRouteFunctionImported = false as boolean\n\n babel.traverse(ast, {\n Program: {\n enter(programPath) {\n programPath.traverse({\n ImportDeclaration(path) {\n const importedSpecifiers = path.node.specifiers.map(\n (specifier) => specifier.local.name,\n )\n if (\n importedSpecifiers.includes(routeType) &&\n path.node.source.value === routerImportPath\n ) {\n isCreateRouteFunctionImported = true\n }\n },\n })\n },\n },\n })\n\n if (!isCreateRouteFunctionImported) {\n if (debug) console.info('Adding autoimports to route ', normalizedId)\n\n const autoImportStatement = template.statement(\n `import { ${routeType} } from '${routerImportPath}'`,\n )()\n ast.program.body.unshift(autoImportStatement)\n\n const result = generateFromAst(ast, {\n sourceMaps: true,\n filename: normalizedId,\n sourceFileName: normalizedId,\n })\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n return result\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n },\n // this check may only happen after config is resolved, so we use applyToEnvironment (apply is too early)\n applyToEnvironment() {\n return userConfig.verboseFileRoutes === false\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n }\n}\n"],"mappings":";;;;;;;;;AAWA,IAAa,kCAER,UAAU,EAAE,KAAK;CACpB,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI;CAEJ,SAAS,iBAAiB;AACxB,MAAI,OAAO,YAAY,WACrB,cAAa,SAAS;MAEtB,cAAa,UAAU,SAAS,KAAK;;AAGzC,QAAO;EACL,MAAM;EACN,SAAS;EAET,WAAW;GACT,QAAQ;IAEN,IAAI;IACJ,MAAM;IACP;GACD,QAAQ,MAAM,IAAI;IAChB,MAAM,eAAe,cAAc,GAAG;AACtC,QAAI,CAAC,WAAW,sBAAsB,IAAI,aAAa,CACrD,QAAO;IAET,IAAI;AACJ,QAAI,KAAK,SAAS,mBAAmB,CACnC,aAAY;aACH,KAAK,SAAS,uBAAuB,CAC9C,aAAY;QAEZ,QAAO;IAGT,MAAM,mBAAmB,aAAa,WAAW,OAAO;IAExD,MAAM,MAAM,SAAS,EAAE,MAAM,CAAC;IAE9B,IAAI,gCAAgC;AAEpC,UAAM,SAAS,KAAK,EAClB,SAAS,EACP,MAAM,aAAa;AACjB,iBAAY,SAAS,EACnB,kBAAkB,MAAM;AAItB,UAH2B,KAAK,KAAK,WAAW,KAC7C,cAAc,UAAU,MAAM,KAChC,CAEoB,SAAS,UAAU,IACtC,KAAK,KAAK,OAAO,UAAU,iBAE3B,iCAAgC;QAGrC,CAAC;OAEL,EACF,CAAC;AAEF,QAAI,CAAC,+BAA+B;AAClC,SAAI,MAAO,SAAQ,KAAK,gCAAgC,aAAa;KAErE,MAAM,sBAAsB,SAAS,UACnC,YAAY,UAAU,WAAW,iBAAiB,GACnD,EAAE;AACH,SAAI,QAAQ,KAAK,QAAQ,oBAAoB;KAE7C,MAAM,SAAS,gBAAgB,KAAK;MAClC,YAAY;MACZ,UAAU;MACV,gBAAgB;MACjB,CAAC;AACF,SAAI,OAAO;AACT,cAAQ,MAAM,OAAO,KAAK;AAC1B,cAAQ,IAAI,aAAa,OAAO,OAAO,OAAO;;AAEhD,YAAO;;AAGT,WAAO;;GAEV;EAED,MAAM;GACJ,eAAe,QAAQ;AACrB,WAAO,OAAO;AACd,oBAAgB;;GAGlB,qBAAqB;AACnB,WAAO,WAAW,sBAAsB;;GAE3C;EAED,SAAS;AACP,UAAO,QAAQ,KAAK;AACpB,mBAAgB;;EAGlB,UAAU;AACR,UAAO,QAAQ,KAAK;AACpB,mBAAgB;;EAEnB"}