Skip to content

Commit c689521

Browse files
authored
fix(api): tslib path (#10681)
1 parent 6b63c75 commit c689521

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

.changes/fix-tslib-path.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tauri-apps/api": patch:bug
3+
---
4+
5+
Fix tslib path in dist.

tooling/api/rollup.config.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { defineConfig, Plugin, RollupLog } from 'rollup'
66
import typescript from '@rollup/plugin-typescript'
77
import terser from '@rollup/plugin-terser'
88
import fg from 'fast-glob'
9-
import { basename, join } from 'path'
9+
import { basename, dirname, join } from 'path'
1010
import { copyFileSync, opendirSync, rmSync, Dir } from 'fs'
1111
import { fileURLToPath } from 'url'
1212

@@ -27,7 +27,7 @@ export default defineConfig([
2727
preserveModulesRoot: 'src',
2828
entryFileNames: (chunkInfo) => {
2929
if (chunkInfo.name.includes('node_modules')) {
30-
return chunkInfo.name.replace('node_modules', 'external') + '.js'
30+
return externalLibPath(chunkInfo.name) + '.js'
3131
}
3232

3333
return '[name].js'
@@ -40,7 +40,7 @@ export default defineConfig([
4040
preserveModulesRoot: 'src',
4141
entryFileNames: (chunkInfo) => {
4242
if (chunkInfo.name.includes('node_modules')) {
43-
return chunkInfo.name.replace('node_modules', 'external') + '.cjs'
43+
return externalLibPath(chunkInfo.name) + '.cjs'
4444
}
4545

4646
return '[name].cjs'
@@ -71,6 +71,10 @@ export default defineConfig([
7171
}
7272
])
7373

74+
function externalLibPath(path: string) {
75+
return `external/${basename(dirname(path))}/${basename(path)}`
76+
}
77+
7478
function onwarn(warning: RollupLog) {
7579
// deny warnings by default
7680
throw Object.assign(new Error(), warning)

0 commit comments

Comments
 (0)