@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/DEV_RUNTIME_KNOBS.md +97 -0
  3. package/README.md +6 -0
  4. package/akanApp/akanApp.host.test.ts +75 -6
  5. package/akanApp/akanApp.host.ts +303 -25
  6. package/akanConfig/akanConfig.ts +3 -0
  7. package/applicationBuildRunner.ts +8 -0
  8. package/commandDecorators/command.ts +16 -1
  9. package/executors.test.ts +290 -1
  10. package/executors.ts +210 -59
  11. package/fileSys.ts +7 -1
  12. package/frontendBuild/clientEntryDiscovery.ts +91 -53
  13. package/frontendBuild/cssCandidateCache.ts +109 -0
  14. package/frontendBuild/cssCompiler.ts +70 -18
  15. package/frontendBuild/fontOptimizer.ts +10 -2
  16. package/frontendBuild/frontendBuild.test.ts +3 -0
  17. package/frontendBuild/hmrWatcher.ts +6 -0
  18. package/frontendBuild/sourceMtimeIndex.test.ts +51 -2
  19. package/frontendBuild/sourceMtimeIndex.ts +66 -5
  20. package/incrementalBuilder/buildBatchRunner.ts +10 -1
  21. package/incrementalBuilder/builderChannel.test.ts +16 -7
  22. package/incrementalBuilder/builderRequestRouter.test.ts +89 -0
  23. package/incrementalBuilder/builderRequestRouter.ts +66 -0
  24. package/incrementalBuilder/incrementalBuilder.host.test.ts +28 -1
  25. package/incrementalBuilder/incrementalBuilder.host.ts +24 -2
  26. package/incrementalBuilder/incrementalBuilder.proc.ts +36 -26
  27. package/integration/devResourceProbe.ts +319 -0
  28. package/integration/devStability.integration.test.ts +153 -4
  29. package/integration/devStabilityHarness.ts +30 -5
  30. package/package.json +2 -2
  31. package/packageExportsMap.ts +1 -1
  32. package/routeSourceValidator.ts +51 -1
  33. package/scanInfo.ts +4 -0
  34. 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
- // Fast pre-check to avoid tokenizing every file in the workspace.
68
- let maybe = false;
69
- for (const b of barrels) {
70
- if (source.includes(b)) {
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
- const sourceFile = ts.createSourceFile("barrel-imports.tsx", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
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;