Skip to content

Commit

Permalink
misc: shim fs out of lightrider report generator bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Jun 7, 2022
1 parent e84549b commit 36787c6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions build/build-lightrider-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,21 @@ async function buildReportGenerator() {
const bundle = await rollup({
input: 'report/generator/report-generator.js',
plugins: [
rollupPlugins.inlineFs({verbose: Boolean(process.env.DEBUG)}),
rollupPlugins.shim({
[`${LH_ROOT}/report/generator/flow-report-assets.js`]: 'export default {}',
'fs': 'export default {}',
}),
rollupPlugins.commonjs(),
rollupPlugins.inlineFs({verbose: Boolean(process.env.DEBUG)}),
],
});

await bundle.write({
file: 'dist/lightrider/report-generator-bundle.js',
format: 'iife',
format: 'umd',
name: 'ReportGenerator',
});
await bundle.close();

// Typically one would use `umd` to export to the window object, but for some reason rollup
// adds a `require('fs')` when used above, which errors in google3 build.
const outPath = `${LH_ROOT}/dist/lightrider/report-generator-bundle.js`;
fs.writeFileSync(outPath,
fs.readFileSync(outPath, 'utf-8') + '\nwindow.ReportGenerator = ReportGenerator;\n');
}

async function buildStaticServerBundle() {
Expand Down

0 comments on commit 36787c6

Please sign in to comment.