@tanstack/router-plugin 1.98.0 → 1.98.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.
- package/dist/cjs/core/code-splitter/compilers.cjs +122 -68
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
- package/dist/esm/core/code-splitter/compilers.js +122 -68
- package/dist/esm/core/code-splitter/compilers.js.map +1 -1
- package/package.json +3 -3
- package/src/core/code-splitter/compilers.ts +154 -85
|
@@ -18,6 +18,35 @@ function removeSplitSearchParamFromFilename(filename) {
|
|
|
18
18
|
const [bareFilename] = filename.split("?");
|
|
19
19
|
return bareFilename;
|
|
20
20
|
}
|
|
21
|
+
const SPLIT_NOES_CONFIG = /* @__PURE__ */ new Map([
|
|
22
|
+
[
|
|
23
|
+
"component",
|
|
24
|
+
{
|
|
25
|
+
routeIdent: "component",
|
|
26
|
+
localImporterIdent: "$$splitComponentImporter",
|
|
27
|
+
// const $$splitComponentImporter = () => import('...')
|
|
28
|
+
splitStrategy: "react-component",
|
|
29
|
+
localExporterIdent: "SplitComponent",
|
|
30
|
+
// const SplitComponent = ...
|
|
31
|
+
exporterIdent: "component"
|
|
32
|
+
// export { SplitComponent as component }
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
[
|
|
36
|
+
"loader",
|
|
37
|
+
{
|
|
38
|
+
routeIdent: "loader",
|
|
39
|
+
localImporterIdent: "$$splitLoaderImporter",
|
|
40
|
+
// const $$splitLoaderImporter = () => import('...')
|
|
41
|
+
splitStrategy: "normal",
|
|
42
|
+
localExporterIdent: "SplitLoader",
|
|
43
|
+
// const SplitLoader = ...
|
|
44
|
+
exporterIdent: "loader"
|
|
45
|
+
// export { SplitLoader as loader }
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
]);
|
|
49
|
+
const SPLIT_ROUTE_IDENT_NODES = [...SPLIT_NOES_CONFIG.keys()];
|
|
21
50
|
function compileCodeSplitReferenceRoute(opts) {
|
|
22
51
|
const ast = parseAst(opts);
|
|
23
52
|
babel.traverse(ast, {
|
|
@@ -41,7 +70,6 @@ function compileCodeSplitReferenceRoute(opts) {
|
|
|
41
70
|
path,
|
|
42
71
|
path.parentPath.node.arguments[0]
|
|
43
72
|
);
|
|
44
|
-
let found = false;
|
|
45
73
|
const hasImportedOrDefinedIdentifier = (name) => {
|
|
46
74
|
return programPath.scope.hasBinding(name);
|
|
47
75
|
};
|
|
@@ -49,7 +77,15 @@ function compileCodeSplitReferenceRoute(opts) {
|
|
|
49
77
|
options.properties.forEach((prop) => {
|
|
50
78
|
if (t.isObjectProperty(prop)) {
|
|
51
79
|
if (t.isIdentifier(prop.key)) {
|
|
52
|
-
|
|
80
|
+
const key = prop.key.name;
|
|
81
|
+
const isNodeConfigAvailable = SPLIT_NOES_CONFIG.has(
|
|
82
|
+
key
|
|
83
|
+
);
|
|
84
|
+
if (!isNodeConfigAvailable) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const splitNodeMeta = SPLIT_NOES_CONFIG.get(key);
|
|
88
|
+
if (splitNodeMeta.splitStrategy === "react-component") {
|
|
53
89
|
const value = prop.value;
|
|
54
90
|
let shouldSplit = true;
|
|
55
91
|
if (t.isIdentifier(value)) {
|
|
@@ -63,36 +99,45 @@ function compileCodeSplitReferenceRoute(opts) {
|
|
|
63
99
|
removeIdentifierLiteral(path, value);
|
|
64
100
|
}
|
|
65
101
|
}
|
|
66
|
-
if (shouldSplit) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
if (!shouldSplit) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!hasImportedOrDefinedIdentifier(
|
|
106
|
+
"lazyRouteComponent"
|
|
107
|
+
)) {
|
|
108
|
+
programPath.unshiftContainer("body", [
|
|
109
|
+
template.statement(
|
|
110
|
+
`import { lazyRouteComponent } from '@tanstack/react-router'`
|
|
111
|
+
)()
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
if (!hasImportedOrDefinedIdentifier(
|
|
115
|
+
splitNodeMeta.localImporterIdent
|
|
116
|
+
)) {
|
|
117
|
+
programPath.unshiftContainer("body", [
|
|
118
|
+
template.statement(
|
|
119
|
+
`const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`
|
|
120
|
+
)()
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
if (key === "component") {
|
|
124
|
+
prop.value = template.expression(
|
|
125
|
+
`lazyRouteComponent(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}', () => Route.ssr)`
|
|
126
|
+
)();
|
|
127
|
+
} else {
|
|
85
128
|
prop.value = template.expression(
|
|
86
|
-
`lazyRouteComponent(
|
|
129
|
+
`lazyRouteComponent(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`
|
|
87
130
|
)();
|
|
131
|
+
}
|
|
132
|
+
if (!hasImportedOrDefinedIdentifier("TSRDummyComponent")) {
|
|
88
133
|
programPath.pushContainer("body", [
|
|
89
134
|
template.statement(
|
|
90
|
-
`function
|
|
135
|
+
`export function TSRDummyComponent() { return null }`
|
|
91
136
|
)()
|
|
92
137
|
]);
|
|
93
|
-
found = true;
|
|
94
138
|
}
|
|
95
|
-
}
|
|
139
|
+
}
|
|
140
|
+
if (splitNodeMeta.splitStrategy === "normal") {
|
|
96
141
|
const value = prop.value;
|
|
97
142
|
let shouldSplit = true;
|
|
98
143
|
if (t.isIdentifier(value)) {
|
|
@@ -106,39 +151,35 @@ function compileCodeSplitReferenceRoute(opts) {
|
|
|
106
151
|
removeIdentifierLiteral(path, value);
|
|
107
152
|
}
|
|
108
153
|
}
|
|
109
|
-
if (shouldSplit) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
)) {
|
|
120
|
-
programPath.unshiftContainer("body", [
|
|
121
|
-
template.statement(
|
|
122
|
-
`const $$splitLoaderImporter = () => import('${splitUrl}')`
|
|
123
|
-
)()
|
|
124
|
-
]);
|
|
125
|
-
}
|
|
126
|
-
prop.value = template.expression(
|
|
127
|
-
`lazyFn($$splitLoaderImporter, 'loader')`
|
|
128
|
-
)();
|
|
129
|
-
found = true;
|
|
154
|
+
if (!shouldSplit) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!hasImportedOrDefinedIdentifier("lazyFn")) {
|
|
158
|
+
programPath.unshiftContainer(
|
|
159
|
+
"body",
|
|
160
|
+
template.smart(
|
|
161
|
+
`import { lazyFn } from '@tanstack/react-router'`
|
|
162
|
+
)()
|
|
163
|
+
);
|
|
130
164
|
}
|
|
165
|
+
if (!hasImportedOrDefinedIdentifier(
|
|
166
|
+
splitNodeMeta.localImporterIdent
|
|
167
|
+
)) {
|
|
168
|
+
programPath.unshiftContainer("body", [
|
|
169
|
+
template.statement(
|
|
170
|
+
`const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`
|
|
171
|
+
)()
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
prop.value = template.expression(
|
|
175
|
+
`lazyFn(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`
|
|
176
|
+
)();
|
|
131
177
|
}
|
|
132
178
|
}
|
|
133
179
|
}
|
|
134
180
|
programPath.scope.crawl();
|
|
135
181
|
});
|
|
136
182
|
}
|
|
137
|
-
if (found) {
|
|
138
|
-
programPath.pushContainer("body", [
|
|
139
|
-
template.statement(`function TSR_Dummy_Component() {}`)()
|
|
140
|
-
]);
|
|
141
|
-
}
|
|
142
183
|
}
|
|
143
184
|
}
|
|
144
185
|
},
|
|
@@ -163,7 +204,6 @@ function compileCodeSplitReferenceRoute(opts) {
|
|
|
163
204
|
sourceFileName: opts.filename
|
|
164
205
|
});
|
|
165
206
|
}
|
|
166
|
-
const splitNodeTypes = ["component", "loader"];
|
|
167
207
|
function compileCodeSplitVirtualRoute(opts) {
|
|
168
208
|
const ast = parseAst(opts);
|
|
169
209
|
const knownExportedIdents = /* @__PURE__ */ new Set();
|
|
@@ -171,7 +211,7 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
171
211
|
Program: {
|
|
172
212
|
enter(programPath, programState) {
|
|
173
213
|
const state = programState;
|
|
174
|
-
const
|
|
214
|
+
const trackedNodesToSplitByType = {
|
|
175
215
|
component: void 0,
|
|
176
216
|
loader: void 0
|
|
177
217
|
};
|
|
@@ -192,7 +232,7 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
192
232
|
if (t.isObjectExpression(options)) {
|
|
193
233
|
options.properties.forEach((prop) => {
|
|
194
234
|
if (t.isObjectProperty(prop)) {
|
|
195
|
-
|
|
235
|
+
SPLIT_ROUTE_IDENT_NODES.forEach((splitType) => {
|
|
196
236
|
if (!t.isIdentifier(prop.key) || prop.key.name !== splitType) {
|
|
197
237
|
return;
|
|
198
238
|
}
|
|
@@ -207,7 +247,11 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
207
247
|
if (isExported && t.isIdentifier(value)) {
|
|
208
248
|
removeExports(ast, value);
|
|
209
249
|
} else {
|
|
210
|
-
|
|
250
|
+
const meta = SPLIT_NOES_CONFIG.get(splitType);
|
|
251
|
+
trackedNodesToSplitByType[splitType] = {
|
|
252
|
+
node: prop.value,
|
|
253
|
+
meta
|
|
254
|
+
};
|
|
211
255
|
}
|
|
212
256
|
});
|
|
213
257
|
}
|
|
@@ -219,11 +263,13 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
219
263
|
},
|
|
220
264
|
state
|
|
221
265
|
);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (!
|
|
266
|
+
SPLIT_ROUTE_IDENT_NODES.forEach((SPLIT_TYPE) => {
|
|
267
|
+
const splitKey = trackedNodesToSplitByType[SPLIT_TYPE];
|
|
268
|
+
if (!splitKey) {
|
|
225
269
|
return;
|
|
226
270
|
}
|
|
271
|
+
let splitNode = splitKey.node;
|
|
272
|
+
const splitMeta = splitKey.meta;
|
|
227
273
|
while (t.isIdentifier(splitNode)) {
|
|
228
274
|
const binding = programPath.scope.getBinding(splitNode.name);
|
|
229
275
|
splitNode = binding == null ? void 0 : binding.path.node;
|
|
@@ -234,7 +280,7 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
234
280
|
"body",
|
|
235
281
|
t.variableDeclaration("const", [
|
|
236
282
|
t.variableDeclarator(
|
|
237
|
-
t.identifier(
|
|
283
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
238
284
|
t.functionExpression(
|
|
239
285
|
splitNode.id || null,
|
|
240
286
|
// Anonymize the function expression
|
|
@@ -251,7 +297,7 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
251
297
|
"body",
|
|
252
298
|
t.variableDeclaration("const", [
|
|
253
299
|
t.variableDeclarator(
|
|
254
|
-
t.identifier(
|
|
300
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
255
301
|
splitNode
|
|
256
302
|
)
|
|
257
303
|
])
|
|
@@ -261,7 +307,7 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
261
307
|
"body",
|
|
262
308
|
t.variableDeclaration("const", [
|
|
263
309
|
t.variableDeclarator(
|
|
264
|
-
t.identifier(
|
|
310
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
265
311
|
splitNode.local
|
|
266
312
|
)
|
|
267
313
|
])
|
|
@@ -270,7 +316,10 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
270
316
|
programPath.pushContainer(
|
|
271
317
|
"body",
|
|
272
318
|
t.variableDeclaration("const", [
|
|
273
|
-
t.variableDeclarator(
|
|
319
|
+
t.variableDeclarator(
|
|
320
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
321
|
+
splitNode.init
|
|
322
|
+
)
|
|
274
323
|
])
|
|
275
324
|
);
|
|
276
325
|
} else if (t.isCallExpression(splitNode)) {
|
|
@@ -278,13 +327,13 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
278
327
|
const splitNodeAst = babel.parse(outputSplitNodeCode);
|
|
279
328
|
if (!splitNodeAst) {
|
|
280
329
|
throw new Error(
|
|
281
|
-
`Failed to parse the generated code for "${
|
|
330
|
+
`Failed to parse the generated code for "${SPLIT_TYPE}" in the node type "${splitNode.type}"`
|
|
282
331
|
);
|
|
283
332
|
}
|
|
284
333
|
const statement = splitNodeAst.program.body[0];
|
|
285
334
|
if (!statement) {
|
|
286
335
|
throw new Error(
|
|
287
|
-
`Failed to parse the generated code for "${
|
|
336
|
+
`Failed to parse the generated code for "${SPLIT_TYPE}" in the node type "${splitNode.type}" as no statement was found in the program body`
|
|
288
337
|
);
|
|
289
338
|
}
|
|
290
339
|
if (t.isExpressionStatement(statement)) {
|
|
@@ -292,12 +341,15 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
292
341
|
programPath.pushContainer(
|
|
293
342
|
"body",
|
|
294
343
|
t.variableDeclaration("const", [
|
|
295
|
-
t.variableDeclarator(
|
|
344
|
+
t.variableDeclarator(
|
|
345
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
346
|
+
expression
|
|
347
|
+
)
|
|
296
348
|
])
|
|
297
349
|
);
|
|
298
350
|
} else {
|
|
299
351
|
throw new Error(
|
|
300
|
-
`Unexpected expression type encounter for "${
|
|
352
|
+
`Unexpected expression type encounter for "${SPLIT_TYPE}" in the node type "${splitNode.type}"`
|
|
301
353
|
);
|
|
302
354
|
}
|
|
303
355
|
} else {
|
|
@@ -311,8 +363,10 @@ function compileCodeSplitVirtualRoute(opts) {
|
|
|
311
363
|
programPath.pushContainer("body", [
|
|
312
364
|
t.exportNamedDeclaration(null, [
|
|
313
365
|
t.exportSpecifier(
|
|
314
|
-
t.identifier(
|
|
315
|
-
|
|
366
|
+
t.identifier(splitMeta.localExporterIdent),
|
|
367
|
+
// local variable name
|
|
368
|
+
t.identifier(splitMeta.exporterIdent)
|
|
369
|
+
// as what name it should be exported as
|
|
316
370
|
)
|
|
317
371
|
])
|
|
318
372
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilers.js","sources":["../../../../src/core/code-splitter/compilers.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport babel from '@babel/core'\nimport _generate from '@babel/generator'\nimport * as template from '@babel/template'\nimport { deadCodeElimination } from 'babel-dead-code-elimination'\n\nimport { splitPrefix } from '../constants'\nimport { parseAst } from './ast'\nimport type { ParseAstOptions } from './ast'\n\nconst debug = process.env.TSR_VITE_DEBUG\n\n// Babel is a CJS package and uses `default` as named binding (`exports.default =`).\n// https://github.com/babel/babel/issues/15269.\nlet generate = (_generate as any)['default'] as typeof _generate\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif (!generate) {\n generate = _generate\n}\n\ntype SplitModulesById = Record<\n string,\n { id: string; node: t.FunctionExpression }\n>\n\ninterface State {\n filename: string\n opts: {\n minify: boolean\n root: string\n }\n imported: Record<string, boolean>\n refs: Set<any>\n serverIndex: number\n splitIndex: number\n splitModulesById: SplitModulesById\n}\n\nfunction addSplitSearchParamToFilename(filename: string) {\n const [bareFilename] = filename.split('?')\n return `${bareFilename}?${splitPrefix}`\n}\n\nfunction removeSplitSearchParamFromFilename(filename: string) {\n const [bareFilename] = filename.split('?')\n return bareFilename!\n}\n\nexport function compileCodeSplitReferenceRoute(opts: ParseAstOptions) {\n const ast = parseAst(opts)\n\n babel.traverse(ast, {\n Program: {\n enter(programPath, programState) {\n const state = programState as unknown as State\n\n // We need to extract the existing search params from the filename, if any\n // and add the splitPrefix to them, then write them back to the filename\n const splitUrl = addSplitSearchParamToFilename(opts.filename)\n\n /**\n * If the component for the route is being imported from\n * another file, this is to track the path to that file\n * the path itself doesn't matter, we just need to keep\n * track of it so that we can remove it from the imports\n * list if it's not being used like:\n *\n * `import '../shared/imported'`\n */\n let existingCompImportPath: string | null = null\n let existingLoaderImportPath: string | null = null\n\n programPath.traverse(\n {\n CallExpression: (path) => {\n if (!t.isIdentifier(path.node.callee)) {\n return\n }\n\n if (\n !(\n path.node.callee.name === 'createRoute' ||\n path.node.callee.name === 'createFileRoute'\n )\n ) {\n return\n }\n\n if (t.isCallExpression(path.parentPath.node)) {\n const options = resolveIdentifier(\n path,\n path.parentPath.node.arguments[0],\n )\n\n let found = false\n\n const hasImportedOrDefinedIdentifier = (name: string) => {\n return programPath.scope.hasBinding(name)\n }\n\n if (t.isObjectExpression(options)) {\n options.properties.forEach((prop) => {\n if (t.isObjectProperty(prop)) {\n if (t.isIdentifier(prop.key)) {\n if (prop.key.name === 'component') {\n const value = prop.value\n\n let shouldSplit = true\n\n if (t.isIdentifier(value)) {\n existingCompImportPath =\n getImportSpecifierAndPathFromLocalName(\n programPath,\n value.name,\n ).path\n\n // exported identifiers should not be split\n // since they are already being imported\n // and need to be retained in the compiled file\n const isExported = hasExport(ast, value)\n shouldSplit = !isExported\n\n if (shouldSplit) {\n removeIdentifierLiteral(path, value)\n }\n }\n\n if (shouldSplit) {\n // Prepend the import statement to the program along with the importer function\n // Check to see if lazyRouteComponent is already imported before attempting\n // to import it again\n\n if (\n !hasImportedOrDefinedIdentifier(\n 'lazyRouteComponent',\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `import { lazyRouteComponent } from '@tanstack/react-router'`,\n )(),\n ])\n }\n\n if (\n !hasImportedOrDefinedIdentifier(\n '$$splitComponentImporter',\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `const $$splitComponentImporter = () => import('${splitUrl}')`,\n )(),\n ])\n }\n\n prop.value = template.expression(\n `lazyRouteComponent($$splitComponentImporter, 'component', () => Route.ssr)`,\n )()\n\n programPath.pushContainer('body', [\n template.statement(\n `function DummyComponent() { return null }`,\n )(),\n ])\n\n found = true\n }\n } else if (prop.key.name === 'loader') {\n const value = prop.value\n\n let shouldSplit = true\n\n if (t.isIdentifier(value)) {\n existingLoaderImportPath =\n getImportSpecifierAndPathFromLocalName(\n programPath,\n value.name,\n ).path\n\n // exported identifiers should not be split\n // since they are already being imported\n // and need to be retained in the compiled file\n const isExported = hasExport(ast, value)\n shouldSplit = !isExported\n\n if (shouldSplit) {\n removeIdentifierLiteral(path, value)\n }\n }\n\n if (shouldSplit) {\n // Prepend the import statement to the program along with the importer function\n if (!hasImportedOrDefinedIdentifier('lazyFn')) {\n programPath.unshiftContainer('body', [\n template.smart(\n `import { lazyFn } from '@tanstack/react-router'`,\n )() as t.Statement,\n ])\n }\n\n if (\n !hasImportedOrDefinedIdentifier(\n '$$splitLoaderImporter',\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `const $$splitLoaderImporter = () => import('${splitUrl}')`,\n )(),\n ])\n }\n\n prop.value = template.expression(\n `lazyFn($$splitLoaderImporter, 'loader')`,\n )()\n\n found = true\n }\n }\n }\n }\n\n programPath.scope.crawl()\n })\n }\n\n if (found as boolean) {\n programPath.pushContainer('body', [\n template.statement(`function TSR_Dummy_Component() {}`)(),\n ])\n }\n }\n },\n },\n state,\n )\n\n /**\n * If the component for the route is being imported,\n * and it's not being used, remove the import statement\n * from the program, by checking that the import has no\n * specifiers\n */\n if (\n (existingCompImportPath as string | null) ||\n (existingLoaderImportPath as string | null)\n ) {\n programPath.traverse({\n ImportDeclaration(path) {\n if (path.node.specifiers.length > 0) return\n if (\n path.node.source.value === existingCompImportPath ||\n path.node.source.value === existingLoaderImportPath\n ) {\n path.remove()\n }\n },\n })\n }\n },\n },\n })\n\n deadCodeElimination(ast)\n\n return generate(ast, {\n sourceMaps: true,\n sourceFileName: opts.filename,\n })\n}\n\nconst splitNodeTypes = ['component', 'loader'] as const\ntype SplitNodeType = (typeof splitNodeTypes)[number]\n\nexport function compileCodeSplitVirtualRoute(opts: ParseAstOptions) {\n const ast = parseAst(opts)\n\n const knownExportedIdents = new Set<string>()\n\n babel.traverse(ast, {\n Program: {\n enter(programPath, programState) {\n const state = programState as unknown as State\n\n const splitNodesByType: Record<SplitNodeType, t.Node | undefined> = {\n component: undefined,\n loader: undefined,\n }\n\n // Find the node\n programPath.traverse(\n {\n CallExpression: (path) => {\n if (!t.isIdentifier(path.node.callee)) {\n return\n }\n\n if (\n !(\n path.node.callee.name === 'createRoute' ||\n path.node.callee.name === 'createFileRoute'\n )\n ) {\n return\n }\n\n if (t.isCallExpression(path.parentPath.node)) {\n const options = resolveIdentifier(\n path,\n path.parentPath.node.arguments[0],\n )\n\n if (t.isObjectExpression(options)) {\n options.properties.forEach((prop) => {\n if (t.isObjectProperty(prop)) {\n splitNodeTypes.forEach((splitType) => {\n if (\n !t.isIdentifier(prop.key) ||\n prop.key.name !== splitType\n ) {\n return\n }\n\n const value = prop.value\n\n let isExported = false\n if (t.isIdentifier(value)) {\n isExported = hasExport(ast, value)\n if (isExported) {\n knownExportedIdents.add(value.name)\n }\n }\n\n // If the node is exported, we need to remove\n // the export from the split file\n if (isExported && t.isIdentifier(value)) {\n removeExports(ast, value)\n } else {\n splitNodesByType[splitType] = prop.value\n }\n })\n }\n })\n\n // Remove all of the options\n options.properties = []\n }\n }\n },\n },\n state,\n )\n\n splitNodeTypes.forEach((splitType) => {\n let splitNode = splitNodesByType[splitType]\n\n if (!splitNode) {\n return\n }\n\n while (t.isIdentifier(splitNode)) {\n const binding = programPath.scope.getBinding(splitNode.name)\n splitNode = binding?.path.node\n }\n\n // Add the node to the program\n if (splitNode) {\n if (t.isFunctionDeclaration(splitNode)) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitType),\n t.functionExpression(\n splitNode.id || null, // Anonymize the function expression\n splitNode.params,\n splitNode.body,\n splitNode.generator,\n splitNode.async,\n ),\n ),\n ]),\n )\n } else if (\n t.isFunctionExpression(splitNode) ||\n t.isArrowFunctionExpression(splitNode)\n ) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitType),\n splitNode as any,\n ),\n ]),\n )\n } else if (\n t.isImportSpecifier(splitNode) ||\n t.isImportDefaultSpecifier(splitNode)\n ) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitType),\n splitNode.local,\n ),\n ]),\n )\n } else if (t.isVariableDeclarator(splitNode)) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(t.identifier(splitType), splitNode.init),\n ]),\n )\n } else if (t.isCallExpression(splitNode)) {\n const outputSplitNodeCode = generate(splitNode).code\n const splitNodeAst = babel.parse(outputSplitNodeCode)\n\n if (!splitNodeAst) {\n throw new Error(\n `Failed to parse the generated code for \"${splitType}\" in the node type \"${splitNode.type}\"`,\n )\n }\n\n const statement = splitNodeAst.program.body[0]\n\n if (!statement) {\n throw new Error(\n `Failed to parse the generated code for \"${splitType}\" in the node type \"${splitNode.type}\" as no statement was found in the program body`,\n )\n }\n\n if (t.isExpressionStatement(statement)) {\n const expression = statement.expression\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(t.identifier(splitType), expression),\n ]),\n )\n } else {\n throw new Error(\n `Unexpected expression type encounter for \"${splitType}\" in the node type \"${splitNode.type}\"`,\n )\n }\n } else {\n console.info('Unexpected splitNode type:', splitNode)\n throw new Error(`Unexpected splitNode type ☝️: ${splitNode.type}`)\n }\n }\n\n // If the splitNode exists at the top of the program\n // then we need to remove that copy\n programPath.node.body = programPath.node.body.filter((node) => {\n return node !== splitNode\n })\n\n // Export the node\n programPath.pushContainer('body', [\n t.exportNamedDeclaration(null, [\n t.exportSpecifier(\n t.identifier(splitType),\n t.identifier(splitType),\n ),\n ]),\n ])\n })\n\n // convert exports to imports from the original file\n programPath.traverse({\n ExportNamedDeclaration(path) {\n // e.g. export const x = 1 or export { x }\n // becomes\n // import { x } from '${opts.id}'\n\n if (path.node.declaration) {\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.replaceWith(\n t.importDeclaration(\n path.node.declaration.declarations.map((decl) =>\n t.importSpecifier(\n t.identifier((decl.id as any).name),\n t.identifier((decl.id as any).name),\n ),\n ),\n t.stringLiteral(\n removeSplitSearchParamFromFilename(opts.filename),\n ),\n ),\n )\n }\n }\n },\n })\n },\n },\n })\n\n deadCodeElimination(ast)\n\n // if there are exported identifiers, then we need to add a warning\n // to the file to let the user know that the exported identifiers\n // will not in the split file but in the original file, therefore\n // increasing the bundle size\n if (knownExportedIdents.size > 0) {\n const list = Array.from(knownExportedIdents).reduce((str, ident) => {\n str += `\\n- ${ident}`\n return str\n }, '')\n\n const warningMessage = `These exports from \"${opts.filename.replace('?' + splitPrefix, '')}\" are not being code-split and will increase your bundle size: ${list}\\nThese should either have their export statements removed or be imported from another file that is not a route.`\n console.warn(warningMessage)\n\n // append this warning to the file using a template\n if (process.env.NODE_ENV !== 'production') {\n const warningTemplate = template.statement(\n `console.warn(${JSON.stringify(warningMessage)})`,\n )()\n ast.program.body.unshift(warningTemplate)\n }\n }\n\n return generate(ast, {\n sourceMaps: true,\n sourceFileName: opts.filename,\n })\n}\n\nfunction getImportSpecifierAndPathFromLocalName(\n programPath: babel.NodePath<t.Program>,\n name: string,\n): {\n specifier:\n | t.ImportSpecifier\n | t.ImportDefaultSpecifier\n | t.ImportNamespaceSpecifier\n | null\n path: string | null\n} {\n let specifier:\n | t.ImportSpecifier\n | t.ImportDefaultSpecifier\n | t.ImportNamespaceSpecifier\n | null = null\n let path: string | null = null\n\n programPath.traverse({\n ImportDeclaration(importPath) {\n const found = importPath.node.specifiers.find(\n (targetSpecifier) => targetSpecifier.local.name === name,\n )\n if (found) {\n specifier = found\n path = importPath.node.source.value\n }\n },\n })\n\n return { specifier, path }\n}\n\n// Reusable function to get literal value or resolve variable to literal\nfunction resolveIdentifier(path: any, node: any) {\n if (t.isIdentifier(node)) {\n const binding = path.scope.getBinding(node.name)\n if (\n binding\n // && binding.kind === 'const'\n ) {\n const declarator = binding.path.node\n if (t.isObjectExpression(declarator.init)) {\n return declarator.init\n } else if (t.isFunctionDeclaration(declarator.init)) {\n return declarator.init\n }\n }\n return undefined\n }\n\n return node\n}\n\nfunction removeIdentifierLiteral(path: any, node: any) {\n if (t.isIdentifier(node)) {\n const binding = path.scope.getBinding(node.name)\n if (binding) {\n binding.path.remove()\n }\n }\n}\n\nfunction hasExport(ast: t.File, node: t.Identifier): boolean {\n let found = false\n\n babel.traverse(ast, {\n ExportNamedDeclaration(path) {\n if (path.node.declaration) {\n // declared as `const loaderFn = () => {}`\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.node.declaration.declarations.forEach((decl) => {\n if (t.isVariableDeclarator(decl)) {\n if (t.isIdentifier(decl.id)) {\n if (decl.id.name === node.name) {\n found = true\n }\n }\n }\n })\n }\n\n // declared as `function loaderFn() {}`\n if (t.isFunctionDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n if (path.node.declaration.id.name === node.name) {\n found = true\n }\n }\n }\n }\n },\n ExportDefaultDeclaration(path) {\n if (t.isIdentifier(path.node.declaration)) {\n if (path.node.declaration.name === node.name) {\n found = true\n }\n }\n },\n })\n\n return found\n}\n\nfunction removeExports(ast: t.File, node: t.Identifier): boolean {\n let removed = false\n\n babel.traverse(ast, {\n ExportNamedDeclaration(path) {\n if (path.node.declaration) {\n // declared as `const loaderFn = () => {}`\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.node.declaration.declarations.forEach((decl) => {\n if (t.isVariableDeclarator(decl)) {\n if (t.isIdentifier(decl.id)) {\n if (decl.id.name === node.name) {\n path.remove()\n removed = true\n }\n }\n }\n })\n } else if (t.isFunctionDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n if (path.node.declaration.id.name === node.name) {\n path.remove()\n removed = true\n }\n }\n }\n }\n },\n ExportDefaultDeclaration(path) {\n if (t.isIdentifier(path.node.declaration)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CACD;AAEM,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"compilers.js","sources":["../../../../src/core/code-splitter/compilers.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport babel from '@babel/core'\nimport _generate from '@babel/generator'\nimport * as template from '@babel/template'\nimport { deadCodeElimination } from 'babel-dead-code-elimination'\n\nimport { splitPrefix } from '../constants'\nimport { parseAst } from './ast'\nimport type { ParseAstOptions } from './ast'\n\nconst debug = process.env.TSR_VITE_DEBUG\n\n// Babel is a CJS package and uses `default` as named binding (`exports.default =`).\n// https://github.com/babel/babel/issues/15269.\nlet generate = (_generate as any)['default'] as typeof _generate\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nif (!generate) {\n generate = _generate\n}\n\ntype SplitModulesById = Record<\n string,\n { id: string; node: t.FunctionExpression }\n>\n\ninterface State {\n filename: string\n opts: {\n minify: boolean\n root: string\n }\n imported: Record<string, boolean>\n refs: Set<any>\n serverIndex: number\n splitIndex: number\n splitModulesById: SplitModulesById\n}\n\nfunction addSplitSearchParamToFilename(filename: string) {\n const [bareFilename] = filename.split('?')\n return `${bareFilename}?${splitPrefix}`\n}\n\nfunction removeSplitSearchParamFromFilename(filename: string) {\n const [bareFilename] = filename.split('?')\n return bareFilename!\n}\n\ntype SplitRouteIdentNodes = 'component' | 'loader'\ntype SplitNodeMeta = {\n routeIdent: SplitRouteIdentNodes\n splitStrategy: 'normal' | 'react-component'\n localImporterIdent: string\n exporterIdent: string\n localExporterIdent: string\n}\nconst SPLIT_NOES_CONFIG = new Map<SplitRouteIdentNodes, SplitNodeMeta>([\n [\n 'component',\n {\n routeIdent: 'component',\n localImporterIdent: '$$splitComponentImporter', // const $$splitComponentImporter = () => import('...')\n splitStrategy: 'react-component',\n localExporterIdent: 'SplitComponent', // const SplitComponent = ...\n exporterIdent: 'component', // export { SplitComponent as component }\n },\n ],\n [\n 'loader',\n {\n routeIdent: 'loader',\n localImporterIdent: '$$splitLoaderImporter', // const $$splitLoaderImporter = () => import('...')\n splitStrategy: 'normal',\n localExporterIdent: 'SplitLoader', // const SplitLoader = ...\n exporterIdent: 'loader', // export { SplitLoader as loader }\n },\n ],\n])\nconst SPLIT_ROUTE_IDENT_NODES = [...SPLIT_NOES_CONFIG.keys()] as const\n\nexport function compileCodeSplitReferenceRoute(opts: ParseAstOptions) {\n const ast = parseAst(opts)\n\n babel.traverse(ast, {\n Program: {\n enter(programPath, programState) {\n const state = programState as unknown as State\n\n // We need to extract the existing search params from the filename, if any\n // and add the splitPrefix to them, then write them back to the filename\n const splitUrl = addSplitSearchParamToFilename(opts.filename)\n\n /**\n * If the component for the route is being imported from\n * another file, this is to track the path to that file\n * the path itself doesn't matter, we just need to keep\n * track of it so that we can remove it from the imports\n * list if it's not being used like:\n *\n * `import '../shared/imported'`\n */\n let existingCompImportPath: string | null = null\n let existingLoaderImportPath: string | null = null\n\n programPath.traverse(\n {\n CallExpression: (path) => {\n if (!t.isIdentifier(path.node.callee)) {\n return\n }\n\n if (\n !(\n path.node.callee.name === 'createRoute' ||\n path.node.callee.name === 'createFileRoute'\n )\n ) {\n return\n }\n\n if (t.isCallExpression(path.parentPath.node)) {\n const options = resolveIdentifier(\n path,\n path.parentPath.node.arguments[0],\n )\n\n const hasImportedOrDefinedIdentifier = (name: string) => {\n return programPath.scope.hasBinding(name)\n }\n\n if (t.isObjectExpression(options)) {\n options.properties.forEach((prop) => {\n if (t.isObjectProperty(prop)) {\n if (t.isIdentifier(prop.key)) {\n const key = prop.key.name\n // find key in nodeSplitConfig\n const isNodeConfigAvailable = SPLIT_NOES_CONFIG.has(\n key as any,\n )\n\n if (!isNodeConfigAvailable) {\n return\n }\n\n const splitNodeMeta = SPLIT_NOES_CONFIG.get(key as any)!\n\n if (splitNodeMeta.splitStrategy === 'react-component') {\n const value = prop.value\n\n let shouldSplit = true\n\n if (t.isIdentifier(value)) {\n existingCompImportPath =\n getImportSpecifierAndPathFromLocalName(\n programPath,\n value.name,\n ).path\n\n // exported identifiers should not be split\n // since they are already being imported\n // and need to be retained in the compiled file\n const isExported = hasExport(ast, value)\n shouldSplit = !isExported\n\n if (shouldSplit) {\n removeIdentifierLiteral(path, value)\n }\n }\n\n if (!shouldSplit) {\n return\n }\n\n // Prepend the import statement to the program along with the importer function\n // Check to see if lazyRouteComponent is already imported before attempting\n // to import it again\n\n if (\n !hasImportedOrDefinedIdentifier(\n 'lazyRouteComponent',\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `import { lazyRouteComponent } from '@tanstack/react-router'`,\n )(),\n ])\n }\n\n // Check to see if the importer function is already defined\n // If not, define it with the dynamic import statement\n if (\n !hasImportedOrDefinedIdentifier(\n splitNodeMeta.localImporterIdent,\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`,\n )(),\n ])\n }\n\n // If it's a component, we need to pass the function to check the Route.ssr value\n if (key === 'component') {\n prop.value = template.expression(\n `lazyRouteComponent(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}', () => Route.ssr)`,\n )()\n } else {\n prop.value = template.expression(\n `lazyRouteComponent(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`,\n )()\n }\n\n // If the TSRDummyComponent is not defined, define it\n if (\n !hasImportedOrDefinedIdentifier('TSRDummyComponent')\n ) {\n programPath.pushContainer('body', [\n template.statement(\n `export function TSRDummyComponent() { return null }`,\n )(),\n ])\n }\n }\n\n if (splitNodeMeta.splitStrategy === 'normal') {\n const value = prop.value\n\n let shouldSplit = true\n\n if (t.isIdentifier(value)) {\n existingLoaderImportPath =\n getImportSpecifierAndPathFromLocalName(\n programPath,\n value.name,\n ).path\n\n // exported identifiers should not be split\n // since they are already being imported\n // and need to be retained in the compiled file\n const isExported = hasExport(ast, value)\n shouldSplit = !isExported\n\n if (shouldSplit) {\n removeIdentifierLiteral(path, value)\n }\n }\n\n if (!shouldSplit) {\n return\n }\n\n // Prepend the import statement to the program along with the importer function\n if (!hasImportedOrDefinedIdentifier('lazyFn')) {\n programPath.unshiftContainer(\n 'body',\n template.smart(\n `import { lazyFn } from '@tanstack/react-router'`,\n )(),\n )\n }\n\n // Check to see if the importer function is already defined\n // If not, define it with the dynamic import statement\n if (\n !hasImportedOrDefinedIdentifier(\n splitNodeMeta.localImporterIdent,\n )\n ) {\n programPath.unshiftContainer('body', [\n template.statement(\n `const ${splitNodeMeta.localImporterIdent} = () => import('${splitUrl}')`,\n )(),\n ])\n }\n\n // Add the lazyFn call with the dynamic import to the prop value\n prop.value = template.expression(\n `lazyFn(${splitNodeMeta.localImporterIdent}, '${splitNodeMeta.exporterIdent}')`,\n )()\n }\n }\n }\n\n programPath.scope.crawl()\n })\n }\n }\n },\n },\n state,\n )\n\n /**\n * If the component for the route is being imported,\n * and it's not being used, remove the import statement\n * from the program, by checking that the import has no\n * specifiers\n */\n if (\n (existingCompImportPath as string | null) ||\n (existingLoaderImportPath as string | null)\n ) {\n programPath.traverse({\n ImportDeclaration(path) {\n if (path.node.specifiers.length > 0) return\n if (\n path.node.source.value === existingCompImportPath ||\n path.node.source.value === existingLoaderImportPath\n ) {\n path.remove()\n }\n },\n })\n }\n },\n },\n })\n\n deadCodeElimination(ast)\n\n return generate(ast, {\n sourceMaps: true,\n sourceFileName: opts.filename,\n })\n}\n\nexport function compileCodeSplitVirtualRoute(opts: ParseAstOptions) {\n const ast = parseAst(opts)\n\n const knownExportedIdents = new Set<string>()\n\n babel.traverse(ast, {\n Program: {\n enter(programPath, programState) {\n const state = programState as unknown as State\n\n const trackedNodesToSplitByType: Record<\n SplitRouteIdentNodes,\n { node: t.Node | undefined; meta: SplitNodeMeta } | undefined\n > = {\n component: undefined,\n loader: undefined,\n }\n\n // Find the node\n programPath.traverse(\n {\n CallExpression: (path) => {\n if (!t.isIdentifier(path.node.callee)) {\n return\n }\n\n if (\n !(\n path.node.callee.name === 'createRoute' ||\n path.node.callee.name === 'createFileRoute'\n )\n ) {\n return\n }\n\n if (t.isCallExpression(path.parentPath.node)) {\n const options = resolveIdentifier(\n path,\n path.parentPath.node.arguments[0],\n )\n\n if (t.isObjectExpression(options)) {\n options.properties.forEach((prop) => {\n if (t.isObjectProperty(prop)) {\n SPLIT_ROUTE_IDENT_NODES.forEach((splitType) => {\n if (\n !t.isIdentifier(prop.key) ||\n prop.key.name !== splitType\n ) {\n return\n }\n\n const value = prop.value\n\n let isExported = false\n if (t.isIdentifier(value)) {\n isExported = hasExport(ast, value)\n if (isExported) {\n knownExportedIdents.add(value.name)\n }\n }\n\n // If the node is exported, we need to remove\n // the export from the split file\n if (isExported && t.isIdentifier(value)) {\n removeExports(ast, value)\n } else {\n const meta = SPLIT_NOES_CONFIG.get(splitType)!\n trackedNodesToSplitByType[splitType] = {\n node: prop.value,\n meta,\n }\n }\n })\n }\n })\n\n // Remove all of the options\n options.properties = []\n }\n }\n },\n },\n state,\n )\n\n SPLIT_ROUTE_IDENT_NODES.forEach((SPLIT_TYPE) => {\n const splitKey = trackedNodesToSplitByType[SPLIT_TYPE]\n\n if (!splitKey) {\n return\n }\n\n let splitNode = splitKey.node\n const splitMeta = splitKey.meta\n\n while (t.isIdentifier(splitNode)) {\n const binding = programPath.scope.getBinding(splitNode.name)\n splitNode = binding?.path.node\n }\n\n // Add the node to the program\n if (splitNode) {\n if (t.isFunctionDeclaration(splitNode)) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitMeta.localExporterIdent),\n t.functionExpression(\n splitNode.id || null, // Anonymize the function expression\n splitNode.params,\n splitNode.body,\n splitNode.generator,\n splitNode.async,\n ),\n ),\n ]),\n )\n } else if (\n t.isFunctionExpression(splitNode) ||\n t.isArrowFunctionExpression(splitNode)\n ) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitMeta.localExporterIdent),\n splitNode as any,\n ),\n ]),\n )\n } else if (\n t.isImportSpecifier(splitNode) ||\n t.isImportDefaultSpecifier(splitNode)\n ) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitMeta.localExporterIdent),\n splitNode.local,\n ),\n ]),\n )\n } else if (t.isVariableDeclarator(splitNode)) {\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitMeta.localExporterIdent),\n splitNode.init,\n ),\n ]),\n )\n } else if (t.isCallExpression(splitNode)) {\n const outputSplitNodeCode = generate(splitNode).code\n const splitNodeAst = babel.parse(outputSplitNodeCode)\n\n if (!splitNodeAst) {\n throw new Error(\n `Failed to parse the generated code for \"${SPLIT_TYPE}\" in the node type \"${splitNode.type}\"`,\n )\n }\n\n const statement = splitNodeAst.program.body[0]\n\n if (!statement) {\n throw new Error(\n `Failed to parse the generated code for \"${SPLIT_TYPE}\" in the node type \"${splitNode.type}\" as no statement was found in the program body`,\n )\n }\n\n if (t.isExpressionStatement(statement)) {\n const expression = statement.expression\n programPath.pushContainer(\n 'body',\n t.variableDeclaration('const', [\n t.variableDeclarator(\n t.identifier(splitMeta.localExporterIdent),\n expression,\n ),\n ]),\n )\n } else {\n throw new Error(\n `Unexpected expression type encounter for \"${SPLIT_TYPE}\" in the node type \"${splitNode.type}\"`,\n )\n }\n } else {\n console.info('Unexpected splitNode type:', splitNode)\n throw new Error(`Unexpected splitNode type ☝️: ${splitNode.type}`)\n }\n }\n\n // If the splitNode exists at the top of the program\n // then we need to remove that copy\n programPath.node.body = programPath.node.body.filter((node) => {\n return node !== splitNode\n })\n\n // Export the node\n programPath.pushContainer('body', [\n t.exportNamedDeclaration(null, [\n t.exportSpecifier(\n t.identifier(splitMeta.localExporterIdent), // local variable name\n t.identifier(splitMeta.exporterIdent), // as what name it should be exported as\n ),\n ]),\n ])\n })\n\n // convert exports to imports from the original file\n programPath.traverse({\n ExportNamedDeclaration(path) {\n // e.g. export const x = 1 or export { x }\n // becomes\n // import { x } from '${opts.id}'\n\n if (path.node.declaration) {\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.replaceWith(\n t.importDeclaration(\n path.node.declaration.declarations.map((decl) =>\n t.importSpecifier(\n t.identifier((decl.id as any).name),\n t.identifier((decl.id as any).name),\n ),\n ),\n t.stringLiteral(\n removeSplitSearchParamFromFilename(opts.filename),\n ),\n ),\n )\n }\n }\n },\n })\n },\n },\n })\n\n deadCodeElimination(ast)\n\n // if there are exported identifiers, then we need to add a warning\n // to the file to let the user know that the exported identifiers\n // will not in the split file but in the original file, therefore\n // increasing the bundle size\n if (knownExportedIdents.size > 0) {\n const list = Array.from(knownExportedIdents).reduce((str, ident) => {\n str += `\\n- ${ident}`\n return str\n }, '')\n\n const warningMessage = `These exports from \"${opts.filename.replace('?' + splitPrefix, '')}\" are not being code-split and will increase your bundle size: ${list}\\nThese should either have their export statements removed or be imported from another file that is not a route.`\n console.warn(warningMessage)\n\n // append this warning to the file using a template\n if (process.env.NODE_ENV !== 'production') {\n const warningTemplate = template.statement(\n `console.warn(${JSON.stringify(warningMessage)})`,\n )()\n ast.program.body.unshift(warningTemplate)\n }\n }\n\n return generate(ast, {\n sourceMaps: true,\n sourceFileName: opts.filename,\n })\n}\n\nfunction getImportSpecifierAndPathFromLocalName(\n programPath: babel.NodePath<t.Program>,\n name: string,\n): {\n specifier:\n | t.ImportSpecifier\n | t.ImportDefaultSpecifier\n | t.ImportNamespaceSpecifier\n | null\n path: string | null\n} {\n let specifier:\n | t.ImportSpecifier\n | t.ImportDefaultSpecifier\n | t.ImportNamespaceSpecifier\n | null = null\n let path: string | null = null\n\n programPath.traverse({\n ImportDeclaration(importPath) {\n const found = importPath.node.specifiers.find(\n (targetSpecifier) => targetSpecifier.local.name === name,\n )\n if (found) {\n specifier = found\n path = importPath.node.source.value\n }\n },\n })\n\n return { specifier, path }\n}\n\n// Reusable function to get literal value or resolve variable to literal\nfunction resolveIdentifier(path: any, node: any) {\n if (t.isIdentifier(node)) {\n const binding = path.scope.getBinding(node.name)\n if (\n binding\n // && binding.kind === 'const'\n ) {\n const declarator = binding.path.node\n if (t.isObjectExpression(declarator.init)) {\n return declarator.init\n } else if (t.isFunctionDeclaration(declarator.init)) {\n return declarator.init\n }\n }\n return undefined\n }\n\n return node\n}\n\nfunction removeIdentifierLiteral(path: any, node: any) {\n if (t.isIdentifier(node)) {\n const binding = path.scope.getBinding(node.name)\n if (binding) {\n binding.path.remove()\n }\n }\n}\n\nfunction hasExport(ast: t.File, node: t.Identifier): boolean {\n let found = false\n\n babel.traverse(ast, {\n ExportNamedDeclaration(path) {\n if (path.node.declaration) {\n // declared as `const loaderFn = () => {}`\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.node.declaration.declarations.forEach((decl) => {\n if (t.isVariableDeclarator(decl)) {\n if (t.isIdentifier(decl.id)) {\n if (decl.id.name === node.name) {\n found = true\n }\n }\n }\n })\n }\n\n // declared as `function loaderFn() {}`\n if (t.isFunctionDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n if (path.node.declaration.id.name === node.name) {\n found = true\n }\n }\n }\n }\n },\n ExportDefaultDeclaration(path) {\n if (t.isIdentifier(path.node.declaration)) {\n if (path.node.declaration.name === node.name) {\n found = true\n }\n }\n },\n })\n\n return found\n}\n\nfunction removeExports(ast: t.File, node: t.Identifier): boolean {\n let removed = false\n\n babel.traverse(ast, {\n ExportNamedDeclaration(path) {\n if (path.node.declaration) {\n // declared as `const loaderFn = () => {}`\n if (t.isVariableDeclaration(path.node.declaration)) {\n path.node.declaration.declarations.forEach((decl) => {\n if (t.isVariableDeclarator(decl)) {\n if (t.isIdentifier(decl.id)) {\n if (decl.id.name === node.name) {\n path.remove()\n removed = true\n }\n }\n }\n })\n } else if (t.isFunctionDeclaration(path.node.declaration)) {\n if (t.isIdentifier(path.node.declaration.id)) {\n if (path.node.declaration.id.name === node.name) {\n path.remove()\n removed = true\n }\n }\n }\n }\n },\n ExportDefaultDeclaration(path) {\n if (t.isIdentifier(path.node.declaration)) {\n if (path.node.declaration.name === node.name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,kBAAA;AAAA,QAAA;AAAA,MACV;AAAA,IACF;AAAA,EACF,CACD;AAEM,SAAA;AACT;AAEA,SAAS,cAAc,KAAa,MAA6B;AAC/D,MAAI,UAAU;AAEd,QAAM,SAAS,KAAK;AAAA,IAClB,uBAAuB,MAAM;AACvB,UAAA,KAAK,KAAK,aAAa;AAEzB,YAAI,EAAE,sBAAsB,KAAK,KAAK,WAAW,GAAG;AAClD,eAAK,KAAK,YAAY,aAAa,QAAQ,CAAC,SAAS;AAC/C,gBAAA,EAAE,qBAAqB,IAAI,GAAG;AAChC,kBAAI,EAAE,aAAa,KAAK,EAAE,GAAG;AAC3B,oBAAI,KAAK,GAAG,SAAS,KAAK,MAAM;AAC9B,uBAAK,OAAO;AACF,4BAAA;AAAA,gBAAA;AAAA,cACZ;AAAA,YACF;AAAA,UACF,CACD;AAAA,QAAA,WACQ,EAAE,sBAAsB,KAAK,KAAK,WAAW,GAAG;AACzD,cAAI,EAAE,aAAa,KAAK,KAAK,YAAY,EAAE,GAAG;AAC5C,gBAAI,KAAK,KAAK,YAAY,GAAG,SAAS,KAAK,MAAM;AAC/C,mBAAK,OAAO;AACF,wBAAA;AAAA,YAAA;AAAA,UACZ;AAAA,QACF;AAAA,MACF;AAAA,IAEJ;AAAA,IACA,yBAAyB,MAAM;AAC7B,UAAI,EAAE,aAAa,KAAK,KAAK,WAAW,GAAG;AACzC,YAAI,KAAK,KAAK,YAAY,SAAS,KAAK,MAAM;AAC5C,eAAK,OAAO;AACF,oBAAA;AAAA,QAAA;AAAA,MACZ;AAAA,IACF;AAAA,EACF,CACD;AAEM,SAAA;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-plugin",
|
|
3
|
-
"version": "1.98.
|
|
3
|
+
"version": "1.98.2",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"diff": "^7.0.0",
|
|
106
106
|
"unplugin": "^2.1.2",
|
|
107
107
|
"zod": "^3.24.1",
|
|
108
|
-
"@tanstack/router-generator": "^1.98.
|
|
109
|
-
"@tanstack/virtual-file-routes": "^1.98.
|
|
108
|
+
"@tanstack/router-generator": "^1.98.1",
|
|
109
|
+
"@tanstack/virtual-file-routes": "^1.98.1"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
112
|
"@rsbuild/core": ">=1.0.2",
|