Closed
Description
Version
System:
OS: macOS 14.6.1
CPU: (16) arm64 Apple M3 Max
Memory: 8.00 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 130.0.6723.71
Safari: 17.6
npmPackages:
@rslib/core: ^0.0.15 => 0.0.15
Details
- Input:
export function example(): string {
return 'hello world';
}
- Config:
import { defineConfig } from '@rslib/core';
export default defineConfig({
lib: [
{
format: 'cjs',
syntax: 'es2021',
},
],
output: { target: 'node' },
});
- Create a
test.mjs
file to import() the dist bundle:
async function main() {
const { example } = await import('./dist/index.cjs');
console.log(example);
// tsup: got "[Function: example]"
// Rslib: got "undefined"
}
main();
Reproduce link
https://github.com/chenjiahan/rslib-repro-cjs-export
Reproduce Steps
Rslib:
- pnpm run build
- node ./test.mjs
tsup:
- npx tsup
- node ./test.mjs