Skip to content

Commit

Permalink
Adds script to external example.
Browse files Browse the repository at this point in the history
Refs #48.

This mostly works just fine. I did notice that source maps seem to be broken, though that seems like a problem with the new `@aspect_rules_js` toolchain rather than this specific external example. I left a TODO to follow up with that separately.
  • Loading branch information
dgp1130 committed Feb 11, 2023
1 parent 0ef4e67 commit ebae5c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions examples/external/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm_user//:defs.bzl", "npm_link_all_packages")
load("@rules_prerender//:index.bzl", "prerender_pages", "web_resources_devserver")
Expand All @@ -15,10 +16,19 @@ npm_link_package(
prerender_pages(
name = "site",
src = "site.ts",
scripts = [":script"],
source_map = True, # TODO(#48): This doesn't seem to work?
tsconfig = "//:tsconfig.json",
lib_deps = ["//:node_modules/rules_prerender"],
)

ts_project(
name = "script",
srcs = ["script.ts"],
declaration = True,
source_map = True,
)

web_resources_devserver(
name = "devserver",
resources = ":site",
Expand Down
1 change: 1 addition & 0 deletions examples/external/script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('Hello, World!');
3 changes: 2 additions & 1 deletion examples/external/site.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrerenderResource } from 'rules_prerender';
import { includeScript, PrerenderResource } from 'rules_prerender';

export default function*(): Generator<PrerenderResource, void, void> {
yield PrerenderResource.of('/index.html', `
Expand All @@ -10,6 +10,7 @@ export default function*(): Generator<PrerenderResource, void, void> {
</head>
<body>
<h2>Hello, World!</h2>
${includeScript('script.js')}
</body>
</html>
`.trim());
Expand Down
1 change: 1 addition & 0 deletions examples/external/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target": "ES2020",
"module": "CommonJS",
"declaration": true,
"sourceMap": true,
"paths": {
"rules_prerender": ["../../packages/rules_prerender"],
},
Expand Down

0 comments on commit ebae5c9

Please sign in to comment.