Skip to content

Commit 35b0ff2

Browse files
committed
refactor
1 parent 4258b9d commit 35b0ff2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/features/pkg/exports.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ export async function generateExports(
158158
name = name.slice(0, -2)
159159
}
160160
const isIndex = onlyOneEntry || name === 'index'
161-
const outDirRelative = slash(path.relative(pkgRoot, chunk.outDir))
162-
const distFile = `${outDirRelative ? `./${outDirRelative}` : '.'}/${normalizedName}`
161+
const distFile = join(pkgRoot, chunk.outDir, normalizedName)
163162

164163
if (isIndex) {
165164
name = '.'
@@ -295,10 +294,8 @@ function exportCss(
295294
for (const chunksByFormat of Object.values(chunks)) {
296295
for (const chunk of chunksByFormat) {
297296
if (chunk.type === 'asset' && RE_CSS.test(chunk.fileName)) {
298-
console.log(chunk)
299-
300-
exports[`./${chunk.fileName}`] =
301-
`./${slash(path.join(path.relative(pkgRoot, chunk.outDir), chunk.fileName))}`
297+
const filename = slash(chunk.fileName)
298+
exports[`./${filename}`] = join(pkgRoot, chunk.outDir, filename)
302299
return
303300
}
304301
}
@@ -334,3 +331,8 @@ export function hasExportsTypes(pkg?: PackageJson): boolean {
334331

335332
return false
336333
}
334+
335+
function join(pkgRoot: string, outDir: string, fileName: string) {
336+
const outDirRelative = slash(path.relative(pkgRoot, outDir))
337+
return `${outDirRelative ? `./${outDirRelative}` : '.'}/${fileName}`
338+
}

0 commit comments

Comments
 (0)