fix(api): tslib path (#10681)

This commit is contained in:
Lucas Fernandes Nogueira 2024-08-19 09:27:45 -03:00 committed by GitHub
parent 6b63c75504
commit c689521a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"@tauri-apps/api": patch:bug
---
Fix tslib path in dist.

View File

@ -6,7 +6,7 @@ import { defineConfig, Plugin, RollupLog } from 'rollup'
import typescript from '@rollup/plugin-typescript'
import terser from '@rollup/plugin-terser'
import fg from 'fast-glob'
import { basename, join } from 'path'
import { basename, dirname, join } from 'path'
import { copyFileSync, opendirSync, rmSync, Dir } from 'fs'
import { fileURLToPath } from 'url'
@ -27,7 +27,7 @@ export default defineConfig([
preserveModulesRoot: 'src',
entryFileNames: (chunkInfo) => {
if (chunkInfo.name.includes('node_modules')) {
return chunkInfo.name.replace('node_modules', 'external') + '.js'
return externalLibPath(chunkInfo.name) + '.js'
}
return '[name].js'
@ -40,7 +40,7 @@ export default defineConfig([
preserveModulesRoot: 'src',
entryFileNames: (chunkInfo) => {
if (chunkInfo.name.includes('node_modules')) {
return chunkInfo.name.replace('node_modules', 'external') + '.cjs'
return externalLibPath(chunkInfo.name) + '.cjs'
}
return '[name].cjs'
@ -71,6 +71,10 @@ export default defineConfig([
}
])
function externalLibPath(path: string) {
return `external/${basename(dirname(path))}/${basename(path)}`
}
function onwarn(warning: RollupLog) {
// deny warnings by default
throw Object.assign(new Error(), warning)