Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 58b2dae

Browse files
nikoantfacebook-github-bot
authored andcommittedMar 10, 2021
Bundle all plugins script
Summary: New script which bundles all plugins. It is faster to bundle them all in one script rather than call "build-plugin" for each of them. The new script will be used in CI to catch regressions when some plugins cannot be bundled into standalone packages. Reviewed By: passy Differential Revision: D26918103 fbshipit-source-id: dbc5c4cd706e8d585718a198dbd7ae9ffd988e28
1 parent c065760 commit 58b2dae

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
 

‎desktop/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@
218218
"scripts": {
219219
"build": "cross-env NODE_ENV=production ./ts-node scripts/build-release.ts $@",
220220
"build-plugin": "./ts-node scripts/build-plugin.ts",
221+
"bundle-all-plugins": "./ts-node scripts/bundle-all-plugins.ts",
221222
"build:dev": "cross-env NODE_ENV=development ./ts-node scripts/build-release.ts $@",
222223
"build:eslint": "cd eslint-plugin-flipper && yarn build",
223224
"build:themes": "lessc --js themes/light.less static/themes/light.css && lessc --js themes/dark.less static/themes/dark.css",

‎desktop/scripts/bundle-all-plugins.ts

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @format
8+
*/
9+
10+
import {pluginsDir} from './paths';
11+
import path from 'path';
12+
import {runBuild} from 'flipper-pkg-lib';
13+
import {getWorkspaces} from './workspaces';
14+
15+
async function bundleAllPlugins() {
16+
const plugins = await getWorkspaces().then((workspaces) =>
17+
workspaces.packages.filter((x) => x.isPlugin),
18+
);
19+
const errors = new Map<string, any>();
20+
for (const plugin of plugins) {
21+
const relativeDir = path.relative(pluginsDir, plugin.dir);
22+
console.log(`Bundling "${relativeDir}"`);
23+
console.time(`Finished bundling "${relativeDir}"`);
24+
try {
25+
await runBuild(plugin.dir, false);
26+
} catch (err) {
27+
console.log(`Failed to bundle "${relativeDir}": ${err.message}`);
28+
errors.set(relativeDir, err);
29+
} finally {
30+
console.timeEnd(`Finished bundling "${relativeDir}"`);
31+
}
32+
}
33+
if (errors.size) {
34+
console.error('---');
35+
for (const [plugin, error] of errors) {
36+
console.error(`Failed to bundle ${plugin}`);
37+
console.error(error);
38+
console.error('---');
39+
}
40+
throw new Error(
41+
`Failed to bundle ${errors.size} plugins: ${[...errors.keys()].join(
42+
', ',
43+
)}`,
44+
);
45+
}
46+
}
47+
48+
bundleAllPlugins()
49+
.then(() => {
50+
process.exit(0);
51+
})
52+
.catch((err: any) => {
53+
console.error(err);
54+
process.exit(1);
55+
});

0 commit comments

Comments
 (0)