Skip to content

Commit 84f27a2

Browse files
authored
fix: preserve bare specifiers for subpath and undeclared external imports in rolldown build (#540)
The rolldown external config used exact string matching, which failed to match dependency subpath imports (e.g. `@noble/hashes/sha2.js` did not match `@noble/hashes`). This caused the build to resolve these imports to relative `node_modules` paths, breaking consumers at runtime.
1 parent 3e3a217 commit 84f27a2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
"esbuild": "0.25.0"
128128
},
129129
"dependencies": {
130+
"@algorandfoundation/xhd-wallet-api": "2.0.0-canary.1",
131+
"@noble/ed25519": "^3.0.0",
130132
"@noble/hashes": "^2.0.1",
131133
"algorand-msgpack": "^1.1.0",
132134
"buffer": "^6.0.3",

rolldown.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ type StringOrRegExp = string | RegExp
99
const nodeBuiltins = builtinModules.flatMap((m) => [m, `node:${m}`])
1010

1111
export default function createConfig(externalDependencies: StringOrRegExp[], input: string[] = ['src/index.ts']): typeof config {
12-
const external = Array.from(new Set([...nodeBuiltins, ...Object.keys(workspacePkg.dependencies || {}), ...externalDependencies]))
12+
const external: StringOrRegExp[] = [
13+
...nodeBuiltins,
14+
...[...Object.keys(workspacePkg.dependencies || {}), ...externalDependencies]
15+
.map(dep => typeof dep === 'string' ? new RegExp(`^${dep}($|\\/|\\\\)`) : dep),
16+
]
1317

1418
const resolvedInput = input.flatMap((pattern) => {
1519
// If it contains glob characters or negations, resolve with fast-glob

0 commit comments

Comments
 (0)