Skip to content

Commit

Permalink
fix: support file names with . (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeliex authored Sep 11, 2024
1 parent df8668b commit 2a988e4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export const getRollupConfigs = async (
entryFileNames: (chunk) => {
const realPath = fs.realpathSync.native(stripQuery(chunk.facadeModuleId!));
const relativePath = realPath.slice(sourceDirectoryPath.length);
const [filePath] = relativePath.split('.');
const filePath = path.join(path.dirname(relativePath), chunk.name);
return filePath + distExtension;
},
};
Expand Down
40 changes: 40 additions & 0 deletions tests/specs/builds/package-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,45 @@ export default testSuite(({ describe }, nodePath: string) => {
const utilsMjs = await fixture.readFile('dist/utils.js', 'utf8');
expect(utilsMjs).toMatch('exports.sayHello =');
});

test('get basename with dot', async () => {
await using fixture = await createFixture({
...packageFixture({
installTypeScript: true,
}),
src: {
'index.node.ts': 'export default () => "foo";',
nested: {
'index.node.ts': 'export default () => "foo";',
},
},
'package.json': createPackageJson({
exports: {
'./': {
default: './dist/index.node.js',
types: './dist/index.node.d.ts',
},
'./nested': {
default: './dist/nested/index.node.js',
types: './dist/nested/index.node.d.ts',
},
},
}),
});

const pkgrollProcess = await pkgroll([], {
cwd: fixture.path,
nodePath,
});

expect(pkgrollProcess.exitCode).toBe(0);
expect(pkgrollProcess.stderr).toBe('');

const content = await fixture.readFile('dist/index.node.js', 'utf8');
expect(content).toMatch('module.exports =');
await fixture.exists('dist/index.node.d.ts');
await fixture.exists('dist/nested/index.node.js');
await fixture.exists('dist/nested/index.node.d.ts');
});
});
});

0 comments on commit 2a988e4

Please sign in to comment.