@tanstack/router-plugin 1.167.0 → 1.167.2

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 (29) hide show
  1. package/dist/cjs/core/code-splitter/compilers.cjs +47 -25
  2. package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
  3. package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs +2 -1
  4. package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs.map +1 -1
  5. package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs +41 -0
  6. package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs.map +1 -0
  7. package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.cts +2 -0
  8. package/dist/cjs/core/code-splitter/plugins.d.cts +11 -0
  9. package/dist/cjs/core/code-splitter/types.d.cts +9 -0
  10. package/dist/cjs/core/utils.cjs +3 -1
  11. package/dist/cjs/core/utils.cjs.map +1 -1
  12. package/dist/esm/core/code-splitter/compilers.js +47 -25
  13. package/dist/esm/core/code-splitter/compilers.js.map +1 -1
  14. package/dist/esm/core/code-splitter/plugins/framework-plugins.js +2 -1
  15. package/dist/esm/core/code-splitter/plugins/framework-plugins.js.map +1 -1
  16. package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +2 -0
  17. package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +38 -0
  18. package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.js.map +1 -0
  19. package/dist/esm/core/code-splitter/plugins.d.ts +11 -0
  20. package/dist/esm/core/code-splitter/types.d.ts +9 -0
  21. package/dist/esm/core/utils.js +3 -1
  22. package/dist/esm/core/utils.js.map +1 -1
  23. package/package.json +4 -4
  24. package/src/core/code-splitter/compilers.ts +84 -50
  25. package/src/core/code-splitter/plugins/framework-plugins.ts +5 -1
  26. package/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts +56 -0
  27. package/src/core/code-splitter/plugins.ts +14 -0
  28. package/src/core/code-splitter/types.ts +11 -0
  29. package/src/core/utils.ts +9 -2
@@ -1 +1 @@
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
+ {"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 { createReactStableHmrSplitRouteComponentsPlugin } from './react-stable-hmr-split-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 [\n createReactRefreshRouteComponentsPlugin(),\n createReactStableHmrSplitRouteComponentsPlugin(),\n ]\n }\n return undefined\n }\n default:\n return undefined\n }\n}\n"],"mappings":";;;AAKA,SAAgB,iCAAiC,MAGG;AAClD,SAAQ,KAAK,iBAAb;EACE,KAAK;AACH,OAAI,KAAK,OACP,QAAO,CACL,uCAAA,yCAAyC,EACzC,gDAAA,gDAAgD,CACjD;AAEH;EAEF,QACE"}
@@ -0,0 +1,41 @@
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
+ let _babel_template = require("@babel/template");
6
+ _babel_template = require_runtime.__toESM(_babel_template);
7
+ //#region src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts
8
+ function capitalizeIdentifier(str) {
9
+ return str[0].toUpperCase() + str.slice(1);
10
+ }
11
+ function createHotDataKey(exportName) {
12
+ return `tsr-split-component:${exportName}`;
13
+ }
14
+ var buildStableSplitComponentStatements = _babel_template.statements(`
15
+ const %%stableComponentIdent%% = import.meta.hot?.data?.[%%hotDataKey%%] ?? %%lazyRouteComponentIdent%%(%%localImporterIdent%%, %%exporterIdent%%)
16
+ if (import.meta.hot) {
17
+ import.meta.hot.data[%%hotDataKey%%] = %%stableComponentIdent%%
18
+ }
19
+ `, { syntacticPlaceholders: true });
20
+ function createReactStableHmrSplitRouteComponentsPlugin() {
21
+ return {
22
+ name: "react-stable-hmr-split-route-components",
23
+ onSplitRouteProperty(ctx) {
24
+ if (ctx.splitNodeMeta.splitStrategy !== "lazyRouteComponent") return;
25
+ const stableComponentIdent = require_utils.getUniqueProgramIdentifier(ctx.programPath, `TSRSplit${capitalizeIdentifier(ctx.splitNodeMeta.exporterIdent)}`);
26
+ const hotDataKey = createHotDataKey(ctx.splitNodeMeta.exporterIdent);
27
+ ctx.insertionPath.insertBefore(buildStableSplitComponentStatements({
28
+ stableComponentIdent,
29
+ hotDataKey: _babel_types.stringLiteral(hotDataKey),
30
+ lazyRouteComponentIdent: _babel_types.identifier(ctx.lazyRouteComponentIdent),
31
+ localImporterIdent: _babel_types.identifier(ctx.splitNodeMeta.localImporterIdent),
32
+ exporterIdent: _babel_types.stringLiteral(ctx.splitNodeMeta.exporterIdent)
33
+ }));
34
+ return _babel_types.identifier(stableComponentIdent.name);
35
+ }
36
+ };
37
+ }
38
+ //#endregion
39
+ exports.createReactStableHmrSplitRouteComponentsPlugin = createReactStableHmrSplitRouteComponentsPlugin;
40
+
41
+ //# sourceMappingURL=react-stable-hmr-split-route-components.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-stable-hmr-split-route-components.cjs","names":[],"sources":["../../../../../src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts"],"sourcesContent":["import * as template from '@babel/template'\nimport * as t from '@babel/types'\nimport { getUniqueProgramIdentifier } from '../../utils'\nimport type { ReferenceRouteCompilerPlugin } from '../plugins'\n\nfunction capitalizeIdentifier(str: string) {\n return str[0]!.toUpperCase() + str.slice(1)\n}\n\nfunction createHotDataKey(exportName: string) {\n return `tsr-split-component:${exportName}`\n}\n\nconst buildStableSplitComponentStatements = template.statements(\n `\n const %%stableComponentIdent%% = import.meta.hot?.data?.[%%hotDataKey%%] ?? %%lazyRouteComponentIdent%%(%%localImporterIdent%%, %%exporterIdent%%)\n if (import.meta.hot) {\n import.meta.hot.data[%%hotDataKey%%] = %%stableComponentIdent%%\n }\n `,\n {\n syntacticPlaceholders: true,\n },\n)\n\nexport function createReactStableHmrSplitRouteComponentsPlugin(): ReferenceRouteCompilerPlugin {\n return {\n name: 'react-stable-hmr-split-route-components',\n onSplitRouteProperty(ctx) {\n if (ctx.splitNodeMeta.splitStrategy !== 'lazyRouteComponent') {\n return\n }\n\n const stableComponentIdent = getUniqueProgramIdentifier(\n ctx.programPath,\n `TSRSplit${capitalizeIdentifier(ctx.splitNodeMeta.exporterIdent)}`,\n )\n\n const hotDataKey = createHotDataKey(ctx.splitNodeMeta.exporterIdent)\n\n ctx.insertionPath.insertBefore(\n buildStableSplitComponentStatements({\n stableComponentIdent,\n hotDataKey: t.stringLiteral(hotDataKey),\n lazyRouteComponentIdent: t.identifier(ctx.lazyRouteComponentIdent),\n localImporterIdent: t.identifier(\n ctx.splitNodeMeta.localImporterIdent,\n ),\n exporterIdent: t.stringLiteral(ctx.splitNodeMeta.exporterIdent),\n }),\n )\n\n return t.identifier(stableComponentIdent.name)\n },\n }\n}\n"],"mappings":";;;;;;;AAKA,SAAS,qBAAqB,KAAa;AACzC,QAAO,IAAI,GAAI,aAAa,GAAG,IAAI,MAAM,EAAE;;AAG7C,SAAS,iBAAiB,YAAoB;AAC5C,QAAO,uBAAuB;;AAGhC,IAAM,sCAAsC,gBAAS,WACnD;;;;;KAMA,EACE,uBAAuB,MACxB,CACF;AAED,SAAgB,iDAA+E;AAC7F,QAAO;EACL,MAAM;EACN,qBAAqB,KAAK;AACxB,OAAI,IAAI,cAAc,kBAAkB,qBACtC;GAGF,MAAM,uBAAuB,cAAA,2BAC3B,IAAI,aACJ,WAAW,qBAAqB,IAAI,cAAc,cAAc,GACjE;GAED,MAAM,aAAa,iBAAiB,IAAI,cAAc,cAAc;AAEpE,OAAI,cAAc,aAChB,oCAAoC;IAClC;IACA,YAAY,aAAE,cAAc,WAAW;IACvC,yBAAyB,aAAE,WAAW,IAAI,wBAAwB;IAClE,oBAAoB,aAAE,WACpB,IAAI,cAAc,mBACnB;IACD,eAAe,aAAE,cAAc,IAAI,cAAc,cAAc;IAChE,CAAC,CACH;AAED,UAAO,aAAE,WAAW,qBAAqB,KAAK;;EAEjD"}
@@ -0,0 +1,2 @@
1
+ import { ReferenceRouteCompilerPlugin } from '../plugins.cjs';
2
+ export declare function createReactStableHmrSplitRouteComponentsPlugin(): ReferenceRouteCompilerPlugin;
@@ -1,6 +1,7 @@
1
1
  import { default as babel } from '@babel/core';
2
2
  import { Config, DeletableNodes } from '../config.cjs';
3
3
  import { CodeSplitGroupings } from '../constants.cjs';
4
+ import { SplitNodeMeta } from './types.cjs';
4
5
  import type * as t from '@babel/types';
5
6
  export type CompileCodeSplitReferenceRouteOptions = {
6
7
  codeSplitGroupings: CodeSplitGroupings;
@@ -19,10 +20,20 @@ export type ReferenceRouteCompilerPluginContext = {
19
20
  createRouteFn: string;
20
21
  opts: CompileCodeSplitReferenceRouteOptions;
21
22
  };
23
+ export type ReferenceRouteSplitPropertyCompilerPluginContext = {
24
+ programPath: babel.NodePath<t.Program>;
25
+ callExpressionPath: babel.NodePath<t.CallExpression>;
26
+ insertionPath: babel.NodePath;
27
+ routeOptions: t.ObjectExpression;
28
+ prop: t.ObjectProperty;
29
+ splitNodeMeta: SplitNodeMeta;
30
+ lazyRouteComponentIdent: string;
31
+ };
22
32
  export type ReferenceRouteCompilerPluginResult = {
23
33
  modified?: boolean;
24
34
  };
25
35
  export type ReferenceRouteCompilerPlugin = {
26
36
  name: string;
27
37
  onUnsplittableRoute?: (ctx: ReferenceRouteCompilerPluginContext) => void | ReferenceRouteCompilerPluginResult;
38
+ onSplitRouteProperty?: (ctx: ReferenceRouteSplitPropertyCompilerPluginContext) => void | t.Expression;
28
39
  };
@@ -0,0 +1,9 @@
1
+ import { SplitRouteIdentNodes } from '../constants.cjs';
2
+ export type SplitStrategy = 'lazyFn' | 'lazyRouteComponent';
3
+ export type SplitNodeMeta = {
4
+ routeIdent: SplitRouteIdentNodes;
5
+ splitStrategy: SplitStrategy;
6
+ localImporterIdent: string;
7
+ exporterIdent: string;
8
+ localExporterIdent: string;
9
+ };
@@ -16,10 +16,12 @@ function normalizePath(path) {
16
16
  function getUniqueProgramIdentifier(programPath, baseName) {
17
17
  let name = baseName;
18
18
  let suffix = 2;
19
- while (programPath.scope.hasBinding(name) || programPath.scope.hasGlobal(name)) {
19
+ const programScope = programPath.scope.getProgramParent();
20
+ while (programScope.hasBinding(name) || programScope.hasGlobal(name) || programScope.hasReference(name)) {
20
21
  name = `${baseName}${suffix}`;
21
22
  suffix++;
22
23
  }
24
+ programScope.references[name] = true;
23
25
  return _babel_types.identifier(name);
24
26
  }
25
27
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/core/utils.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport type babel from '@babel/core'\n\nexport const debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\n/**\n * Normalizes a file path by converting Windows backslashes to forward slashes.\n * This ensures consistent path handling across different bundlers and operating systems.\n *\n * The route generator stores paths with forward slashes, but rspack/webpack on Windows\n * pass native paths with backslashes to transform handlers.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nexport function getUniqueProgramIdentifier(\n programPath: babel.NodePath<t.Program>,\n baseName: string,\n): t.Identifier {\n let name = baseName\n let suffix = 2\n\n while (\n programPath.scope.hasBinding(name) ||\n programPath.scope.hasGlobal(name)\n ) {\n name = `${baseName}${suffix}`\n suffix++\n }\n\n return t.identifier(name)\n}\n"],"mappings":";;;;AAGA,IAAa,QACX,QAAQ,IAAI,kBACZ,CAAC,QAAQ,gBAAgB,CAAC,SAAS,QAAQ,IAAI,eAAe;;;;;;;;AAShE,SAAgB,cAAc,MAAsB;AAClD,QAAO,KAAK,QAAQ,OAAO,IAAI;;AAGjC,SAAgB,2BACd,aACA,UACc;CACd,IAAI,OAAO;CACX,IAAI,SAAS;AAEb,QACE,YAAY,MAAM,WAAW,KAAK,IAClC,YAAY,MAAM,UAAU,KAAK,EACjC;AACA,SAAO,GAAG,WAAW;AACrB;;AAGF,QAAO,aAAE,WAAW,KAAK"}
1
+ {"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/core/utils.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport type babel from '@babel/core'\n\nexport const debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\n/**\n * Normalizes a file path by converting Windows backslashes to forward slashes.\n * This ensures consistent path handling across different bundlers and operating systems.\n *\n * The route generator stores paths with forward slashes, but rspack/webpack on Windows\n * pass native paths with backslashes to transform handlers.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nexport function getUniqueProgramIdentifier(\n programPath: babel.NodePath<t.Program>,\n baseName: string,\n): t.Identifier {\n let name = baseName\n let suffix = 2\n\n const programScope = programPath.scope.getProgramParent()\n\n while (\n programScope.hasBinding(name) ||\n programScope.hasGlobal(name) ||\n programScope.hasReference(name)\n ) {\n name = `${baseName}${suffix}`\n suffix++\n }\n\n // Register the name so subsequent calls within the same traversal\n // see it and avoid collisions\n programScope.references[name] = true\n\n return t.identifier(name)\n}\n"],"mappings":";;;;AAGA,IAAa,QACX,QAAQ,IAAI,kBACZ,CAAC,QAAQ,gBAAgB,CAAC,SAAS,QAAQ,IAAI,eAAe;;;;;;;;AAShE,SAAgB,cAAc,MAAsB;AAClD,QAAO,KAAK,QAAQ,OAAO,IAAI;;AAGjC,SAAgB,2BACd,aACA,UACc;CACd,IAAI,OAAO;CACX,IAAI,SAAS;CAEb,MAAM,eAAe,YAAY,MAAM,kBAAkB;AAEzD,QACE,aAAa,WAAW,KAAK,IAC7B,aAAa,UAAU,KAAK,IAC5B,aAAa,aAAa,KAAK,EAC/B;AACA,SAAO,GAAG,WAAW;AACrB;;AAKF,cAAa,WAAW,QAAQ;AAEhC,QAAO,aAAE,WAAW,KAAK"}
@@ -96,6 +96,10 @@ function collectIdentifiersFromNode(node) {
96
96
  })(node);
97
97
  return ids;
98
98
  }
99
+ function getObjectPropertyKeyName(prop) {
100
+ if (t.isIdentifier(prop.key)) return prop.key.name;
101
+ if (t.isStringLiteral(prop.key)) return prop.key.value;
102
+ }
99
103
  /**
100
104
  * Build a map from binding name → declaration AST node for all
101
105
  * locally-declared module-level bindings. Built once, O(1) lookup.
@@ -162,10 +166,12 @@ function computeSharedBindings(opts) {
162
166
  const splitGroupsPresent = /* @__PURE__ */ new Set();
163
167
  let hasNonSplit = false;
164
168
  for (const prop of routeOptions.properties) {
165
- if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) continue;
166
- if (prop.key.name === "codeSplitGroupings") continue;
169
+ if (!t.isObjectProperty(prop)) continue;
170
+ const key = getObjectPropertyKeyName(prop);
171
+ if (!key) continue;
172
+ if (key === "codeSplitGroupings") continue;
167
173
  if (t.isIdentifier(prop.value) && prop.value.name === "undefined") continue;
168
- const groupIndex = findIndexForSplitNode(prop.key.name);
174
+ const groupIndex = findIndexForSplitNode(key);
169
175
  if (groupIndex === -1) hasNonSplit = true;
170
176
  else splitGroupsPresent.add(groupIndex);
171
177
  }
@@ -177,8 +183,9 @@ function computeSharedBindings(opts) {
177
183
  const fullDepGraph = buildDependencyGraph(declMap, allLocalBindings);
178
184
  const refsByGroup = /* @__PURE__ */ new Map();
179
185
  for (const prop of routeOptions.properties) {
180
- if (!t.isObjectProperty(prop) || !t.isIdentifier(prop.key)) continue;
181
- const key = prop.key.name;
186
+ if (!t.isObjectProperty(prop)) continue;
187
+ const key = getObjectPropertyKeyName(prop);
188
+ if (!key) continue;
182
189
  if (key === "codeSplitGroupings") continue;
183
190
  const groupIndex = findIndexForSplitNode(key);
184
191
  const directRefs = collectModuleLevelRefsFromNode(prop.value, localModuleLevelBindings);
@@ -384,11 +391,10 @@ function compileCodeSplitReferenceRoute(opts) {
384
391
  if (t.isObjectExpression(routeOptions)) {
385
392
  if (opts.deleteNodes && opts.deleteNodes.size > 0) routeOptions.properties = routeOptions.properties.filter((prop) => {
386
393
  if (t.isObjectProperty(prop)) {
387
- if (t.isIdentifier(prop.key)) {
388
- if (opts.deleteNodes.has(prop.key.name)) {
389
- modified = true;
390
- return false;
391
- }
394
+ const key = getObjectPropertyKeyName(prop);
395
+ if (key && opts.deleteNodes.has(key)) {
396
+ modified = true;
397
+ return false;
392
398
  }
393
399
  }
394
400
  return true;
@@ -414,8 +420,8 @@ function compileCodeSplitReferenceRoute(opts) {
414
420
  }
415
421
  routeOptions.properties.forEach((prop) => {
416
422
  if (t.isObjectProperty(prop)) {
417
- if (t.isIdentifier(prop.key)) {
418
- const key = prop.key.name;
423
+ const key = getObjectPropertyKeyName(prop);
424
+ if (key) {
419
425
  const codeSplitGroupingByKey = findIndexForSplitNode(key);
420
426
  if (codeSplitGroupingByKey === -1) return;
421
427
  const codeSplitGroup = [...new Set(opts.codeSplitGroupings[codeSplitGroupingByKey])];
@@ -438,7 +444,25 @@ function compileCodeSplitReferenceRoute(opts) {
438
444
  modified = true;
439
445
  if (!hasImportedOrDefinedIdentifier(LAZY_ROUTE_COMPONENT_IDENT)) programPath.unshiftContainer("body", [template.statement(`import { ${LAZY_ROUTE_COMPONENT_IDENT} } from '${PACKAGE}'`)()]);
440
446
  if (!hasImportedOrDefinedIdentifier(splitNodeMeta.localImporterIdent)) programPath.unshiftContainer("body", [template.statement(`const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`)()]);
441
- prop.value = template.expression(`${LAZY_ROUTE_COMPONENT_IDENT}(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`)();
447
+ const insertionPath = path.getStatementParent() ?? path;
448
+ let splitPropValue;
449
+ for (const plugin of opts.compilerPlugins ?? []) {
450
+ const pluginPropValue = plugin.onSplitRouteProperty?.({
451
+ programPath,
452
+ callExpressionPath: path,
453
+ insertionPath,
454
+ routeOptions,
455
+ prop,
456
+ splitNodeMeta,
457
+ lazyRouteComponentIdent: LAZY_ROUTE_COMPONENT_IDENT
458
+ });
459
+ if (!pluginPropValue) continue;
460
+ modified = true;
461
+ splitPropValue = pluginPropValue;
462
+ break;
463
+ }
464
+ if (splitPropValue) prop.value = splitPropValue;
465
+ else prop.value = template.expression(`${LAZY_ROUTE_COMPONENT_IDENT}(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`)();
442
466
  if (opts.addHmr && !hmrAdded) {
443
467
  programPath.pushContainer("body", routeHmrStatement);
444
468
  modified = true;
@@ -540,7 +564,7 @@ function compileCodeSplitVirtualRoute(opts) {
540
564
  if (t.isObjectExpression(options)) {
541
565
  options.properties.forEach((prop) => {
542
566
  if (t.isObjectProperty(prop)) KNOWN_SPLIT_ROUTE_IDENTS.forEach((splitType) => {
543
- if (!t.isIdentifier(prop.key) || prop.key.name !== splitType) return;
567
+ if (getObjectPropertyKeyName(prop) !== splitType) return;
544
568
  const value = prop.value;
545
569
  if (t.isIdentifier(value) && value.name === "undefined") return;
546
570
  let isExported = false;
@@ -734,18 +758,16 @@ function detectCodeSplitGroupingsFromRoute(opts) {
734
758
  function babelHandleSplittingGroups(routeOptions) {
735
759
  if (t.isObjectExpression(routeOptions)) routeOptions.properties.forEach((prop) => {
736
760
  if (t.isObjectProperty(prop)) {
737
- if (t.isIdentifier(prop.key)) {
738
- if (prop.key.name === "codeSplitGroupings") {
739
- const value = prop.value;
740
- if (t.isArrayExpression(value)) codeSplitGroupings = value.elements.map((group) => {
741
- if (t.isArrayExpression(group)) return group.elements.map((node) => {
742
- if (!t.isStringLiteral(node)) throw new Error("You must provide a string literal for the codeSplitGroupings");
743
- return node.value;
744
- });
745
- throw new Error("You must provide arrays with codeSplitGroupings options.");
761
+ if (getObjectPropertyKeyName(prop) === "codeSplitGroupings") {
762
+ const value = prop.value;
763
+ if (t.isArrayExpression(value)) codeSplitGroupings = value.elements.map((group) => {
764
+ if (t.isArrayExpression(group)) return group.elements.map((node) => {
765
+ if (!t.isStringLiteral(node)) throw new Error("You must provide a string literal for the codeSplitGroupings");
766
+ return node.value;
746
767
  });
747
- else throw new Error("You must provide an array of arrays for the codeSplitGroupings.");
748
- }
768
+ throw new Error("You must provide arrays with codeSplitGroupings options.");
769
+ });
770
+ else throw new Error("You must provide an array of arrays for the codeSplitGroupings.");
749
771
  }
750
772
  }
751
773
  });