Skip to content

Commit

Permalink
fix: js bundle alias of shared module (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Dec 31, 2024
1 parent c524f94 commit 833f285
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,19 @@ export async function collectSourceEntriesFromExportPaths(
],
]
const privateExportInfo: [string, string][] = [
...(isTs ? typesInfos : []),
[
posixRelativify(
posix.join('./dist', exportPath + (isEsmPkg ? '.js' : '.mjs')),
),
condPart + 'import',
condPart + 'import.default',
],
[
posixRelativify(
posix.join('./dist', exportPath + (isEsmPkg ? '.cjs' : '.js')),
),
condPart + 'require',
condPart + 'require.default',
],
...(isTs ? typesInfos : []),
]

const exportsInfo = parsedExportsInfo.get(normalizedExportPath)
Expand Down
10 changes: 10 additions & 0 deletions test/integration/shared-module-with-suffix/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "mixed-export-conditions",
"exports": {
"./client": {
"import": {
"default": "./dist/client.mjs"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { assertFilesContent, createIntegrationTest } from '../utils'

describe('integration - shared-module-with-suffix', () => {
it('should alias correctly for the shared module with special suffix', async () => {
await createIntegrationTest(
{
directory: __dirname,
},
async ({ distDir }) => {
assertFilesContent(distDir, {
'client.mjs': `./_private/util.browser.mjs`,
})
},
)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const util = 'index:browser'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { util } from '../_private/util.browser'

export function getClient() {
return 'client' + util
}

0 comments on commit 833f285

Please sign in to comment.