Skip to content

Commit

Permalink
merge with unjs#371
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 4, 2024
1 parent b394e6d commit 38e6170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
11 changes: 2 additions & 9 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,14 @@ export async function rollupBuild(ctx: BuildContext) {

// DTS Stub
if (ctx.options.declaration) {
const entry = resolvedEntry
.replace(/\.ts$/, ".js")
.replace(/\.mts$/, ".cts")
.replace(/\.mjs$/, ".cjs");

const dtsContent = [
`export * from ${JSON.stringify(entry)};`,
`export * from ${JSON.stringify(resolvedEntryForTypeImport)};`,
hasDefaultExport
? `export { default } from ${JSON.stringify(entry)};`
? `export { default } from ${JSON.stringify(resolvedEntryForTypeImport)};`
: "",
].join("\n");

await writeFile(output + ".d.cts", dtsContent);
await writeFile(output + ".d.mts", dtsContent);
// .d.ts for node10 compatibility (TypeScript version < 4.7)
if (
ctx.options.declaration === "compatible" ||
ctx.options.declaration === true
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineBuildConfig([
emitCJS: true,
},
entries: [
"./src/index.ts",
"./src/index.mts",
"./src/nested/subpath.ts",
{ input: "src/runtime/", outDir: "dist/runtime" },
{
Expand Down

0 comments on commit 38e6170

Please sign in to comment.