@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,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
+ //#region src/core/code-splitter/path-ids.ts
3
2
  function createIdentifier(strings) {
4
- if (strings.length === 0) {
5
- throw new Error("Cannot create an identifier from an empty array");
6
- }
7
- const sortedStrings = [...strings].sort();
8
- const combinedString = sortedStrings.join("---");
9
- let safeString = combinedString.replace(/\//g, "--slash--");
10
- safeString = safeString.replace(/\\/g, "--backslash--");
11
- safeString = safeString.replace(/\?/g, "--question--");
12
- safeString = safeString.replace(/%/g, "--percent--");
13
- safeString = safeString.replace(/#/g, "--hash--");
14
- safeString = safeString.replace(/\+/g, "--plus--");
15
- safeString = safeString.replace(/=/g, "--equals--");
16
- safeString = safeString.replace(/&/g, "--ampersand--");
17
- safeString = safeString.replace(/\s/g, "_");
18
- 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;
19
14
  }
20
15
  function decodeIdentifier(identifier) {
21
- if (!identifier) {
22
- return [];
23
- }
24
- let combinedString = identifier.replace(/--slash--/g, "/");
25
- combinedString = combinedString.replace(/--backslash--/g, "\\");
26
- combinedString = combinedString.replace(/--question--/g, "?");
27
- combinedString = combinedString.replace(/--percent--/g, "%");
28
- combinedString = combinedString.replace(/--hash--/g, "#");
29
- combinedString = combinedString.replace(/--plus--/g, "+");
30
- combinedString = combinedString.replace(/--equals--/g, "=");
31
- combinedString = combinedString.replace(/--ampersand--/g, "&");
32
- combinedString = combinedString.replace(/_/g, " ");
33
- 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("---");
34
27
  }
28
+ //#endregion
35
29
  exports.createIdentifier = createIdentifier;
36
30
  exports.decodeIdentifier = decodeIdentifier;
37
- //# sourceMappingURL=path-ids.cjs.map
31
+
32
+ //# sourceMappingURL=path-ids.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-ids.cjs","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.cjs","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
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const reactRefreshRouteComponents = require("./react-refresh-route-components.cjs");
1
+ const require_react_refresh_route_components = require("./react-refresh-route-components.cjs");
2
+ //#region src/core/code-splitter/plugins/framework-plugins.ts
4
3
  function getReferenceRouteCompilerPlugins(opts) {
5
- switch (opts.targetFramework) {
6
- case "react": {
7
- if (opts.addHmr) {
8
- return [reactRefreshRouteComponents.createReactRefreshRouteComponentsPlugin()];
9
- }
10
- return void 0;
11
- }
12
- default:
13
- return void 0;
14
- }
4
+ switch (opts.targetFramework) {
5
+ case "react":
6
+ if (opts.addHmr) return [require_react_refresh_route_components.createReactRefreshRouteComponentsPlugin()];
7
+ return;
8
+ default: return;
9
+ }
15
10
  }
11
+ //#endregion
16
12
  exports.getReferenceRouteCompilerPlugins = getReferenceRouteCompilerPlugins;
17
- //# sourceMappingURL=framework-plugins.cjs.map
13
+
14
+ //# sourceMappingURL=framework-plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"framework-plugins.cjs","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":["createReactRefreshRouteComponentsPlugin"],"mappings":";;;AAIO,SAAS,iCAAiC,MAGG;AAClD,UAAQ,KAAK,iBAAA;AAAA,IACX,KAAK,SAAS;AACZ,UAAI,KAAK,QAAQ;AACf,eAAO,CAACA,4BAAAA,yCAAyC;AAAA,MACnD;AACA,aAAO;AAAA,IACT;AAAA,IACA;AACE,aAAO;AAAA,EAAA;AAEb;;"}
1
+ {"version":3,"file":"framework-plugins.cjs","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,uCAAA,yCAAyC,CAAC;AAEpD;EAEF,QACE"}
@@ -1,69 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const t = require("@babel/types");
4
- const utils = require("../../utils.cjs");
5
- function _interopNamespaceDefault(e) {
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const t__namespace = /* @__PURE__ */ _interopNamespaceDefault(t);
22
- const REACT_REFRESH_ROUTE_COMPONENT_IDENTS = /* @__PURE__ */ new Set([
23
- "component",
24
- "pendingComponent",
25
- "errorComponent",
26
- "notFoundComponent"
1
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
2
+ const require_utils = require("../../utils.cjs");
3
+ let _babel_types = require("@babel/types");
4
+ _babel_types = require_runtime.__toESM(_babel_types);
5
+ //#region src/core/code-splitter/plugins/react-refresh-route-components.ts
6
+ var REACT_REFRESH_ROUTE_COMPONENT_IDENTS = new Set([
7
+ "component",
8
+ "pendingComponent",
9
+ "errorComponent",
10
+ "notFoundComponent"
27
11
  ]);
28
12
  function createReactRefreshRouteComponentsPlugin() {
29
- return {
30
- name: "react-refresh-route-components",
31
- onUnsplittableRoute(ctx) {
32
- if (!ctx.opts.addHmr) {
33
- return;
34
- }
35
- const hoistedDeclarations = [];
36
- ctx.routeOptions.properties.forEach((prop) => {
37
- if (!t__namespace.isObjectProperty(prop) || !t__namespace.isIdentifier(prop.key)) {
38
- return;
39
- }
40
- if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) {
41
- return;
42
- }
43
- if (!t__namespace.isArrowFunctionExpression(prop.value) && !t__namespace.isFunctionExpression(prop.value)) {
44
- return;
45
- }
46
- const hoistedIdentifier = utils.getUniqueProgramIdentifier(
47
- ctx.programPath,
48
- `TSR${prop.key.name[0].toUpperCase()}${prop.key.name.slice(1)}`
49
- );
50
- hoistedDeclarations.push(
51
- t__namespace.variableDeclaration("const", [
52
- t__namespace.variableDeclarator(
53
- hoistedIdentifier,
54
- t__namespace.cloneNode(prop.value, true)
55
- )
56
- ])
57
- );
58
- prop.value = t__namespace.cloneNode(hoistedIdentifier);
59
- });
60
- if (hoistedDeclarations.length === 0) {
61
- return;
62
- }
63
- ctx.insertionPath.insertBefore(hoistedDeclarations);
64
- return { modified: true };
65
- }
66
- };
13
+ return {
14
+ name: "react-refresh-route-components",
15
+ onUnsplittableRoute(ctx) {
16
+ if (!ctx.opts.addHmr) return;
17
+ const hoistedDeclarations = [];
18
+ ctx.routeOptions.properties.forEach((prop) => {
19
+ if (!_babel_types.isObjectProperty(prop) || !_babel_types.isIdentifier(prop.key)) return;
20
+ if (!REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(prop.key.name)) return;
21
+ if (!_babel_types.isArrowFunctionExpression(prop.value) && !_babel_types.isFunctionExpression(prop.value)) return;
22
+ const hoistedIdentifier = require_utils.getUniqueProgramIdentifier(ctx.programPath, `TSR${prop.key.name[0].toUpperCase()}${prop.key.name.slice(1)}`);
23
+ hoistedDeclarations.push(_babel_types.variableDeclaration("const", [_babel_types.variableDeclarator(hoistedIdentifier, _babel_types.cloneNode(prop.value, true))]));
24
+ prop.value = _babel_types.cloneNode(hoistedIdentifier);
25
+ });
26
+ if (hoistedDeclarations.length === 0) return;
27
+ ctx.insertionPath.insertBefore(hoistedDeclarations);
28
+ return { modified: true };
29
+ }
30
+ };
67
31
  }
32
+ //#endregion
68
33
  exports.createReactRefreshRouteComponentsPlugin = createReactRefreshRouteComponentsPlugin;
69
- //# sourceMappingURL=react-refresh-route-components.cjs.map
34
+
35
+ //# sourceMappingURL=react-refresh-route-components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-refresh-route-components.cjs","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":["t","getUniqueProgramIdentifier"],"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,CAACA,aAAE,iBAAiB,IAAI,KAAK,CAACA,aAAE,aAAa,KAAK,GAAG,GAAG;AAC1D;AAAA,QACF;AAEA,YAAI,CAAC,qCAAqC,IAAI,KAAK,IAAI,IAAI,GAAG;AAC5D;AAAA,QACF;AAEA,YACE,CAACA,aAAE,0BAA0B,KAAK,KAAK,KACvC,CAACA,aAAE,qBAAqB,KAAK,KAAK,GAClC;AACA;AAAA,QACF;AAEA,cAAM,oBAAoBC,MAAAA;AAAAA,UACxB,IAAI;AAAA,UACJ,MAAM,KAAK,IAAI,KAAK,CAAC,EAAG,aAAa,GAAG,KAAK,IAAI,KAAK,MAAM,CAAC,CAAC;AAAA,QAAA;AAGhE,4BAAoB;AAAA,UAClBD,aAAE,oBAAoB,SAAS;AAAA,YAC7BA,aAAE;AAAA,cACA;AAAA,cACAA,aAAE,UAAU,KAAK,OAAO,IAAI;AAAA,YAAA;AAAA,UAC9B,CACD;AAAA,QAAA;AAGH,aAAK,QAAQA,aAAE,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.cjs","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,aAAE,iBAAiB,KAAK,IAAI,CAAC,aAAE,aAAa,KAAK,IAAI,CACxD;AAGF,QAAI,CAAC,qCAAqC,IAAI,KAAK,IAAI,KAAK,CAC1D;AAGF,QACE,CAAC,aAAE,0BAA0B,KAAK,MAAM,IACxC,CAAC,aAAE,qBAAqB,KAAK,MAAM,CAEnC;IAGF,MAAM,oBAAoB,cAAA,2BACxB,IAAI,aACJ,MAAM,KAAK,IAAI,KAAK,GAAI,aAAa,GAAG,KAAK,IAAI,KAAK,MAAM,EAAE,GAC/D;AAED,wBAAoB,KAClB,aAAE,oBAAoB,SAAS,CAC7B,aAAE,mBACA,mBACA,aAAE,UAAU,KAAK,OAAO,KAAK,CAC9B,CACF,CAAC,CACH;AAED,SAAK,QAAQ,aAAE,UAAU,kBAAkB;KAC3C;AAEF,OAAI,oBAAoB,WAAW,EACjC;AAGF,OAAI,cAAc,aAAa,oBAAoB;AACnD,UAAO,EAAE,UAAU,MAAM;;EAE5B"}
@@ -1,53 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const zod = require("zod");
4
- const routerGenerator = require("@tanstack/router-generator");
5
- const splitGroupingsSchema = zod.z.array(
6
- zod.z.array(
7
- zod.z.union([
8
- zod.z.literal("loader"),
9
- zod.z.literal("component"),
10
- zod.z.literal("pendingComponent"),
11
- zod.z.literal("errorComponent"),
12
- zod.z.literal("notFoundComponent")
13
- ])
14
- ),
15
- {
16
- message: " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]"
17
- }
18
- ).superRefine((val, ctx) => {
19
- const flattened = val.flat();
20
- const unique = [...new Set(flattened)];
21
- if (unique.length !== flattened.length) {
22
- ctx.addIssue({
23
- code: "custom",
24
- message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].
25
- You input was: ${JSON.stringify(val)}.`
26
- });
27
- }
1
+ require("../_virtual/_rolldown/runtime.cjs");
2
+ let zod = require("zod");
3
+ let _tanstack_router_generator = require("@tanstack/router-generator");
4
+ //#region src/core/config.ts
5
+ var splitGroupingsSchema = zod.z.array(zod.z.array(zod.z.union([
6
+ zod.z.literal("loader"),
7
+ zod.z.literal("component"),
8
+ zod.z.literal("pendingComponent"),
9
+ zod.z.literal("errorComponent"),
10
+ zod.z.literal("notFoundComponent")
11
+ ])), { message: " Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]" }).superRefine((val, ctx) => {
12
+ const flattened = val.flat();
13
+ if ([...new Set(flattened)].length !== flattened.length) ctx.addIssue({
14
+ code: "custom",
15
+ message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].\n You input was: ${JSON.stringify(val)}.`
16
+ });
28
17
  });
29
- const codeSplittingOptionsSchema = zod.z.object({
30
- splitBehavior: zod.z.function().optional(),
31
- defaultBehavior: splitGroupingsSchema.optional(),
32
- deleteNodes: zod.z.array(zod.z.string()).optional(),
33
- addHmr: zod.z.boolean().optional().default(true)
18
+ var codeSplittingOptionsSchema = zod.z.object({
19
+ splitBehavior: zod.z.function().optional(),
20
+ defaultBehavior: splitGroupingsSchema.optional(),
21
+ deleteNodes: zod.z.array(zod.z.string()).optional(),
22
+ addHmr: zod.z.boolean().optional().default(true)
34
23
  });
35
- const configSchema = routerGenerator.configSchema.extend({
36
- enableRouteGeneration: zod.z.boolean().optional(),
37
- codeSplittingOptions: zod.z.custom((v) => {
38
- return codeSplittingOptionsSchema.parse(v);
39
- }).optional(),
40
- plugin: zod.z.object({
41
- vite: zod.z.object({
42
- environmentName: zod.z.string().optional()
43
- }).optional()
44
- }).optional()
24
+ var configSchema = _tanstack_router_generator.configSchema.extend({
25
+ enableRouteGeneration: zod.z.boolean().optional(),
26
+ codeSplittingOptions: zod.z.custom((v) => {
27
+ return codeSplittingOptionsSchema.parse(v);
28
+ }).optional(),
29
+ plugin: zod.z.object({ vite: zod.z.object({ environmentName: zod.z.string().optional() }).optional() }).optional()
45
30
  });
46
- const getConfig = (inlineConfig, root) => {
47
- const config = routerGenerator.getConfig(inlineConfig, root);
48
- return configSchema.parse({ ...inlineConfig, ...config });
31
+ var getConfig = (inlineConfig, root) => {
32
+ const config = (0, _tanstack_router_generator.getConfig)(inlineConfig, root);
33
+ return configSchema.parse({
34
+ ...inlineConfig,
35
+ ...config
36
+ });
49
37
  };
38
+ //#endregion
50
39
  exports.configSchema = configSchema;
51
40
  exports.getConfig = getConfig;
52
41
  exports.splitGroupingsSchema = splitGroupingsSchema;
53
- //# sourceMappingURL=config.cjs.map
42
+
43
+ //# sourceMappingURL=config.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","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":["z","generatorConfigSchema","getGeneratorConfig"],"mappings":";;;;AAYO,MAAM,uBAAuBA,IAAAA,EACjC;AAAA,EACCA,IAAAA,EAAE;AAAA,IACAA,IAAAA,EAAE,MAAM;AAAA,MACNA,IAAAA,EAAE,QAAQ,QAAQ;AAAA,MAClBA,IAAAA,EAAE,QAAQ,WAAW;AAAA,MACrBA,IAAAA,EAAE,QAAQ,kBAAkB;AAAA,MAC5BA,IAAAA,EAAE,QAAQ,gBAAgB;AAAA,MAC1BA,IAAAA,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,6BAA6BA,IAAAA,EAAE,OAAO;AAAA,EAC1C,eAAeA,IAAAA,EAAE,SAAA,EAAW,SAAA;AAAA,EAC5B,iBAAiB,qBAAqB,SAAA;AAAA,EACtC,aAAaA,IAAAA,EAAE,MAAMA,IAAAA,EAAE,OAAA,CAAQ,EAAE,SAAA;AAAA,EACjC,QAAQA,IAAAA,EAAE,QAAA,EAAU,SAAA,EAAW,QAAQ,IAAI;AAC7C,CAAC;AAOM,MAAM,eAAeC,gBAAAA,aAAsB,OAAO;AAAA,EACvD,uBAAuBD,IAAAA,EAAE,QAAA,EAAU,SAAA;AAAA,EACnC,sBAAsBA,IAAAA,EACnB,OAA6B,CAAC,MAAM;AACnC,WAAO,2BAA2B,MAAM,CAAC;AAAA,EAC3C,CAAC,EACA,SAAA;AAAA,EACH,QAAQA,IAAAA,EACL,OAAO;AAAA,IACN,MAAMA,IAAAA,EACH,OAAO;AAAA,MACN,iBAAiBA,IAAAA,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,SAASE,gBAAAA,UAAmB,cAAc,IAAI;AAEpD,SAAO,aAAa,MAAM,EAAE,GAAG,cAAc,GAAG,QAAQ;AAC1D;;;;"}
1
+ {"version":3,"file":"config.cjs","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,IAAA,EACjC,MACC,IAAA,EAAE,MACA,IAAA,EAAE,MAAM;CACN,IAAA,EAAE,QAAQ,SAAS;CACnB,IAAA,EAAE,QAAQ,YAAY;CACtB,IAAA,EAAE,QAAQ,mBAAmB;CAC7B,IAAA,EAAE,QAAQ,iBAAiB;CAC3B,IAAA,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,IAAA,EAAE,OAAO;CAC1C,eAAe,IAAA,EAAE,UAAU,CAAC,UAAU;CACtC,iBAAiB,qBAAqB,UAAU;CAChD,aAAa,IAAA,EAAE,MAAM,IAAA,EAAE,QAAQ,CAAC,CAAC,UAAU;CAC3C,QAAQ,IAAA,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,KAAK;CAC7C,CAAC;AAOF,IAAa,eAAe,2BAAA,aAAsB,OAAO;CACvD,uBAAuB,IAAA,EAAE,SAAS,CAAC,UAAU;CAC7C,sBAAsB,IAAA,EACnB,QAA8B,MAAM;AACnC,SAAO,2BAA2B,MAAM,EAAE;GAC1C,CACD,UAAU;CACb,QAAQ,IAAA,EACL,OAAO,EACN,MAAM,IAAA,EACH,OAAO,EACN,iBAAiB,IAAA,EAAE,QAAQ,CAAC,UAAU,EACvC,CAAC,CACD,UAAU,EACd,CAAC,CACD,UAAU;CACd,CAAC;AAEF,IAAa,aAAa,cAA+B,SAAiB;CACxE,MAAM,UAAA,GAAA,2BAAA,WAA4B,cAAc,KAAK;AAErD,QAAO,aAAa,MAAM;EAAE,GAAG;EAAc,GAAG;EAAQ,CAAC"}
@@ -1,21 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const tsrSplit = "tsr-split";
4
- const tsrShared = "tsr-shared";
5
- const splitRouteIdentNodes = [
6
- "loader",
7
- "component",
8
- "pendingComponent",
9
- "errorComponent",
10
- "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"
11
10
  ];
12
- const defaultCodeSplitGroupings = [
13
- ["component"],
14
- ["errorComponent"],
15
- ["notFoundComponent"]
11
+ var defaultCodeSplitGroupings = [
12
+ ["component"],
13
+ ["errorComponent"],
14
+ ["notFoundComponent"]
16
15
  ];
16
+ //#endregion
17
17
  exports.defaultCodeSplitGroupings = defaultCodeSplitGroupings;
18
18
  exports.splitRouteIdentNodes = splitRouteIdentNodes;
19
19
  exports.tsrShared = tsrShared;
20
20
  exports.tsrSplit = tsrSplit;
21
- //# sourceMappingURL=constants.cjs.map
21
+
22
+ //# sourceMappingURL=constants.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","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.cjs","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,117 +1,83 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const routerUtils = require("@tanstack/router-utils");
4
- const babel = require("@babel/core");
5
- const template = require("@babel/template");
6
- const config = require("./config.cjs");
7
- const utils = require("./utils.cjs");
8
- function _interopNamespaceDefault(e) {
9
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
- if (e) {
11
- for (const k in e) {
12
- if (k !== "default") {
13
- const d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: () => e[k]
17
- });
18
- }
19
- }
20
- }
21
- n.default = e;
22
- return Object.freeze(n);
23
- }
24
- const template__namespace = /* @__PURE__ */ _interopNamespaceDefault(template);
25
- const unpluginRouteAutoImportFactory = (options = {}) => {
26
- let ROOT = process.cwd();
27
- let userConfig;
28
- function initUserConfig() {
29
- if (typeof options === "function") {
30
- userConfig = options();
31
- } else {
32
- userConfig = config.getConfig(options, ROOT);
33
- }
34
- }
35
- return {
36
- name: "tanstack-router:autoimport",
37
- enforce: "pre",
38
- transform: {
39
- filter: {
40
- // this is necessary for webpack / rspack to avoid matching .html files
41
- id: /\.(m|c)?(j|t)sx?$/,
42
- code: /createFileRoute\(|createLazyFileRoute\(/
43
- },
44
- handler(code, id) {
45
- const normalizedId = utils.normalizePath(id);
46
- if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) {
47
- return null;
48
- }
49
- let routeType;
50
- if (code.includes("createFileRoute(")) {
51
- routeType = "createFileRoute";
52
- } else if (code.includes("createLazyFileRoute(")) {
53
- routeType = "createLazyFileRoute";
54
- } else {
55
- return null;
56
- }
57
- const routerImportPath = `@tanstack/${userConfig.target}-router`;
58
- const ast = routerUtils.parseAst({ code });
59
- let isCreateRouteFunctionImported = false;
60
- babel.traverse(ast, {
61
- Program: {
62
- enter(programPath) {
63
- programPath.traverse({
64
- ImportDeclaration(path) {
65
- const importedSpecifiers = path.node.specifiers.map(
66
- (specifier) => specifier.local.name
67
- );
68
- if (importedSpecifiers.includes(routeType) && path.node.source.value === routerImportPath) {
69
- isCreateRouteFunctionImported = true;
70
- }
71
- }
72
- });
73
- }
74
- }
75
- });
76
- if (!isCreateRouteFunctionImported) {
77
- if (utils.debug) console.info("Adding autoimports to route ", normalizedId);
78
- const autoImportStatement = template__namespace.statement(
79
- `import { ${routeType} } from '${routerImportPath}'`
80
- )();
81
- ast.program.body.unshift(autoImportStatement);
82
- const result = routerUtils.generateFromAst(ast, {
83
- sourceMaps: true,
84
- filename: normalizedId,
85
- sourceFileName: normalizedId
86
- });
87
- if (utils.debug) {
88
- routerUtils.logDiff(code, result.code);
89
- console.log("Output:\n", result.code + "\n\n");
90
- }
91
- return result;
92
- }
93
- return null;
94
- }
95
- },
96
- vite: {
97
- configResolved(config2) {
98
- ROOT = config2.root;
99
- initUserConfig();
100
- },
101
- // this check may only happen after config is resolved, so we use applyToEnvironment (apply is too early)
102
- applyToEnvironment() {
103
- return userConfig.verboseFileRoutes === false;
104
- }
105
- },
106
- rspack() {
107
- ROOT = process.cwd();
108
- initUserConfig();
109
- },
110
- webpack() {
111
- ROOT = process.cwd();
112
- initUserConfig();
113
- }
114
- };
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ const require_config = require("./config.cjs");
3
+ const require_utils = require("./utils.cjs");
4
+ let _tanstack_router_utils = require("@tanstack/router-utils");
5
+ let _babel_core = require("@babel/core");
6
+ _babel_core = require_runtime.__toESM(_babel_core);
7
+ let _babel_template = require("@babel/template");
8
+ _babel_template = require_runtime.__toESM(_babel_template);
9
+ //#region src/core/route-autoimport-plugin.ts
10
+ /**
11
+ * This plugin adds imports for createFileRoute and createLazyFileRoute to the file route.
12
+ */
13
+ var unpluginRouteAutoImportFactory = (options = {}) => {
14
+ let ROOT = process.cwd();
15
+ let userConfig;
16
+ function initUserConfig() {
17
+ if (typeof options === "function") userConfig = options();
18
+ else userConfig = require_config.getConfig(options, ROOT);
19
+ }
20
+ return {
21
+ name: "tanstack-router:autoimport",
22
+ enforce: "pre",
23
+ transform: {
24
+ filter: {
25
+ id: /\.(m|c)?(j|t)sx?$/,
26
+ code: /createFileRoute\(|createLazyFileRoute\(/
27
+ },
28
+ handler(code, id) {
29
+ const normalizedId = require_utils.normalizePath(id);
30
+ if (!globalThis.TSR_ROUTES_BY_ID_MAP?.has(normalizedId)) return null;
31
+ let routeType;
32
+ if (code.includes("createFileRoute(")) routeType = "createFileRoute";
33
+ else if (code.includes("createLazyFileRoute(")) routeType = "createLazyFileRoute";
34
+ else return null;
35
+ const routerImportPath = `@tanstack/${userConfig.target}-router`;
36
+ const ast = (0, _tanstack_router_utils.parseAst)({ code });
37
+ let isCreateRouteFunctionImported = false;
38
+ _babel_core.traverse(ast, { Program: { enter(programPath) {
39
+ programPath.traverse({ ImportDeclaration(path) {
40
+ if (path.node.specifiers.map((specifier) => specifier.local.name).includes(routeType) && path.node.source.value === routerImportPath) isCreateRouteFunctionImported = true;
41
+ } });
42
+ } } });
43
+ if (!isCreateRouteFunctionImported) {
44
+ if (require_utils.debug) console.info("Adding autoimports to route ", normalizedId);
45
+ const autoImportStatement = _babel_template.statement(`import { ${routeType} } from '${routerImportPath}'`)();
46
+ ast.program.body.unshift(autoImportStatement);
47
+ const result = (0, _tanstack_router_utils.generateFromAst)(ast, {
48
+ sourceMaps: true,
49
+ filename: normalizedId,
50
+ sourceFileName: normalizedId
51
+ });
52
+ if (require_utils.debug) {
53
+ (0, _tanstack_router_utils.logDiff)(code, result.code);
54
+ console.log("Output:\n", result.code + "\n\n");
55
+ }
56
+ return result;
57
+ }
58
+ return null;
59
+ }
60
+ },
61
+ vite: {
62
+ configResolved(config) {
63
+ ROOT = config.root;
64
+ initUserConfig();
65
+ },
66
+ applyToEnvironment() {
67
+ return userConfig.verboseFileRoutes === false;
68
+ }
69
+ },
70
+ rspack() {
71
+ ROOT = process.cwd();
72
+ initUserConfig();
73
+ },
74
+ webpack() {
75
+ ROOT = process.cwd();
76
+ initUserConfig();
77
+ }
78
+ };
115
79
  };
80
+ //#endregion
116
81
  exports.unpluginRouteAutoImportFactory = unpluginRouteAutoImportFactory;
117
- //# sourceMappingURL=route-autoimport-plugin.cjs.map
82
+
83
+ //# sourceMappingURL=route-autoimport-plugin.cjs.map