Add sourcemap support to server build
Summary: Provide the same build parameters as for the main build and move the two bundles to a folder where we can pick them up. For consistency, I'm keeping the naming scheme with the main build. Reviewed By: antonk52 Differential Revision: D36521046 fbshipit-source-id: 9ea992d6e5dc299d88083d751ca8e84eadb1430b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3dbd3f43e1
commit
02adfa79e9
@@ -17,6 +17,7 @@ import {
|
||||
getVersionNumber,
|
||||
prepareDefaultPlugins,
|
||||
prepareHeadlessPlugins,
|
||||
moveServerSourceMaps,
|
||||
} from './build-utils';
|
||||
import {defaultPluginsDir, distDir, serverDir, staticDir} from './paths';
|
||||
import isFB from './isFB';
|
||||
@@ -98,6 +99,11 @@ const argv = yargs
|
||||
'Directory with prepared list of default plugins which will be included into the Flipper distribution as "defaultPlugins" dir',
|
||||
type: 'string',
|
||||
},
|
||||
'source-map-dir': {
|
||||
describe:
|
||||
'Directory to write the main.bundle.map and bundle.map files for the main and render bundle sourcemaps, respectively',
|
||||
type: 'string',
|
||||
},
|
||||
version: {
|
||||
description:
|
||||
'Unique build identifier to be used as the version patch part for the build',
|
||||
@@ -335,6 +341,7 @@ async function buildServerRelease() {
|
||||
await copyStaticResources(dir, versionNumber);
|
||||
await downloadIcons(path.join(dir, 'static'));
|
||||
await buildBrowserBundle(path.join(dir, 'static'), false);
|
||||
await moveServerSourceMaps(dir, argv['source-map-dir']);
|
||||
await modifyPackageManifest(dir, versionNumber, hgRevision, argv.channel);
|
||||
const archive = await packNpmArchive(dir, versionNumber);
|
||||
await runPostBuildAction(archive, dir);
|
||||
|
||||
@@ -351,9 +351,35 @@ export async function moveSourceMaps(
|
||||
} else {
|
||||
// If we don't move them out of the build folders, they'll get included in the ASAR
|
||||
// which we don't want.
|
||||
console.log(`⏭ Removing source maps.`);
|
||||
await fs.remove(mainBundleMap);
|
||||
await fs.remove(rendererBundleMap);
|
||||
}
|
||||
}
|
||||
|
||||
export async function moveServerSourceMaps(
|
||||
buildFolder: string,
|
||||
sourceMapFolder: string | undefined,
|
||||
) {
|
||||
console.log(`⚙️ Moving server source maps...`);
|
||||
const mainBundleMap = path.join(buildFolder, 'dist', 'index.map');
|
||||
const rendererBundleMap = path.join(buildFolder, 'static', 'bundle.map');
|
||||
if (sourceMapFolder) {
|
||||
await fs.ensureDir(sourceMapFolder);
|
||||
await fs.move(mainBundleMap, path.join(sourceMapFolder, 'bundle.map'), {
|
||||
overwrite: true,
|
||||
});
|
||||
await fs.move(
|
||||
rendererBundleMap,
|
||||
path.join(sourceMapFolder, 'main.bundle.map'),
|
||||
{overwrite: true},
|
||||
);
|
||||
console.log(`✅ Moved to ${sourceMapFolder}.`);
|
||||
} else {
|
||||
// Removing so we don't bundle them up as part of the release.
|
||||
console.log(`⏭ Removing source maps.`);
|
||||
await fs.remove(mainBundleMap);
|
||||
await fs.remove(rendererBundleMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user