From c689521a7674b6562b5dfd4f5cacd12138d99d85 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 19 Aug 2024 09:27:45 -0300 Subject: [PATCH] fix(api): tslib path (#10681) --- .changes/fix-tslib-path.md | 5 +++++ tooling/api/rollup.config.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changes/fix-tslib-path.md diff --git a/.changes/fix-tslib-path.md b/.changes/fix-tslib-path.md new file mode 100644 index 000000000..e43ee138c --- /dev/null +++ b/.changes/fix-tslib-path.md @@ -0,0 +1,5 @@ +--- +"@tauri-apps/api": patch:bug +--- + +Fix tslib path in dist. diff --git a/tooling/api/rollup.config.ts b/tooling/api/rollup.config.ts index 4af733784..4463b924c 100644 --- a/tooling/api/rollup.config.ts +++ b/tooling/api/rollup.config.ts @@ -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)