Skip to content

Commit c969a11

Browse files
committed
test(auto-install): mirror alias package setup; map ~package to dist and add yarn fixture
fix(auto-install): normalize built-ins to include both 'fs' and 'node:fs' chore(auto-install): set peer rollup to ^4 per review
1 parent ea6c46a commit c969a11

File tree

4 files changed

+26
-10194
lines changed

4 files changed

+26
-10194
lines changed

.config/vitest.config.mts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export default defineConfig({
88
path.join(path.dirname(testPath), '.snapshots', path.basename(testPath) + snapExt)
99
},
1010
resolve: {
11-
// Allow importing the current package under test via `~package`
12-
alias: [{ find: /^~package$/, replacement: path.resolve(process.cwd()) }]
11+
// Allow importing the current package under test via `~package`.
12+
// Point directly at the built entry so dynamic imports in tests work consistently.
13+
alias: [
14+
{
15+
find: /^~package$/,
16+
replacement: path.resolve(process.cwd(), 'dist/index.js')
17+
}
18+
]
1319
}
1420
});

packages/auto-install/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ export default function autoInstall(opts: RollupAutoInstallOptions = {}): Plugin
5858
pkg = {};
5959
}
6060

61-
const installed = new Set(Object.keys(pkg.dependencies || {}).concat(builtinModules));
61+
// Normalize core module names to include both `fs` and `node:fs` forms so we never try to
62+
// install built-ins regardless of how Rollup reports them or how they are imported.
63+
const coreModules = new Set<string>([
64+
...builtinModules,
65+
...builtinModules.filter((m) => m.startsWith('node:')).map((m) => m.slice(5)),
66+
...builtinModules.filter((m) => !m.startsWith('node:')).map((m) => `node:${m}`)
67+
]);
68+
69+
const installed = new Set([...Object.keys(pkg.dependencies || {}), ...coreModules]);
6270
const cmd = commands[manager];
6371

6472
return {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)