Remove inlined source maps from debug builds

Summary: Disabled producing inline source maps for debug builds. Source maps are already writte to "map" files, so this does not make sense to also inline them to the js bundle. Passing "sourceMapUrl" parameter to Metro fixed this.

Reviewed By: mweststrate

Differential Revision: D22159501

fbshipit-source-id: f06225cd43f44a7f93afcc32bb0501323b35d0c3
This commit is contained in:
Anton Nikolaev
2020-06-22 06:10:21 -07:00
committed by Facebook GitHub Bot
parent f373872b5c
commit b69996ca50
4 changed files with 9 additions and 2 deletions

View File

@@ -69,7 +69,6 @@
"devDependencies": {
"@testing-library/react": "^10.0.2",
"flipper-test-utils": "0.47.0",
"mac-ca": "^1.0.4",
"metro": "^0.59.0",
"mock-fs": "^4.12.0",
"pretty-format": "^25.4.0",

View File

@@ -35,6 +35,9 @@ export default async function runBuild(
out: string,
dev: boolean,
) {
const sourceMapUrl = path.basename(
out.substring(0, out.lastIndexOf('.')) + '.map',
);
const baseConfig = await Metro.loadConfig();
const config = Object.assign({}, baseConfig, {
reporter: {update: () => {}},
@@ -70,6 +73,7 @@ export default async function runBuild(
minify: !dev,
resetCache: !dev,
sourceMap: dev,
sourceMapUrl,
entry,
out,
});

View File

@@ -74,6 +74,8 @@ async function compile(
watchFolders: string[],
entry: string,
) {
const out = path.join(buildFolder, 'bundle.js');
const sourceMapUrl = dev ? 'bundle.map' : undefined;
await Metro.runBuild(
{
reporter: {update: () => {}},
@@ -98,8 +100,9 @@ async function compile(
minify: !dev,
resetCache: !dev,
sourceMap: dev,
sourceMapUrl,
entry,
out: path.join(buildFolder, 'bundle.js'),
out,
},
);
}

View File

@@ -13,6 +13,7 @@
"flipper-plugin-lib": "0.47.0",
"fs-extra": "^8.1.0",
"ignore": "^5.1.4",
"mac-ca": "^1.0.4",
"mem": "^6.0.0",
"mkdirp": "^1.0.4",
"p-filter": "^2.1.0",