Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: recognize inline comments between import( and its literal specifier in import reach

[._.]/ Adam Eivyfd7018b94e5c
diff --git a/scripts/lib/importReach.js b/scripts/lib/importReach.js
index 81ca4731e8..317206b11e 100644
--- a/scripts/lib/importReach.js
+++ b/scripts/lib/importReach.js
@@ -27,7 +27,7 @@ import { globToRegExp, toWorkspacePath, workspaceTestGlobs } from './workspaceTe
const MODULE_SOURCE_RE = /\.[cm]?[jt]sx?$/i;
const RESOLVE_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.mts', '.cts'];
-const DYNAMIC_IMPORT_RE = /\bimport\s*\(\s*(['"`])([^'"`]+?)\1\s*[,)]/g;
+const DYNAMIC_IMPORT_RE = /\bimport\s*\(\s*(?:\/\*.*?\*\/\s*)*(['"`])([^'"`]+?)\1\s*[,)]/g;
// `*` opens a comment continuation only when followed by space, `/` or EOL; `*gen() {}` is code.
const COMMENT_LINE_RE = /^\s*(?:\/\/|\*(?:[\s/]|$))/;
const LEADING_BLOCK_COMMENT_RE = /^\s*\/\*.*?\*\//;
diff --git a/scripts/lib/importReach.test.js b/scripts/lib/importReach.test.js
index 086ce3e3df..e7eb0c52c4 100644
--- a/scripts/lib/importReach.test.js
+++ b/scripts/lib/importReach.test.js
@@ -16,12 +16,14 @@ const SOURCES = new Map([
"export const load = (name) => import(`./${name}.js`);",
"export async function rare() { return (await import('./heavy.js')).run(); }",
"/* lazy */ export const lazyLeaf = () => import('./lazyLeaf.js');",
+ "export const tagged = () => import(/* webpackChunkName: x */ './taggedLeaf.js');",
"export const gen = {\n *walk() { return import('./genLeaf.js'); }\n};",
].join('\n')],
['svc/heavy.js', "import { core } from './core.js';\nexport const run = () => core;\n"],
['svc/core.js', 'export const core = 1;\n'],
['svc/leaf.js', 'export const leaf = 1;\n'],
['svc/lazyLeaf.js', 'export const a = 1;\n'],
+ ['svc/taggedLeaf.js', 'export const c = 1;\n'],
['svc/genLeaf.js', 'export const b = 1;\n'],
['svc/ghost.js', 'export const ghost = 1;\n'],
['svc/caller.test.js', "import { load } from './caller.js';\n"],
@@ -32,7 +34,7 @@ const graph = buildImportGraph([...SOURCES.keys()], (rel) => SOURCES.get(rel) ??
describe('importReachReport', () => {
it('counts a dynamic edge for selection while the static view stops at it', () => {
- expect([...graph.get('svc/caller.js').dynamic]).toEqual(['svc/heavy.js', 'svc/lazyLeaf.js', 'svc/genLeaf.js']);
+ expect([...graph.get('svc/caller.js').dynamic]).toEqual(['svc/heavy.js', 'svc/lazyLeaf.js', 'svc/taggedLeaf.js', 'svc/genLeaf.js']);
const { rows, selected } = importReachReport(graph, ['svc/core.js', 'svc/heavy.js', 'svc/ghost.js'], isTest);
expect(rows).toEqual([
// core.test.js resolves `./core` without an extension, like Vite.