Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logic to remove soucemap and merge sourcemap params #9

Merged
merged 2 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ async function runReactNativeBundleCommand(
}
}
const bundleParams = await checkPlugins();
const minifyOption = bundleParams.minify;
const isSentry = bundleParams.sentry;
const bundleCommand = usingExpo
? 'export:embed'
Expand Down Expand Up @@ -126,8 +125,6 @@ async function runReactNativeBundleCommand(
'--platform',
platform,
'--reset-cache',
'--minify',
minifyOption,
]);

if (sourcemapOutput) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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`);
Expand All @@ -842,7 +839,7 @@ export const commands = {
entryFile,
intermediaDir,
platform,
sourcemap ? sourcemapOutput : '',
sourcemap || sourcemapPlugin ? sourcemapOutput : '',
);

await pack(path.resolve(intermediaDir), realOutput);
Expand Down
2 changes: 0 additions & 2 deletions src/utils/check-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { plugins } from './plugin-config';

interface BundleParams {
sentry: boolean;
minify: boolean;
sourcemap: boolean;
[key: string]: any;
}

export async function checkPlugins(): Promise<BundleParams> {
const params: BundleParams = {
sentry: false,
minify: true,
sourcemap: false,
};

Expand Down
2 changes: 0 additions & 2 deletions src/utils/plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import fs from 'fs-extra';
interface PluginConfig {
name: string;
bundleParams?: {
minify?: boolean;
[key: string]: any;
};
detect: () => Promise<boolean>;
Expand All @@ -14,7 +13,6 @@ export const plugins: PluginConfig[] = [
name: 'sentry',
bundleParams: {
sentry: true,
minify: false,
sourcemap: true,
},
detect: async () => {
Expand Down
Loading