Skip to content

Commit

Permalink
fix(examples): transpile Angular es5 bundle to SystemJS (#2562)
Browse files Browse the repository at this point in the history
By default the es5 bundle created with Babel is transpiled to use require
for loading modules. This does not work with SystemJS, which is used in the
Angular example. This PR changes the transpilation to SystemJS.
  • Loading branch information
kyubisation authored Apr 20, 2021
1 parent d938c3b commit b0175cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/angular/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ babel(
"--no-babelrc",
"--source-maps",
"--presets=@babel/preset-env",
"--plugins=@babel/plugin-transform-modules-systemjs",
"--out-dir",
"$(@D)",
],
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/src/example/index.prod.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<!-- TODO: figure out how diff. loading interacts with
https://www.npmjs.com/package/rollup-plugin-bundle-html -->
<script type="module" src="/bundle-es2015.min/index.js"></script>
<script nomodule="" src="/bundle-es5.min/index.js"></script>
<script type="module" src="/bundle-es2015.min/index.js?v=TIMESTAMP-VARIABLE"></script>
<script nomodule="">System.import('/bundle-es5.min/index.js?v=TIMESTAMP-VARIABLE')</script>
</body>
</html>
7 changes: 6 additions & 1 deletion examples/angular/src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ const routes = process.argv.slice(routesFlagIdx + 1, process.argv.length);
const outsFlagIdx = process.argv.findIndex(arg => arg === '--outs');
const outs = process.argv.slice(outsFlagIdx + 1, routesFlagIdx);

const document = readFileSync(rootIndexPath, { encoding: 'utf8' });
const document = readFileSync(rootIndexPath, {encoding: 'utf8'})
// Replace the timestamp placeholder for cache busting.
// This is done per build and not per request, so the timestamp
// remains the same, until the app (or more precisely the prerender
// target) is rebuilt.
.replace(/TIMESTAMP-VARIABLE/g, `${Date.now()}`);

const win: any = domino.createWindow(document);
declare const global: any;
Expand Down

0 comments on commit b0175cd

Please sign in to comment.