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

report(build): create UMD bundle build #12898

Merged
merged 4 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 18 additions & 1 deletion build/build-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,39 @@ async function buildEsModulesBundle() {
});

await bundle.write({
file: 'dist/report/bundle.js',
file: 'dist/report/bundle.esm.js',
format: 'esm',
});
}

async function buildUmdBundle() {
const bundle = await rollup.rollup({
input: 'report/clients/bundle.js',
plugins: [
commonjs(),
],
});

await bundle.write({
file: 'dist/report/bundle.umd.js',
format: 'umd',
name: 'report',
});
}

if (require.main === module) {
if (process.argv[2] === '--only-standalone') {
buildStandaloneReport();
} else {
buildStandaloneReport();
buildUmdBundle();
buildEsModulesBundle();
}
}

module.exports = {
buildStandaloneReport,
buildPsiReport,
buildUmdBundle,
buildTreemapReport,
};
7 changes: 4 additions & 3 deletions lighthouse-core/scripts/roll-to-devtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ cp -pPR "$lh_bg_js" "$fe_lh_dir/lighthouse-dt-bundle.js"
echo -e "$check lighthouse-dt-bundle copied."

# generate bundle.d.ts
npx tsc --allowJs --declaration --emitDeclarationOnly dist/report/bundle.js
npx tsc --allowJs --declaration --emitDeclarationOnly dist/report/bundle.esm.js

# copy report code $fe_lh_dir
fe_lh_report_dir="$fe_lh_dir/report/"
cp dist/report/bundle.js dist/report/bundle.d.ts "$fe_lh_report_dir"
cp dist/report/bundle.esm.js "$fe_lh_report_dir/bundle.js"
cp dist/report/bundle.esm.d.ts "$fe_lh_report_dir/bundle.d.ts"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you saw that the type files generated for both module types ended up being the same (makes sense)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. but thx for calling out.

echo -e "$check Report code copied."

# copy report generator + cached resources into $fe_lh_dir
Expand All @@ -71,5 +72,5 @@ fe_webtests_dir="$dt_dir/test/webtests/http/tests/devtools/lighthouse"
rsync -avh "$lh_webtests_dir" "$fe_webtests_dir" --exclude="OWNERS" --delete

echo ""
echo "Done. To run the webtests: "
echo "Done. To run the webtests: "
echo " DEVTOOLS_PATH=\"$dt_dir\" yarn test-devtools"