Skip to content

Commit 690ba52

Browse files
committed
fix(auto-install): restore pnpm lockfile, make TS config TS4/5-compatible; type hooks; normalize built-ins; fix tests CWD
- Regenerate workspace pnpm-lock.yaml (v9) to fix CI install step - tsconfig: use moduleResolution "nodenext" for TS 4.8 compatibility; stripInternal in plugin config - src: mark test-only "commands" as @internal; normalize core module names; add resolveId param types - tests: restore process.cwd() in teardown to avoid cross-test coupling - package: constrain peer rollup to ^4
1 parent 6110665 commit 690ba52

File tree

10 files changed

+34
-10449
lines changed

10 files changed

+34
-10449
lines changed

.config/tsconfig.base.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"esModuleInterop": true,
55
"lib": ["ESNext"],
66
"module": "esnext",
7-
"moduleResolution": "bundler",
7+
// Use NodeNext for broad compatibility with both TS 4.8 and 5.x
8+
// (TS 4.8 does not support "bundler" resolution yet.)
9+
"moduleResolution": "nodenext",
810
"noEmit": true,
911
"noUnusedLocals": true,
1012
"noUnusedParameters": true,

.config/tsconfig.plugin.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"outDir": "dist",
88
"rootDir": "src",
99
"declaration": true,
10-
"declarationMap": true
10+
"declarationMap": true,
11+
// Ensure TSDoc `@internal` members aren't emitted in published types
12+
"stripInternal": true
1113
},
1214
"include": ["src/**/*"]
1315
}

packages/auto-install/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"modules"
4949
],
5050
"peerDependencies": {
51-
"rollup": ">=4.0.0"
51+
"rollup": "^4"
5252
},
5353
"peerDependenciesMeta": {
5454
"rollup": {

packages/auto-install/src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export interface RollupAutoInstallOptions {
2828
*/
2929
manager?: 'npm' | 'yarn' | 'pnpm';
3030

31-
/** Test-only override of package manager commands. */
31+
/**
32+
* Test-only override of package manager commands.
33+
* @internal
34+
*/
3235
commands?: Partial<Record<'npm' | 'yarn' | 'pnpm', string>>;
3336
}
3437

@@ -65,13 +68,20 @@ export default function autoInstall(opts: RollupAutoInstallOptions = {}): Plugin
6568
pkg = {};
6669
}
6770

68-
const installed = new Set(Object.keys(pkg.dependencies || {}).concat(builtinModules));
71+
// Normalize core module names to include both prefixed and unprefixed variants
72+
const coreModules = new Set<string>([
73+
...builtinModules,
74+
...builtinModules.filter((m) => m.startsWith('node:')).map((m) => m.slice(5)),
75+
...builtinModules.filter((m) => !m.startsWith('node:')).map((m) => `node:${m}`)
76+
]);
77+
78+
const installed = new Set<string>([...Object.keys(pkg.dependencies || {}), ...coreModules]);
6979
const cmd = options.commands[manager];
7080

7181
return {
7282
name: 'auto-install',
7383

74-
async resolveId(importee, importer) {
84+
async resolveId(importee: string, importer: string | undefined) {
7585
// entry module
7686
if (!importer) return null;
7787

packages/auto-install/test/npm-bare.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
1010
import autoInstall from '~package';
1111

1212
const DIRNAME = fileURLToPath(new URL('.', import.meta.url));
13+
const PREV_CWD = process.cwd();
1314
const cwd = path.join(DIRNAME, 'fixtures/npm-bare');
1415
const file = path.join(cwd, 'output/bundle.js');
1516
const input = path.join(cwd, '../input.js');
@@ -31,4 +32,5 @@ it('npm, bare', async () => {
3132

3233
afterAll(async () => {
3334
await del(['node_modules', 'package.json', 'package-lock.json']);
35+
process.chdir(PREV_CWD);
3436
});

packages/auto-install/test/npm.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
1010
import autoInstall from '~package';
1111

1212
const DIRNAME = fileURLToPath(new URL('.', import.meta.url));
13+
const PREV_CWD = process.cwd();
1314
const cwd = path.join(DIRNAME, 'fixtures/npm');
1415
const file = path.join(cwd, 'output/bundle.js');
1516
const input = path.join(cwd, '../input.js');
@@ -36,4 +37,5 @@ it('npm', async () => {
3637
afterAll(async () => {
3738
await del(['node_modules', 'package-lock.json']);
3839
fs.writeFileSync(pkgFile, '{}');
40+
process.chdir(PREV_CWD);
3941
});

packages/auto-install/test/pnpm-bare.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
1010
import autoInstall from '~package';
1111

1212
const DIRNAME = fileURLToPath(new URL('.', import.meta.url));
13+
const PREV_CWD = process.cwd();
1314
const cwd = path.join(DIRNAME, 'fixtures/pnpm-bare');
1415
const file = path.join(cwd, 'output/bundle.js');
1516
const input = path.join(cwd, '../input.js');
@@ -30,4 +31,5 @@ it('pnpm, bare', async () => {
3031

3132
afterAll(async () => {
3233
await del(['node_modules', 'package.json', 'pnpm-lock.yaml']);
34+
process.chdir(PREV_CWD);
3335
});

packages/auto-install/test/pnpm.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
1010
import autoInstall from '~package';
1111

1212
const DIRNAME = fileURLToPath(new URL('.', import.meta.url));
13+
const PREV_CWD = process.cwd();
1314
const cwd = path.join(DIRNAME, 'fixtures/pnpm');
1415
const file = path.join(cwd, 'output/bundle.js');
1516
const input = path.join(cwd, '../input.js');
@@ -31,4 +32,5 @@ it('pnpm', async () => {
3132
afterAll(async () => {
3233
await del(['node_modules', 'package.json']);
3334
fs.writeFileSync(path.join(cwd, 'pnpm-lock.yaml'), '');
35+
process.chdir(PREV_CWD);
3436
});

packages/auto-install/test/yarn.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import nodeResolve from '@rollup/plugin-node-resolve';
1010
import autoInstall from '~package';
1111

1212
const DIRNAME = fileURLToPath(new URL('.', import.meta.url));
13+
const PREV_CWD = process.cwd();
1314
const cwd = path.join(DIRNAME, 'fixtures/yarn');
1415
const file = path.join(cwd, 'output/bundle.js');
1516
const input = path.join(cwd, '../input.js');
@@ -30,4 +31,5 @@ it('yarn', async () => {
3031
afterAll(async () => {
3132
await del(['node_modules', 'package.json']);
3233
fs.writeFileSync(path.join(cwd, 'yarn.lock'), '');
34+
process.chdir(PREV_CWD);
3335
});

0 commit comments

Comments
 (0)