From abef760f430dc30addb4a3a5438dde7c5951c4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=A2=E4=BB=94=E7=B3=95?= Date: Sun, 9 Feb 2025 16:14:45 +0800 Subject: [PATCH] add logic to remove soucemap and merge sourcemap params (#9) * add logic to remove soucemap and merge sourcemap params * Update bundle.js --------- Co-authored-by: Sunny Luo --- src/bundle.js | 11 ++++------- src/utils/check-plugin.ts | 2 -- src/utils/plugin-config.ts | 2 -- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/bundle.js b/src/bundle.js index f243a0d..b06c928 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -87,7 +87,6 @@ async function runReactNativeBundleCommand( } } const bundleParams = await checkPlugins(); - const minifyOption = bundleParams.minify; const isSentry = bundleParams.sentry; const bundleCommand = usingExpo ? 'export:embed' @@ -126,8 +125,6 @@ async function runReactNativeBundleCommand( '--platform', platform, '--reset-cache', - '--minify', - minifyOption, ]); if (sourcemapOutput) { @@ -420,7 +417,7 @@ async function pack(dir, output) { } const childs = fs.readdirSync(root); for (const name of childs) { - if (name === '.' || name === '..' || name === 'index.bundlejs.map') { + if (name === '.' || name === '..' || name === 'index.bundlejs.map' || name === 'index.bundlejs.txt.map') { continue; } const fullPath = path.join(root, name); @@ -814,14 +811,14 @@ export const commands = { options.platform || (await question('平台(ios/android/harmony):')), ); - const { bundleName, entryFile, intermediaDir, output, dev } = + const { bundleName, entryFile, intermediaDir, output, dev, sourcemap } = translateOptions({ ...options, platform, }); const bundleParams = await checkPlugins(); - const sourcemap = bundleParams.sourcemap; + const sourcemapPlugin = bundleParams.sourcemap; const isSentry = bundleParams.sentry; const sourcemapOutput = path.join(intermediaDir, `${bundleName}.map`); @@ -842,7 +839,7 @@ export const commands = { entryFile, intermediaDir, platform, - sourcemap ? sourcemapOutput : '', + sourcemap || sourcemapPlugin ? sourcemapOutput : '', ); await pack(path.resolve(intermediaDir), realOutput); diff --git a/src/utils/check-plugin.ts b/src/utils/check-plugin.ts index 347f2a8..ee72fa3 100644 --- a/src/utils/check-plugin.ts +++ b/src/utils/check-plugin.ts @@ -2,7 +2,6 @@ import { plugins } from './plugin-config'; interface BundleParams { sentry: boolean; - minify: boolean; sourcemap: boolean; [key: string]: any; } @@ -10,7 +9,6 @@ interface BundleParams { export async function checkPlugins(): Promise { const params: BundleParams = { sentry: false, - minify: true, sourcemap: false, }; diff --git a/src/utils/plugin-config.ts b/src/utils/plugin-config.ts index cf60a20..06cbac3 100644 --- a/src/utils/plugin-config.ts +++ b/src/utils/plugin-config.ts @@ -3,7 +3,6 @@ import fs from 'fs-extra'; interface PluginConfig { name: string; bundleParams?: { - minify?: boolean; [key: string]: any; }; detect: () => Promise; @@ -14,7 +13,6 @@ export const plugins: PluginConfig[] = [ name: 'sentry', bundleParams: { sentry: true, - minify: false, sourcemap: true, }, detect: async () => {