diff --git a/BUILD.bazel b/BUILD.bazel index d222cc31a8..a5d2904247 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -91,7 +91,6 @@ npm_package( "//third_party/github.com/bazelbuild/bazel-skylib:package_contents", "//third_party/github.com/buffer-from:package_contents", "//third_party/github.com/gjtorikian/isBinaryFile:package_contents", - "//third_party/github.com/inikulin/parse5:package_contents", "//third_party/github.com/juanjoDiaz/removeNPMAbsolutePaths:package_contents", "//third_party/github.com/source-map:package_contents", "//third_party/github.com/source-map-support:package_contents", diff --git a/e2e/BUILD.bazel b/e2e/BUILD.bazel index 9dc8278a70..272b4ebff4 100644 --- a/e2e/BUILD.bazel +++ b/e2e/BUILD.bazel @@ -83,6 +83,7 @@ e2e_integration_test( name = "e2e_ts_devserver", npm_packages = { "//packages/hide-bazel-files:npm_package": "@bazel/hide-bazel-files", + "//packages/inject-html:npm_package": "@bazel/inject-html", "//packages/protractor:npm_package": "@bazel/protractor", "//packages/typescript:npm_package": "@bazel/typescript", }, diff --git a/e2e/ts_devserver/package.json b/e2e/ts_devserver/package.json index bd66da7690..6a06eedc60 100644 --- a/e2e/ts_devserver/package.json +++ b/e2e/ts_devserver/package.json @@ -1,6 +1,7 @@ { "dependencies": { "@bazel/hide-bazel-files": "^0.40.0", + "@bazel/inject-html": "^0.40.0", "@bazel/protractor": "^0.40.0", "@bazel/typescript": "^0.40.0", "@types/jasmine": "2.8.2", diff --git a/e2e/ts_devserver/subpackage/BUILD.bazel b/e2e/ts_devserver/subpackage/BUILD.bazel index fb5798db54..9095a6bc10 100644 --- a/e2e/ts_devserver/subpackage/BUILD.bazel +++ b/e2e/ts_devserver/subpackage/BUILD.bazel @@ -12,13 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@npm_bazel_inject_html//:index.bzl", "inject_html") load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite") load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library") +inject_html( + name = "inject", + src = "index.html", + assets = ["//:red-body-style.css"], +) + ts_devserver( name = "devserver", - index_html = "index.html", - static_files = ["//:red-body-style.css"], + static_files = [ + "inject", + "//:red-body-style.css", + ], ) ts_library( diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index 112887bb71..ad6d2fdc87 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -18,6 +18,7 @@ example_integration_test( name = "examples_angular", timeout = "long", npm_packages = { + "//packages/inject-html:npm_package": "@bazel/inject-html", "//packages/karma:npm_package": "@bazel/karma", "//packages/protractor:npm_package": "@bazel/protractor", "//packages/rollup:npm_package": "@bazel/rollup", @@ -51,6 +52,7 @@ example_integration_test( name = "examples_angular_view_engine", timeout = "long", npm_packages = { + "//packages/inject-html:npm_package": "@bazel/inject-html", "//packages/karma:npm_package": "@bazel/karma", "//packages/protractor:npm_package": "@bazel/protractor", "//packages/rollup:npm_package": "@bazel/rollup", @@ -90,6 +92,7 @@ example_integration_test( name = "examples_app", npm_packages = { "//packages/hide-bazel-files:npm_package": "@bazel/hide-bazel-files", + "//packages/inject-html:npm_package": "@bazel/inject-html", "//packages/protractor:npm_package": "@bazel/protractor", "//packages/rollup:npm_package": "@bazel/rollup", "//packages/terser:npm_package": "@bazel/terser", @@ -115,6 +118,7 @@ example_integration_test( example_integration_test( name = "examples_kotlin", npm_packages = { + "//packages/inject-html:npm_package": "@bazel/inject-html", "//packages/jasmine:npm_package": "@bazel/jasmine", "//packages/rollup:npm_package": "@bazel/rollup", "//packages/terser:npm_package": "@bazel/terser", diff --git a/examples/angular/package.json b/examples/angular/package.json index f2f695da8f..ecf251abb6 100644 --- a/examples/angular/package.json +++ b/examples/angular/package.json @@ -36,6 +36,7 @@ "@bazel/benchmark-runner": "^0.1.0", "@bazel/buildifier": "^0.29.0", "@bazel/ibazel": "^0.10.3", + "@bazel/inject-html": "^0.40.0", "@bazel/karma": "^0.40.0", "@bazel/protractor": "^0.40.0", "@bazel/rollup": "^0.40.0", diff --git a/examples/angular/src/BUILD.bazel b/examples/angular/src/BUILD.bazel index 64fe9e9b9f..0a24cecca4 100644 --- a/examples/angular/src/BUILD.bazel +++ b/examples/angular/src/BUILD.bazel @@ -5,6 +5,7 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") load("@npm//@babel/cli:index.bzl", "babel") load("@npm//history-server:index.bzl", "history_server") load("@npm_angular_bazel//:index.bzl", "ng_module") +load("@npm_bazel_inject_html//:index.bzl", "inject_html") load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") load("@npm_bazel_terser//:index.bzl", "terser_minified") load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library") @@ -85,23 +86,22 @@ _ASSETS = [ "@npm//:node_modules/zone.js/dist/zone.min.js", ] +inject_html( + name = "inject_scripts_for_dev", + src = "//src:example/index.html", + assets = _ASSETS + ["_/ts_scripts.js"], +) + # This devserver is written in Go and is super-fast. # It doesn't run any bundler or code splitter. Instead, it concatenates # named UMD and named AMD JavaScript code on-the-fly in-memory. # This scales really well for massive codebases. ts_devserver( name = "devserver", - # Serve these files but don't inject tags for them into the index file - # This might be because we only want to lazy-load these scripts on-demand, - # or because they aren't compatible with Require.js so we must use a runtime - # loader to load them. - data = [ - "//src/assets", - ], - # Start from the development version of the main + # Serve src/example/index.html at /index.html + additional_root_paths = ["src/example"], + # Run the program from the development version of the main entry_module = "examples_angular/src/main.dev", - # - - - - - + diff --git a/examples/angular/src/example/index.prod.html b/examples/angular/src/example/index.prod.html new file mode 100644 index 0000000000..eed875619a --- /dev/null +++ b/examples/angular/src/example/index.prod.html @@ -0,0 +1,23 @@ + + + + + Angular Bazel Example + + + + + + + + + + + + + + + + + diff --git a/examples/angular_view_engine/package.json b/examples/angular_view_engine/package.json index 3a3d3ab164..923d47605c 100644 --- a/examples/angular_view_engine/package.json +++ b/examples/angular_view_engine/package.json @@ -36,6 +36,7 @@ "@bazel/benchmark-runner": "^0.1.0", "@bazel/buildifier": "^0.29.0", "@bazel/ibazel": "^0.10.3", + "@bazel/inject-html": "^0.40.0", "@bazel/karma": "^0.40.0", "@bazel/protractor": "^0.40.0", "@bazel/rollup": "^0.40.0", diff --git a/examples/angular_view_engine/src/BUILD.bazel b/examples/angular_view_engine/src/BUILD.bazel index edfd13b1fa..2da9bfb427 100644 --- a/examples/angular_view_engine/src/BUILD.bazel +++ b/examples/angular_view_engine/src/BUILD.bazel @@ -3,6 +3,7 @@ load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") load("@npm//@babel/cli:index.bzl", "babel") load("@npm//history-server:index.bzl", "history_server") load("@npm_angular_bazel//:index.bzl", "ng_module") +load("@npm_bazel_inject_html//:index.bzl", "inject_html") load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") load("@npm_bazel_terser//:index.bzl", "terser_minified") load("@npm_bazel_typescript//:index.bzl", "ts_config", "ts_devserver", "ts_library") @@ -83,23 +84,22 @@ _ASSETS = [ "@npm//:node_modules/zone.js/dist/zone.min.js", ] +inject_html( + name = "inject_scripts_for_dev", + src = "//src:example/index.html", + assets = _ASSETS + ["_/ts_scripts.js"], +) + # This devserver is written in Go and is super-fast. # It doesn't run any bundler or code splitter. Instead, it concatenates # named UMD and named AMD JavaScript code on-the-fly in-memory. # This scales really well for massive codebases. ts_devserver( name = "devserver", - # Serve these files but don't inject tags for them into the index file - # This might be because we only want to lazy-load these scripts on-demand, - # or because they aren't compatible with Require.js so we must use a runtime - # loader to load them. - data = [ - "//src/assets", - ], - # Start from the development version of the main + # Serve src/example/index.html at /index.html + additional_root_paths = ["src/example"], + # Run the program from the development version of the main entry_module = "examples_angular_view_engine/src/main.dev", - # - - - - - + diff --git a/examples/angular_view_engine/src/example/index.prod.html b/examples/angular_view_engine/src/example/index.prod.html new file mode 100644 index 0000000000..eed875619a --- /dev/null +++ b/examples/angular_view_engine/src/example/index.prod.html @@ -0,0 +1,23 @@ + + + + + Angular Bazel Example + + + + + + + + + + + + + + + + + diff --git a/examples/app/BUILD.bazel b/examples/app/BUILD.bazel index 01a23c6675..31b9c1b964 100644 --- a/examples/app/BUILD.bazel +++ b/examples/app/BUILD.bazel @@ -1,6 +1,7 @@ load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package") load("@npm//http-server:index.bzl", "http_server") load("@npm//typescript:index.bzl", "tsc") +load("@npm_bazel_inject_html//:index.bzl", "inject_html") load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite") load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") load("@npm_bazel_terser//:index.bzl", "terser_minified") @@ -15,7 +16,6 @@ ts_library( ts_devserver( name = "devserver", - index_html = "index.html", # We'll collect all the devmode JS sources from these TypeScript libraries deps = [":app"], ) @@ -31,14 +31,21 @@ terser_minified( src = ":bundle", ) +_ASSETS = [ + ":bundle.min", + "//styles:base.css", + "//styles:test.css", +] + +inject_html( + name = "inject_js_css_tags", + src = "index.html", + assets = _ASSETS, +) + web_package( name = "package", - assets = [ - ":bundle.min", - "//styles:base.css", - "//styles:test.css", - ], - index_html = "index.html", + srcs = [":inject_js_css_tags"] + _ASSETS, ) http_server( diff --git a/examples/app/index.html b/examples/app/index.html index c2c0d055ed..f222da46ad 100644 --- a/examples/app/index.html +++ b/examples/app/index.html @@ -7,7 +7,7 @@ --> - ts_devserver example + app example diff --git a/examples/app/package.json b/examples/app/package.json index 44b744a17a..3b0c141233 100644 --- a/examples/app/package.json +++ b/examples/app/package.json @@ -1,6 +1,7 @@ { "devDependencies": { "@bazel/hide-bazel-files": "^0.40.0", + "@bazel/inject-html": "^0.40.0", "@bazel/protractor": "^0.40.0", "@bazel/rollup": "^0.40.0", "@bazel/terser": "^0.40.0", diff --git a/examples/kotlin/BUILD.bazel b/examples/kotlin/BUILD.bazel index 277daa3f5a..e199249cde 100644 --- a/examples/kotlin/BUILD.bazel +++ b/examples/kotlin/BUILD.bazel @@ -4,6 +4,7 @@ load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package") load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_js_import", "kt_js_library") load("@npm//http-server:index.bzl", "http_server") +load("@npm_bazel_inject_html//:index.bzl", "inject_html") load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test") load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") load("@npm_bazel_terser//:index.bzl", "terser_minified") @@ -48,14 +49,24 @@ rollup_bundle( ) terser_minified( + # This will output bundle.min.js name = "bundle.min", src = ":bundle", ) +inject_html( + name = "inject_script_tag", + src = "index.html", + # Having a .js file here causes the injector to add a script tag + assets = [":bundle.min.js"], +) + web_package( name = "package", - data = [":bundle.min"], - index_html = "index.html", + srcs = [ + "inject_script_tag", + ":bundle.min", + ], ) # TODO: fix prodserver; require.js is needed if rollup_bundle output is cjs diff --git a/examples/kotlin/package.json b/examples/kotlin/package.json index 5e04d49064..965796d8e5 100644 --- a/examples/kotlin/package.json +++ b/examples/kotlin/package.json @@ -2,6 +2,7 @@ "name": "kotlin_example", "private": true, "devDependencies": { + "@bazel/inject-html": "^0.40.0", "@bazel/jasmine": "^0.40.0", "@bazel/rollup": "^0.40.0", "@bazel/terser": "^0.40.0", diff --git a/examples/kotlin/spec.js b/examples/kotlin/spec.js index 06694d39cb..75728a4bbc 100644 --- a/examples/kotlin/spec.js +++ b/examples/kotlin/spec.js @@ -10,6 +10,10 @@ describe('kotlin webapp', () => { // Make all Domino types available as types in the global env. Object.assign(global, domino.impl); -import(path.join(__dirname, 'bundle/bundle.js')).then(() => {expect(global.document.body.textContent).toEqual('Hello from Kotlin!')}); + // clang-format off + // (it doesn't understand dynamic import) + import(path.join(__dirname, 'bundle/bundle.js')).then(() => { + expect(global.document.body.textContent).toEqual('Hello from Kotlin!'); + }); }); }); diff --git a/examples/webapp/differential_loading.bzl b/examples/webapp/differential_loading.bzl index e3d449be0f..47414f106a 100644 --- a/examples/webapp/differential_loading.bzl +++ b/examples/webapp/differential_loading.bzl @@ -57,6 +57,7 @@ def differential_loading(name, entry_point, srcs): web_package( name = name, assets = [ + "index.html", "styles.css", ], data = [ @@ -64,5 +65,4 @@ def differential_loading(name, entry_point, srcs): name + "_chunks.min", name + "_chunks_es5.min", ], - index_html = "index.html", ) diff --git a/examples/webapp/index.html b/examples/webapp/index.html index 13c02b5faa..f300cf9fbc 100644 --- a/examples/webapp/index.html +++ b/examples/webapp/index.html @@ -2,7 +2,6 @@ rules_nodejs webapp example - diff --git a/internal/web_package/BUILD.bazel b/internal/web_package/BUILD.bazel index 9b4201be66..0ac1f26279 100644 --- a/internal/web_package/BUILD.bazel +++ b/internal/web_package/BUILD.bazel @@ -7,10 +7,7 @@ load("@npm_bazel_jasmine//:index.from_src.bzl", "jasmine_node_test") # END-INTERNAL package(default_visibility = ["//visibility:public"]) -exports_files([ - "web_package.bzl", - "inject_html.bzl", -]) +exports_files(["web_package.bzl"]) bzl_library( name = "bzl", @@ -30,26 +27,7 @@ nodejs_binary( node_modules = ":node_modules_none", ) -nodejs_binary( - name = "injector", - data = [ - "injector.js", - "//third_party/github.com/inikulin/parse5", - ], - entry_point = ":injector.js", - install_source_map_support = False, -) - # BEGIN-INTERNAL -jasmine_node_test( - name = "injector_test", - srcs = ["injector_spec.js"], - deps = [ - ":injector.js", - "//third_party/github.com/inikulin/parse5", - ], -) - jasmine_node_test( name = "assembler_test", srcs = ["assembler_spec.js"], diff --git a/internal/web_package/test/BUILD.bazel b/internal/web_package/test/BUILD.bazel index 999e50cac4..118a1785bc 100644 --- a/internal/web_package/test/BUILD.bazel +++ b/internal/web_package/test/BUILD.bazel @@ -67,7 +67,10 @@ web_package( # Intentionally duplicating `:bundle.min` (`bundle.min.js`) in assets # and data to test for regression of the issues fixed by # https://github.com/bazelbuild/rules_nodejs/pull/546 - assets = [":bundle.min"], + assets = [ + "index.html", + ":bundle.min", + ], data = [ ":bundle", ":bundle.es2015", @@ -76,7 +79,6 @@ web_package( ":bundle.min_debug", ":bundle.min_debug.es2015", ], - index_html = "index.html", ) jasmine_node_test( diff --git a/internal/web_package/test/index_golden.html_ b/internal/web_package/test/index_golden.html_ index ccc6280c66..18ecdcb795 100644 --- a/internal/web_package/test/index_golden.html_ +++ b/internal/web_package/test/index_golden.html_ @@ -1,2 +1 @@ - - \ No newline at end of file + diff --git a/internal/web_package/test2/BUILD.bazel b/internal/web_package/test2/BUILD.bazel index c5d4a2a805..43706b077b 100644 --- a/internal/web_package/test2/BUILD.bazel +++ b/internal/web_package/test2/BUILD.bazel @@ -62,6 +62,7 @@ EXTS = [ web_package( name = "pkg", assets = [ + "index.html", # bundles from a different directory "//internal/web_package/test:bundle.es2015", "//internal/web_package/test:bundle.min.es2015", @@ -85,7 +86,6 @@ web_package( ["//internal/web_package/test2/rel-exports:rel-bin-" + e for e in EXTS] + ["//internal/web_package/test2/rel-exports:rel-gen-" + e for e in EXTS] + ["//internal/web_package/test2/rel-exports:rel-file." + e for e in EXTS], - index_html = "index.html", ) jasmine_node_test( diff --git a/internal/web_package/test2/index_golden.html_ b/internal/web_package/test2/index_golden.html_ index 8f37f927a0..18ecdcb795 100644 --- a/internal/web_package/test2/index_golden.html_ +++ b/internal/web_package/test2/index_golden.html_ @@ -1,2 +1 @@ - - + diff --git a/internal/web_package/web_package.bzl b/internal/web_package/web_package.bzl index 599ef01b3a..ff089fbc1c 100644 --- a/internal/web_package/web_package.bzl +++ b/internal/web_package/web_package.bzl @@ -15,35 +15,6 @@ """Contains the web_package rule. """ -def html_asset_inject(index_html, action_factory, injector, root_dirs, assets, output): - """Injects JS and CSS resources into the index.html. - - Args: - index_html: The input html file - action_factory: Bazel's actions module from ctx.actions - see https://docs.bazel.build/versions/master/skylark/lib/actions.html - injector: The injector executable - root_dirs: Path prefixes to strip off all assets. Longest wins. - assets: Asset files to inject - output: The output html file - - Returns: - The output html file - """ - args = action_factory.args() - args.add(output.path) - args.add(index_html.path) - args.add_all(root_dirs) - args.add("--assets") - args.add_all(assets) - args.use_param_file("%s", use_always = True) - action_factory.run( - inputs = [index_html], - outputs = [output], - executable = injector, - arguments = [args], - ) - return output - def move_files(output_name, files, action_factory, assembler, root_paths): """Moves files into an output directory @@ -91,21 +62,9 @@ def additional_root_paths(ctx): def _web_package(ctx): root_paths = additional_root_paths(ctx) - # Create the output file in a re-rooted subdirectory so it doesn't collide with the input file - html = ctx.actions.declare_file("_%s/%s" % (ctx.label.name, ctx.file.index_html.path)) - - # Move that index file back into place inside the package - populated_index = html_asset_inject( - ctx.file.index_html, - ctx.actions, - ctx.executable._injector, - root_paths, - [f.path for f in ctx.files.assets], - html, - ) package_layout = move_files( ctx.label.name, - ctx.files.data + ctx.files.assets + [html], + ctx.files.data + ctx.files.assets, ctx.actions, ctx.executable._assembler, root_paths, @@ -128,20 +87,11 @@ web_package = rule( allow_files = True, doc = """Additional files which should be served on request""", ), - "index_html": attr.label( - allow_single_file = True, - doc = """The entry point of the application""", - ), "_assembler": attr.label( default = "@build_bazel_rules_nodejs//internal/web_package:assembler", executable = True, cfg = "host", ), - "_injector": attr.label( - default = "@build_bazel_rules_nodejs//internal/web_package:injector", - executable = True, - cfg = "host", - ), }, doc = """Assembles a web application from source files. diff --git a/package.json b/package.json index fe5e986b9a..a1f0d8d8b2 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "node_resolve_main": "file:./tools/npm_packages/node_resolve_main", "node_resolve_main_2": "file:./tools/npm_packages/node_resolve_main_2", "node_resolve_nested_main": "file:./tools/npm_packages/node_resolve_nested_main", + "parse5": "5.1.0", "protobufjs": "6.8.8", "protractor": "^5.4.2", "requirejs": "2.3.6", diff --git a/packages/inject-html/BUILD.bazel b/packages/inject-html/BUILD.bazel new file mode 100644 index 0000000000..1ab283aab3 --- /dev/null +++ b/packages/inject-html/BUILD.bazel @@ -0,0 +1,36 @@ +load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "npm_package") +load("@npm_bazel_jasmine//:index.from_src.bzl", "jasmine_node_test") + +# For local testing without an npm install +nodejs_binary( + name = "injector", + data = ["@npm//parse5"], + entry_point = ":index.js", + install_source_map_support = False, + visibility = ["//packages/inject-html:__subpackages__"], +) + +jasmine_node_test( + name = "test", + srcs = ["spec.js"], + deps = [ + ":index.js", + "@npm//parse5", + ], +) + +npm_package( + name = "npm_package", + srcs = [ + "README.md", + "index.bzl", + "index.js", + "inject_html.bzl", + "package.json", + ], + # Don't distribute this package yet + # TODO: determine if this is a useful public API that we want to commit to + # after discussion with the team. + tags = ["do-not-publish"], + visibility = ["//:__subpackages__"], +) diff --git a/packages/inject-html/README.md b/packages/inject-html/README.md new file mode 100644 index 0000000000..15717859ec --- /dev/null +++ b/packages/inject-html/README.md @@ -0,0 +1,3 @@ +# @bazel/inject-html + +A utility for adding `` and ` \ No newline at end of file diff --git a/packages/inject-html/test/script.js b/packages/inject-html/test/script.js new file mode 100644 index 0000000000..70e301760f --- /dev/null +++ b/packages/inject-html/test/script.js @@ -0,0 +1,4 @@ +const el = document.createElement('div'); +const text = 'Hello, World'; +el.innerText = text; +document.body.appendChild(el); diff --git a/packages/inject-html/test/spec.js b/packages/inject-html/test/spec.js new file mode 100644 index 0000000000..fc115a3a4a --- /dev/null +++ b/packages/inject-html/test/spec.js @@ -0,0 +1,15 @@ +const fs = require('fs'); +const path = require('path'); + +process.chdir(path.join(process.env['TEST_SRCDIR'], 'build_bazel_rules_nodejs')); +console.error(fs.readdirSync('.')); +describe('web_package', () => { + it('should match the golden file', () => { + const output = 'build_bazel_rules_nodejs/internal/web_package/test/pkg/index.html'; + const golden = 'build_bazel_rules_nodejs/internal/web_package/test/index_golden.html_'; + const actual = fs.readFileSync(require.resolve(output), {encoding: 'utf-8'}); + const expected = fs.readFileSync(require.resolve(golden), {encoding: 'utf-8'}); + // make the input hermetic by replacing the cache-buster timestamp + expect(actual.replace(/\?v=\d+/g, '?v=123')).toBe(expected); + }); +}); diff --git a/packages/typescript/src/internal/devserver/package.json b/packages/typescript/src/internal/devserver/package.json deleted file mode 100644 index 5391d982e5..0000000000 --- a/packages/typescript/src/internal/devserver/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "description": "runtime dependencies for devserver", - "devDependencies": { - "requirejs": "2.3.5" - } -} diff --git a/packages/typescript/src/internal/devserver/ts_devserver.bzl b/packages/typescript/src/internal/devserver/ts_devserver.bzl index e1d46440fd..97fdfe4401 100644 --- a/packages/typescript/src/internal/devserver/ts_devserver.bzl +++ b/packages/typescript/src/internal/devserver/ts_devserver.bzl @@ -19,11 +19,6 @@ load( "@build_bazel_rules_nodejs//internal/js_library:js_library.bzl", "write_amd_names_shim", ) -load( - "@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", - "additional_root_paths", - "html_asset_inject", -) # Avoid using non-normalized paths (workspace/../other_workspace/path) def _to_manifest_path(ctx, file): @@ -100,21 +95,6 @@ def _ts_devserver(ctx): devserver_runfiles += script_files devserver_runfiles += ctx.files._bash_runfile_helpers - if ctx.file.index_html: - injected_index = ctx.actions.declare_file("index.html") - bundle_script = ctx.attr.serving_path - if bundle_script.startswith("/"): - bundle_script = bundle_script[1:] - html_asset_inject( - ctx.file.index_html, - ctx.actions, - ctx.executable._injector, - additional_root_paths(ctx), - [_to_manifest_path(ctx, f) for f in ctx.files.static_files] + [bundle_script], - injected_index, - ) - devserver_runfiles += [injected_index] - packages = depset(["/".join([workspace_name, ctx.label.package])] + ctx.attr.additional_root_paths) ctx.actions.expand_template( @@ -173,12 +153,6 @@ ts_devserver = rule( `require(["entry_module"]);` """, ), - "index_html": attr.label( - allow_single_file = True, - doc = """An index.html file, we'll inject the script tag for the bundle, - as well as script tags for .js static_files and link tags for .css - static_files""", - ), "port": attr.int( doc = """The port that the devserver will listen on.""", default = 5432, @@ -205,11 +179,6 @@ ts_devserver = rule( aspects = [node_modules_aspect], ), "_bash_runfile_helpers": attr.label(default = Label("@bazel_tools//tools/bash/runfiles")), - "_injector": attr.label( - default = "@build_bazel_rules_nodejs//internal/web_package:injector", - executable = True, - cfg = "host", - ), "_launcher_template": attr.label(allow_single_file = True, default = Label("//internal/devserver:launcher_template.sh")), "_requirejs_script": attr.label(allow_single_file = True, default = Label("//third_party/npm/requirejs:require.js")), }, diff --git a/packages/typescript/src/internal/devserver/yarn.lock b/packages/typescript/src/internal/devserver/yarn.lock deleted file mode 100644 index 95ae199a6c..0000000000 --- a/packages/typescript/src/internal/devserver/yarn.lock +++ /dev/null @@ -1,7 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -requirejs@2.3.5: - version "2.3.5" - resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.5.tgz#617b9acbbcb336540ef4914d790323a8d4b861b0" diff --git a/yarn.lock b/yarn.lock index 18d68331de..029f39618d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5313,6 +5313,11 @@ parse-json@^4.0.0: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" +parse5@5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2" + integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ== + parse5@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"