Skip to content

Commit 9c0ce33

Browse files
committed
use re-export trick to reduce node_modules size
1 parent e2d8d54 commit 9c0ce33

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

scripts/build-exports.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,12 @@ if (process.argv.includes('--no-tsc')) {
127127
process.exit(exitCode);
128128
}
129129

130-
console.log('Copying declaration files for CommonJS...');
130+
console.log('Building shims for CommonJS type resolution...');
131131
for await (const file of fs.glob('*.d.ts', { cwd: rootDir })) {
132-
// Expected they have the same content, but this is still required for TypeScript's Node16 resolution.
133-
await fs.copyFile(dist(file), dist(file.replace('.d.ts', '.d.cts')));
132+
await fs.writeFile(
133+
dist(file.replace('.d.ts', '.d.cts')),
134+
`export * from "./${file.replace('.d.ts', '.js')}";`,
135+
'utf8',
136+
);
134137
}
135138
}

0 commit comments

Comments
 (0)