@akanjs/devkit 2.4.1-rc.7 → 2.4.2-rc.0
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/CHANGELOG.md +30 -0
- package/DEV_RUNTIME_KNOBS.md +97 -0
- package/README.md +6 -0
- package/akanApp/akanApp.host.test.ts +75 -6
- package/akanApp/akanApp.host.ts +303 -25
- package/akanConfig/akanConfig.ts +3 -0
- package/applicationBuildRunner.ts +8 -0
- package/commandDecorators/command.ts +16 -1
- package/executors.test.ts +290 -1
- package/executors.ts +210 -59
- package/fileSys.ts +7 -1
- package/frontendBuild/clientEntryDiscovery.ts +91 -53
- package/frontendBuild/cssCandidateCache.ts +109 -0
- package/frontendBuild/cssCompiler.ts +70 -18
- package/frontendBuild/fontOptimizer.ts +10 -2
- package/frontendBuild/frontendBuild.test.ts +3 -0
- package/frontendBuild/hmrWatcher.ts +6 -0
- package/frontendBuild/sourceMtimeIndex.test.ts +51 -2
- package/frontendBuild/sourceMtimeIndex.ts +66 -5
- package/incrementalBuilder/buildBatchRunner.ts +10 -1
- package/incrementalBuilder/builderChannel.test.ts +16 -7
- package/incrementalBuilder/builderRequestRouter.test.ts +89 -0
- package/incrementalBuilder/builderRequestRouter.ts +66 -0
- package/incrementalBuilder/incrementalBuilder.host.test.ts +28 -1
- package/incrementalBuilder/incrementalBuilder.host.ts +24 -2
- package/incrementalBuilder/incrementalBuilder.proc.ts +36 -26
- package/integration/devResourceProbe.ts +319 -0
- package/integration/devStability.integration.test.ts +153 -4
- package/integration/devStabilityHarness.ts +30 -5
- package/package.json +2 -2
- package/packageExportsMap.ts +1 -1
- package/routeSourceValidator.ts +51 -1
- package/scanInfo.ts +4 -0
- package/transforms/barrelImportsPlugin.ts +20 -13
|
@@ -64,18 +64,10 @@ export const createBarrelImportsPlugin = async (
|
|
|
64
64
|
const hasMacroAttr = MACRO_ATTR_RE.test(source);
|
|
65
65
|
|
|
66
66
|
if (!hasMacroAttr && barrels.length > 0) {
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
maybe = true;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
if (maybe) {
|
|
76
|
-
const rewritten = await rewriteBarrelImports(source, barrels, analyzer);
|
|
77
|
-
if (rewritten !== null) source = rewritten;
|
|
78
|
-
}
|
|
67
|
+
// The pre-check that used to live here — "does this file mention a barrel at all" — now
|
|
68
|
+
// lives inside `rewriteBarrelImports`, so every caller gets it rather than just this one.
|
|
69
|
+
const rewritten = await rewriteBarrelImports(source, barrels, analyzer);
|
|
70
|
+
if (rewritten !== null) source = rewritten;
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
if (pipeAfter) {
|
|
@@ -309,6 +301,12 @@ export const rewriteBarrelImports = async (
|
|
|
309
301
|
barrels: string[],
|
|
310
302
|
analyzer: BarrelAnalyzer,
|
|
311
303
|
): Promise<string | null> => {
|
|
304
|
+
// Establish there is something to rewrite before the TypeScript parser is involved. This runs on
|
|
305
|
+
// every source file of every dev rebuild, and parsing was by far the most expensive thing in one:
|
|
306
|
+
// measured across 1189 files here, 299ms and 161MB of RSS, of which **63% of files import no barrel
|
|
307
|
+
// at all**. A static import cannot name a specifier without that specifier appearing literally in the
|
|
308
|
+
// text, so a substring test is a sound filter and costs 4ms for the whole corpus.
|
|
309
|
+
if (!barrels.some((barrel) => source.includes(barrel))) return null;
|
|
312
310
|
const statements = findImportStatements(source);
|
|
313
311
|
if (statements.length === 0) return null;
|
|
314
312
|
|
|
@@ -340,7 +338,16 @@ interface ImportStatement {
|
|
|
340
338
|
|
|
341
339
|
const findImportStatements = (source: string): ImportStatement[] => {
|
|
342
340
|
const statements: ImportStatement[] = [];
|
|
343
|
-
|
|
341
|
+
// `setParentNodes: false`: nothing below reads `node.parent`, and every position comes from
|
|
342
|
+
// `getStart(sourceFile)`, which takes the file explicitly. Building the parent links cost 132ms and
|
|
343
|
+
// 143MB of RSS across 1189 files for no reader.
|
|
344
|
+
const sourceFile = ts.createSourceFile(
|
|
345
|
+
"barrel-imports.tsx",
|
|
346
|
+
source,
|
|
347
|
+
ts.ScriptTarget.Latest,
|
|
348
|
+
false,
|
|
349
|
+
ts.ScriptKind.TSX,
|
|
350
|
+
);
|
|
344
351
|
for (const statement of sourceFile.statements) {
|
|
345
352
|
if (!ts.isImportDeclaration(statement)) continue;
|
|
346
353
|
if (!ts.isStringLiteral(statement.moduleSpecifier)) continue;
|