From 71ebac2ad2217caf45d447026b7cb89f10f85dbf Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Tue, 28 Feb 2023 22:33:46 -0800 Subject: [PATCH] The big ESM migration commit. Refs #33. This updates `@rules_prerender` to use ESM modules everywhere. This makes a few changes throughout the workspace: 1. Renames `*.{ts,js}` -> `*.{mts,mjs}`. 2. Updates imports to include `.mjs` in the file path. 3. Updates any hard-coded CommonJS `require()` or `module.exports` to use ESM syntax. 4. Updates `tsconfig.json` files to use `module: "ES2020"` and `moduleResolution: "node"`. 5. Updates `package.json` files to use `type: "module"`. Most of the changes are fairly mechanical syntax modifications, though there are a couple random edits thrown in as necessary to switch over to ESM. Most of this was generated by running: ``` $ echo {common,examples,packages,tools}/**/*.ts | tr " " "\n" | xargs -I {} bash -c "git mv {} \$(echo {} | sed 's,\\.ts$,.mts,g')" $ sed -i -E "s,^import (.*?) from '(\..*?)';,import \1 from '\2.mjs';,g" {common,examples,packages,tools}/**/*.mts $ sed -i -E "s,^export (.*?) from '(\..*?)';,export \1 from '\2.mjs';,g" {common,examples,packages,tools}/**/*.mts $ sed -i "s,\\.ts\",.mts\",g" {.,common,examples,packages,tools}/**/BUILD.bazel $ sed -i "s,\\.js\",.mjs\",g" {.,common,examples,packages,tools}/**/BUILD.bazel ``` --- common/BUILD.bazel | 28 +++++++-------- common/{binary.ts => binary.mts} | 0 common/{binary_test.ts => binary_test.mts} | 2 +- common/{collections.ts => collections.mts} | 0 ...llections_test.ts => collections_test.mts} | 2 +- common/{file_system.ts => file_system.mts} | 0 ...le_system_fake.ts => file_system_fake.mts} | 2 +- common/{formatters.ts => formatters.mts} | 0 ...formatters_test.ts => formatters_test.mts} | 2 +- common/{http.ts => http.mts} | 0 common/{http_test.ts => http_test.mts} | 2 +- common/models/BUILD.bazel | 20 +++++------ ...annotation.ts => prerender_annotation.mts} | 0 ..._mock.ts => prerender_annotation_mock.mts} | 2 +- ..._test.ts => prerender_annotation_test.mts} | 2 +- ...der_metadata.ts => prerender_metadata.mts} | 0 ...ta_mock.ts => prerender_metadata_mock.mts} | 2 +- ...ta_test.ts => prerender_metadata_test.mts} | 2 +- ...der_resource.ts => prerender_resource.mts} | 2 +- ...ce_test.ts => prerender_resource_test.mts} | 2 +- common/models/{url_path.ts => url_path.mts} | 0 .../{url_path_test.ts => url_path_test.mts} | 2 +- ...ker.ts => prerender_annotation_walker.mts} | 4 +-- ...s => prerender_annotation_walker_test.mts} | 4 +-- common/{probably.ts => probably.mts} | 0 .../{probably_test.ts => probably_test.mts} | 2 +- common/testing/BUILD.bazel | 36 +++++++++---------- common/testing/{binary.ts => binary.mts} | 0 .../{binary_test.ts => binary_test.mts} | 4 +-- .../testing/{devserver.ts => devserver.mts} | 6 ++-- .../{devserver_test.ts => devserver_test.mts} | 6 ++-- .../{effect_fake.ts => effect_fake.mts} | 2 +- ...fect_fake_test.ts => effect_fake_test.mts} | 4 +-- .../{effect_tester.ts => effect_tester.mts} | 2 +- ..._tester_test.ts => effect_tester_test.mts} | 6 ++-- common/testing/{effects.ts => effects.mts} | 0 .../{effects_test.ts => effects_test.mts} | 2 +- common/testing/{mocks.ts => mocks.mts} | 0 .../testing/{mocks_test.ts => mocks_test.mts} | 2 +- common/testing/{temp_dir.ts => temp_dir.mts} | 2 +- .../{temp_dir_test.ts => temp_dir_test.mts} | 4 +-- .../{test_server.ts => test_server.mts} | 0 ...st_server_test.ts => test_server_test.mts} | 2 +- .../testing/{webdriver.ts => webdriver.mts} | 4 +-- .../{webdriver_test.ts => webdriver_test.mts} | 6 ++-- examples/components/BUILD.bazel | 12 +++---- .../{component.ts => component.mts} | 4 +-- examples/components/{dep.ts => dep.mts} | 2 +- examples/components/{page.ts => page.mts} | 2 +- examples/components/{test.ts => test.mts} | 4 +-- .../{transitive.ts => transitive.mts} | 0 examples/components/{ts_dep.ts => ts_dep.mts} | 0 examples/data/BUILD.bazel | 4 +-- examples/data/{pages.ts => pages.mts} | 0 examples/data/{test.ts => test.mts} | 4 +-- examples/declarative_shadow_dom/BUILD.bazel | 6 ++-- .../{component.ts => component.mts} | 0 .../{site.ts => site.mts} | 2 +- .../{test.ts => test.mts} | 4 +-- examples/external/BUILD.bazel | 2 +- examples/external/component/BUILD.bazel | 4 +-- .../component/{component.ts => component.mts} | 0 .../component/{script.ts => script.mts} | 0 examples/external/{site.ts => site.mts} | 2 +- examples/external/tsconfig.json | 3 +- examples/extract/BUILD.bazel | 4 +-- ...nested_resource.ts => nested_resource.mts} | 0 ...single_resource.ts => single_resource.mts} | 0 examples/javascript/BUILD.bazel | 4 +-- examples/javascript/component/BUILD.bazel | 10 +++--- .../component/{component.js => component.mjs} | 10 +++--- ...mponent_script.js => component_script.mjs} | 0 ...script_dep.js => component_script_dep.mjs} | 0 ..._unused.js => component_script_unused.mjs} | 0 .../{prerender_lib.js => prerender_lib.mjs} | 4 +-- examples/javascript/{page.js => page.mjs} | 8 ++--- examples/javascript/{test.ts => test.mts} | 4 +-- examples/minimal/BUILD.bazel | 8 ++--- examples/minimal/{dep.ts => dep.mts} | 2 +- examples/minimal/{page.ts => page.mts} | 2 +- examples/minimal/{test.ts => test.mts} | 4 +-- .../minimal/{transitive.ts => transitive.mts} | 0 examples/multi_page/BUILD.bazel | 6 ++-- examples/multi_page/{pages.ts => pages.mts} | 0 examples/multi_page/{script.ts => script.mts} | 0 examples/multi_page/{test.ts => test.mts} | 4 +-- examples/prerender_resources/BUILD.bazel | 6 ++-- .../{generator.ts => generator.mts} | 0 .../{generator_test.ts => generator_test.mts} | 0 examples/resources/BUILD.bazel | 4 +-- examples/resources/component/BUILD.bazel | 2 +- .../component/{component.ts => component.mts} | 2 +- examples/resources/{page.ts => page.mts} | 4 +-- examples/resources/{test.ts => test.mts} | 4 +-- examples/resources/transitive/BUILD.bazel | 2 +- .../{transitive.ts => transitive.mts} | 0 examples/script_isolation/BUILD.bazel | 8 ++--- examples/script_isolation/{bar.ts => bar.mts} | 0 examples/script_isolation/{foo.ts => foo.mts} | 0 .../script_isolation/{site.ts => site.mts} | 0 .../script_isolation/{test.ts => test.mts} | 4 +-- examples/scripts/BUILD.bazel | 6 ++-- examples/scripts/component/BUILD.bazel | 4 +-- .../component/{component.ts => component.mts} | 2 +- ...mponent_script.ts => component_script.mts} | 0 examples/scripts/{page.ts => page.mts} | 2 +- examples/scripts/{script.ts => script.mts} | 0 examples/scripts/{test.ts => test.mts} | 4 +-- examples/scripts/transitive/BUILD.bazel | 4 +-- .../{transitive.ts => transitive.mts} | 0 ...sitive_script.ts => transitive_script.mts} | 0 examples/shared_chunks/BUILD.bazel | 10 +++--- examples/shared_chunks/goodbye.mts | 3 ++ examples/shared_chunks/goodbye.ts | 3 -- examples/shared_chunks/hello.mts | 3 ++ examples/shared_chunks/hello.ts | 3 -- .../shared_chunks/{shared.ts => shared.mts} | 0 examples/shared_chunks/{site.ts => site.mts} | 0 examples/shared_chunks/{test.ts => test.mts} | 0 examples/site/about/BUILD.bazel | 2 +- examples/site/about/{about.ts => about.mts} | 4 +-- examples/site/blog/BUILD.bazel | 4 +-- examples/site/blog/{blog.ts => blog.mts} | 4 +-- .../site/blog/{blog_test.ts => blog_test.mts} | 2 +- examples/site/common/BUILD.bazel | 2 +- examples/site/common/{links.ts => links.mts} | 0 examples/site/components/base/BUILD.bazel | 4 +-- .../components/base/{base.ts => base.mts} | 4 +-- .../base/{base_test.ts => base_test.mts} | 2 +- examples/site/components/counter/BUILD.bazel | 10 +++--- ...ter_prerender.ts => counter_prerender.mts} | 0 ...der_test.ts => counter_prerender_test.mts} | 2 +- .../{counter_script.ts => counter_script.mts} | 0 .../{counter_test.ts => counter_test.mts} | 4 +-- ...r_test_cases.ts => counter_test_cases.mts} | 2 +- examples/site/components/footer/BUILD.bazel | 4 +-- .../footer/{footer.ts => footer.mts} | 2 +- .../{footer_test.ts => footer_test.mts} | 2 +- examples/site/components/header/BUILD.bazel | 4 +-- .../header/{header.ts => header.mts} | 0 .../{header_test.ts => header_test.mts} | 2 +- examples/site/counter/BUILD.bazel | 2 +- .../site/counter/{counter.ts => counter.mts} | 6 ++-- examples/site/home/BUILD.bazel | 4 +-- examples/site/home/{home.ts => home.mts} | 4 +-- .../site/home/{home_test.ts => home_test.mts} | 4 +-- examples/styles/BUILD.bazel | 4 +-- examples/styles/{page.ts => page.mts} | 0 examples/styles/{test.ts => test.mts} | 4 +-- examples/testonly/BUILD.bazel | 4 +-- examples/testonly/component/BUILD.bazel | 4 +-- .../component/{component.ts => component.mts} | 2 +- ...mponent_script.ts => component_script.mts} | 0 examples/testonly/{page.ts => page.mts} | 2 +- .../{page_script.ts => page_script.mts} | 0 examples/testonly/transitive/BUILD.bazel | 4 +-- .../{transitive.ts => transitive.mts} | 0 ...sitive_script.ts => transitive_script.mts} | 0 examples/tsconfig/BUILD.bazel | 2 +- examples/tsconfig/{page.ts => page.mts} | 0 examples/tsconfig/tsconfig.json | 3 +- examples/tsjs/BUILD.bazel | 14 ++++---- examples/tsjs/js_child/BUILD.bazel | 4 +-- .../{js_child.d.ts => js_child.d.mts} | 0 .../js_child/{js_child.js => js_child.mjs} | 4 +-- ...hild_script.d.ts => js_child_script.d.mts} | 0 ...js_child_script.js => js_child_script.mjs} | 0 examples/tsjs/js_parent/BUILD.bazel | 4 +-- .../{js_parent.d.ts => js_parent.d.mts} | 0 examples/tsjs/js_parent/js_parent.js | 12 ------- examples/tsjs/js_parent/js_parent.mjs | 10 ++++++ ..._parent_script.js => js_parent_script.mjs} | 0 examples/tsjs/{page.ts => page.mts} | 4 +-- examples/tsjs/{test.ts => test.mts} | 4 +-- examples/tsjs/ts_child/BUILD.bazel | 2 +- .../ts_child/{ts_child.ts => ts_child.mts} | 0 ...ts_child_script.ts => ts_child_script.mts} | 0 examples/tsjs/ts_parent/BUILD.bazel | 2 +- .../ts_parent/{ts_parent.ts => ts_parent.mts} | 2 +- ..._parent_script.ts => ts_parent_script.mts} | 2 +- package.json | 5 +-- packages/declarative_shadow_dom/BUILD.bazel | 6 ++-- ...adow_dom.ts => declarative_shadow_dom.mts} | 0 ...ts => declarative_shadow_dom_polyfill.mts} | 0 ...est.ts => declarative_shadow_dom_test.mts} | 4 +-- packages/declarative_shadow_dom/package.json | 3 +- packages/rules_prerender/BUILD.bazel | 21 ++++++----- .../rules_prerender/{index.ts => index.mts} | 8 ++--- ...line_style_map.ts => inline_style_map.mts} | 0 packages/rules_prerender/package.json | 6 ++++ ...rerender_component_publish_files_test.mts} | 24 ++++++------- .../BUILD.bazel | 8 ++--- .../{component.ts => component.mts} | 0 .../{prerender_dep.ts => prerender_dep.mts} | 0 .../{script.ts => script.mts} | 2 +- .../{script_dep.ts => script_dep.mts} | 0 .../rules_prerender/prerender_resources.bzl | 14 ++++---- .../{rollup.config.ts => rollup.config.mts} | 0 .../{scripts.ts => scripts.mts} | 2 +- .../{scripts_test.ts => scripts_test.mts} | 4 +-- .../rules_prerender/{styles.ts => styles.mts} | 4 +-- .../{styles_test.ts => styles_test.mts} | 6 ++-- .../binaries/annotation_extractor/BUILD.bazel | 14 ++++---- ..._extractor.ts => annotation_extractor.mts} | 14 ++++---- ..._test.ts => annotation_extractor_test.mts} | 10 +++--- .../{extractor.ts => extractor.mts} | 4 +-- .../{extractor_test.ts => extractor_test.mts} | 4 +-- .../{metadata.ts => metadata.mts} | 4 +-- .../{metadata_test.ts => metadata_test.mts} | 6 ++-- tools/binaries/css_bundler/BUILD.bazel | 6 ++-- .../{css_bundler.ts => css_bundler.mts} | 4 +-- ...s_bundler_test.ts => css_bundler_test.mts} | 4 +-- tools/binaries/renderer/BUILD.bazel | 8 ++--- .../{entry_point.ts => entry_point.mts} | 4 +-- ...try_point_test.ts => entry_point_test.mts} | 6 ++-- .../renderer/{renderer.ts => renderer.mts} | 6 ++-- .../{renderer_test.ts => renderer_test.mts} | 8 ++--- tools/binaries/resource_injector/BUILD.bazel | 12 +++---- .../{config.ts => config.mts} | 0 .../{injector.ts => injector.mts} | 6 ++-- .../{injector_test.ts => injector_test.mts} | 8 ++--- ...urce_injector.ts => resource_injector.mts} | 8 ++--- ...tor_test.ts => resource_injector_test.mts} | 6 ++-- tools/binaries/resource_packager/BUILD.bazel | 20 +++++------ .../{package_loader.ts => package_loader.mts} | 2 +- ...loader_test.ts => package_loader_test.mts} | 4 +-- .../{packager.ts => packager.mts} | 4 +-- .../{packager_test.ts => packager_test.mts} | 8 ++--- .../{resource_map.ts => resource_map.mts} | 0 ...urce_map_mock.ts => resource_map_mock.mts} | 4 +-- ...urce_map_test.ts => resource_map_test.mts} | 4 +-- ...urce_packager.ts => resource_packager.mts} | 10 +++--- ...ger_test.ts => resource_packager_test.mts} | 4 +-- .../script_entry_generator/BUILD.bazel | 10 +++--- .../{generator.ts => generator.mts} | 2 +- .../{generator_test.ts => generator_test.mts} | 4 +-- ...enerator.ts => script_entry_generator.mts} | 8 ++--- ...est.ts => script_entry_generator_test.mts} | 6 ++-- tools/jasmine/jasmine_node_test.bzl | 1 + tsconfig.json | 4 +-- 240 files changed, 455 insertions(+), 447 deletions(-) rename common/{binary.ts => binary.mts} (100%) rename common/{binary_test.ts => binary_test.mts} (97%) rename common/{collections.ts => collections.mts} (100%) rename common/{collections_test.ts => collections_test.mts} (95%) rename common/{file_system.ts => file_system.mts} (100%) rename common/{file_system_fake.ts => file_system_fake.mts} (97%) rename common/{formatters.ts => formatters.mts} (100%) rename common/{formatters_test.ts => formatters_test.mts} (95%) rename common/{http.ts => http.mts} (100%) rename common/{http_test.ts => http_test.mts} (98%) rename common/models/{prerender_annotation.ts => prerender_annotation.mts} (100%) rename common/models/{prerender_annotation_mock.ts => prerender_annotation_mock.mts} (97%) rename common/models/{prerender_annotation_test.ts => prerender_annotation_test.mts} (99%) rename common/models/{prerender_metadata.ts => prerender_metadata.mts} (100%) rename common/models/{prerender_metadata_mock.ts => prerender_metadata_mock.mts} (98%) rename common/models/{prerender_metadata_test.ts => prerender_metadata_test.mts} (98%) rename common/models/{prerender_resource.ts => prerender_resource.mts} (98%) rename common/models/{prerender_resource_test.ts => prerender_resource_test.mts} (96%) rename common/models/{url_path.ts => url_path.mts} (100%) rename common/models/{url_path_test.ts => url_path_test.mts} (91%) rename common/{prerender_annotation_walker.ts => prerender_annotation_walker.mts} (99%) rename common/{prerender_annotation_walker_test.ts => prerender_annotation_walker_test.mts} (98%) rename common/{probably.ts => probably.mts} (100%) rename common/{probably_test.ts => probably_test.mts} (96%) rename common/testing/{binary.ts => binary.mts} (100%) rename common/testing/{binary_test.ts => binary_test.mts} (93%) rename common/testing/{devserver.ts => devserver.mts} (98%) rename common/testing/{devserver_test.ts => devserver_test.mts} (94%) rename common/testing/{effect_fake.ts => effect_fake.mts} (89%) rename common/testing/{effect_fake_test.ts => effect_fake_test.mts} (85%) rename common/testing/{effect_tester.ts => effect_tester.mts} (99%) rename common/testing/{effect_tester_test.ts => effect_tester_test.mts} (96%) rename common/testing/{effects.ts => effects.mts} (100%) rename common/testing/{effects_test.ts => effects_test.mts} (98%) rename common/testing/{mocks.ts => mocks.mts} (100%) rename common/testing/{mocks_test.ts => mocks_test.mts} (96%) rename common/testing/{temp_dir.ts => temp_dir.mts} (96%) rename common/testing/{temp_dir_test.ts => temp_dir_test.mts} (92%) rename common/testing/{test_server.ts => test_server.mts} (100%) rename common/testing/{test_server_test.ts => test_server_test.mts} (93%) rename common/testing/{webdriver.ts => webdriver.mts} (97%) rename common/testing/{webdriver_test.ts => webdriver_test.mts} (90%) rename examples/components/{component.ts => component.mts} (83%) rename examples/components/{dep.ts => dep.mts} (79%) rename examples/components/{page.ts => page.mts} (88%) rename examples/components/{test.ts => test.mts} (92%) rename examples/components/{transitive.ts => transitive.mts} (100%) rename examples/components/{ts_dep.ts => ts_dep.mts} (100%) rename examples/data/{pages.ts => pages.mts} (100%) rename examples/data/{test.ts => test.mts} (95%) rename examples/declarative_shadow_dom/{component.ts => component.mts} (100%) rename examples/declarative_shadow_dom/{site.ts => site.mts} (90%) rename examples/declarative_shadow_dom/{test.ts => test.mts} (91%) rename examples/external/component/{component.ts => component.mts} (100%) rename examples/external/component/{script.ts => script.mts} (100%) rename examples/external/{site.ts => site.mts} (86%) rename examples/extract/{nested_resource.ts => nested_resource.mts} (100%) rename examples/extract/{single_resource.ts => single_resource.mts} (100%) rename examples/javascript/component/{component.js => component.mjs} (73%) rename examples/javascript/component/{component_script.js => component_script.mjs} (100%) rename examples/javascript/component/{component_script_dep.js => component_script_dep.mjs} (100%) rename examples/javascript/component/{component_script_unused.js => component_script_unused.mjs} (100%) rename examples/javascript/component/{prerender_lib.js => prerender_lib.mjs} (51%) rename examples/javascript/{page.js => page.mjs} (65%) rename examples/javascript/{test.ts => test.mts} (87%) rename examples/minimal/{dep.ts => dep.mts} (70%) rename examples/minimal/{page.ts => page.mts} (93%) rename examples/minimal/{test.ts => test.mts} (86%) rename examples/minimal/{transitive.ts => transitive.mts} (100%) rename examples/multi_page/{pages.ts => pages.mts} (100%) rename examples/multi_page/{script.ts => script.mts} (100%) rename examples/multi_page/{test.ts => test.mts} (96%) rename examples/prerender_resources/{generator.ts => generator.mts} (100%) rename examples/prerender_resources/{generator_test.ts => generator_test.mts} (100%) rename examples/resources/component/{component.ts => component.mts} (78%) rename examples/resources/{page.ts => page.mts} (88%) rename examples/resources/{test.ts => test.mts} (91%) rename examples/resources/transitive/{transitive.ts => transitive.mts} (100%) rename examples/script_isolation/{bar.ts => bar.mts} (100%) rename examples/script_isolation/{foo.ts => foo.mts} (100%) rename examples/script_isolation/{site.ts => site.mts} (100%) rename examples/script_isolation/{test.ts => test.mts} (93%) rename examples/scripts/component/{component.ts => component.mts} (87%) rename examples/scripts/component/{component_script.ts => component_script.mts} (100%) rename examples/scripts/{page.ts => page.mts} (91%) rename examples/scripts/{script.ts => script.mts} (100%) rename examples/scripts/{test.ts => test.mts} (91%) rename examples/scripts/transitive/{transitive.ts => transitive.mts} (100%) rename examples/scripts/transitive/{transitive_script.ts => transitive_script.mts} (100%) create mode 100644 examples/shared_chunks/goodbye.mts delete mode 100644 examples/shared_chunks/goodbye.ts create mode 100644 examples/shared_chunks/hello.mts delete mode 100644 examples/shared_chunks/hello.ts rename examples/shared_chunks/{shared.ts => shared.mts} (100%) rename examples/shared_chunks/{site.ts => site.mts} (100%) rename examples/shared_chunks/{test.ts => test.mts} (100%) rename examples/site/about/{about.ts => about.mts} (96%) rename examples/site/blog/{blog.ts => blog.mts} (96%) rename examples/site/blog/{blog_test.ts => blog_test.mts} (98%) rename examples/site/common/{links.ts => links.mts} (100%) rename examples/site/components/base/{base.ts => base.mts} (88%) rename examples/site/components/base/{base_test.ts => base_test.mts} (98%) rename examples/site/components/counter/{counter_prerender.ts => counter_prerender.mts} (100%) rename examples/site/components/counter/{counter_prerender_test.ts => counter_prerender_test.mts} (93%) rename examples/site/components/counter/{counter_script.ts => counter_script.mts} (100%) rename examples/site/components/counter/{counter_test.ts => counter_test.mts} (98%) rename examples/site/components/counter/{counter_test_cases.ts => counter_test_cases.mts} (95%) rename examples/site/components/footer/{footer.ts => footer.mts} (91%) rename examples/site/components/footer/{footer_test.ts => footer_test.mts} (91%) rename examples/site/components/header/{header.ts => header.mts} (100%) rename examples/site/components/header/{header_test.ts => header_test.mts} (94%) rename examples/site/counter/{counter.ts => counter.mts} (91%) rename examples/site/home/{home.ts => home.mts} (96%) rename examples/site/home/{home_test.ts => home_test.mts} (80%) rename examples/styles/{page.ts => page.mts} (100%) rename examples/styles/{test.ts => test.mts} (92%) rename examples/testonly/component/{component.ts => component.mts} (88%) rename examples/testonly/component/{component_script.ts => component_script.mts} (100%) rename examples/testonly/{page.ts => page.mts} (92%) rename examples/testonly/{page_script.ts => page_script.mts} (100%) rename examples/testonly/transitive/{transitive.ts => transitive.mts} (100%) rename examples/testonly/transitive/{transitive_script.ts => transitive_script.mts} (100%) rename examples/tsconfig/{page.ts => page.mts} (100%) rename examples/tsjs/js_child/{js_child.d.ts => js_child.d.mts} (100%) rename examples/tsjs/js_child/{js_child.js => js_child.mjs} (57%) rename examples/tsjs/{js_child_script.d.ts => js_child_script.d.mts} (100%) rename examples/tsjs/{js_child_script.js => js_child_script.mjs} (100%) rename examples/tsjs/js_parent/{js_parent.d.ts => js_parent.d.mts} (100%) delete mode 100644 examples/tsjs/js_parent/js_parent.js create mode 100644 examples/tsjs/js_parent/js_parent.mjs rename examples/tsjs/{js_parent_script.js => js_parent_script.mjs} (100%) rename examples/tsjs/{page.ts => page.mts} (95%) rename examples/tsjs/{test.ts => test.mts} (95%) rename examples/tsjs/ts_child/{ts_child.ts => ts_child.mts} (100%) rename examples/tsjs/{ts_child_script.ts => ts_child_script.mts} (100%) rename examples/tsjs/ts_parent/{ts_parent.ts => ts_parent.mts} (72%) rename examples/tsjs/{ts_parent_script.ts => ts_parent_script.mts} (72%) rename packages/declarative_shadow_dom/{declarative_shadow_dom.ts => declarative_shadow_dom.mts} (100%) rename packages/declarative_shadow_dom/{declarative_shadow_dom_polyfill.ts => declarative_shadow_dom_polyfill.mts} (100%) rename packages/declarative_shadow_dom/{declarative_shadow_dom_test.ts => declarative_shadow_dom_test.mts} (95%) rename packages/rules_prerender/{index.ts => index.mts} (72%) rename packages/rules_prerender/{inline_style_map.ts => inline_style_map.mts} (100%) create mode 100644 packages/rules_prerender/package.json rename packages/rules_prerender/{prerender_component_publish_files_test.ts => prerender_component_publish_files_test.mts} (72%) rename packages/rules_prerender/prerender_component_publish_files_testdata/{component.ts => component.mts} (100%) rename packages/rules_prerender/prerender_component_publish_files_testdata/{prerender_dep.ts => prerender_dep.mts} (100%) rename packages/rules_prerender/prerender_component_publish_files_testdata/{script.ts => script.mts} (56%) rename packages/rules_prerender/prerender_component_publish_files_testdata/{script_dep.ts => script_dep.mts} (100%) rename packages/rules_prerender/{rollup.config.ts => rollup.config.mts} (100%) rename packages/rules_prerender/{scripts.ts => scripts.mts} (96%) rename packages/rules_prerender/{scripts_test.ts => scripts_test.mts} (87%) rename packages/rules_prerender/{styles.ts => styles.mts} (96%) rename packages/rules_prerender/{styles_test.ts => styles_test.mts} (91%) rename tools/binaries/annotation_extractor/{annotation_extractor.ts => annotation_extractor.mts} (93%) rename tools/binaries/annotation_extractor/{annotation_extractor_test.ts => annotation_extractor_test.mts} (97%) rename tools/binaries/annotation_extractor/{extractor.ts => extractor.mts} (97%) rename tools/binaries/annotation_extractor/{extractor_test.ts => extractor_test.mts} (98%) rename tools/binaries/annotation_extractor/{metadata.ts => metadata.mts} (96%) rename tools/binaries/annotation_extractor/{metadata_test.ts => metadata_test.mts} (88%) rename tools/binaries/css_bundler/{css_bundler.ts => css_bundler.mts} (95%) rename tools/binaries/css_bundler/{css_bundler_test.ts => css_bundler_test.mts} (97%) rename tools/binaries/renderer/{entry_point.ts => entry_point.mts} (97%) rename tools/binaries/renderer/{entry_point_test.ts => entry_point_test.mts} (97%) rename tools/binaries/renderer/{renderer.ts => renderer.mts} (97%) rename tools/binaries/renderer/{renderer_test.ts => renderer_test.mts} (97%) rename tools/binaries/resource_injector/{config.ts => config.mts} (100%) rename tools/binaries/resource_injector/{injector.ts => injector.mts} (96%) rename tools/binaries/resource_injector/{injector_test.ts => injector_test.mts} (97%) rename tools/binaries/resource_injector/{resource_injector.ts => resource_injector.mts} (97%) rename tools/binaries/resource_injector/{resource_injector_test.ts => resource_injector_test.mts} (98%) rename tools/binaries/resource_packager/{package_loader.ts => package_loader.mts} (96%) rename tools/binaries/resource_packager/{package_loader_test.ts => package_loader_test.mts} (88%) rename tools/binaries/resource_packager/{packager.ts => packager.mts} (93%) rename tools/binaries/resource_packager/{packager_test.ts => packager_test.mts} (95%) rename tools/binaries/resource_packager/{resource_map.ts => resource_map.mts} (100%) rename tools/binaries/resource_packager/{resource_map_mock.ts => resource_map_mock.mts} (90%) rename tools/binaries/resource_packager/{resource_map_test.ts => resource_map_test.mts} (97%) rename tools/binaries/resource_packager/{resource_packager.ts => resource_packager.mts} (94%) rename tools/binaries/resource_packager/{resource_packager_test.ts => resource_packager_test.mts} (98%) rename tools/binaries/script_entry_generator/{generator.ts => generator.mts} (98%) rename tools/binaries/script_entry_generator/{generator_test.ts => generator_test.mts} (93%) rename tools/binaries/script_entry_generator/{script_entry_generator.ts => script_entry_generator.mts} (94%) rename tools/binaries/script_entry_generator/{script_entry_generator_test.ts => script_entry_generator_test.mts} (96%) diff --git a/common/BUILD.bazel b/common/BUILD.bazel index 4305e378..0c07f237 100644 --- a/common/BUILD.bazel +++ b/common/BUILD.bazel @@ -6,14 +6,14 @@ load(":paths_test.bzl", "paths_test_suite") ts_project( name = "binary", - srcs = ["binary.ts"], + srcs = ["binary.mts"], visibility = ["//visibility:public"], deps = ["//:node_modules/@types/node"], ) ts_project( name = "binary_test_lib", - srcs = ["binary_test.ts"], + srcs = ["binary_test.mts"], testonly = True, deps = [ ":binary", @@ -28,13 +28,13 @@ jasmine_node_test( ts_project( name = "collections", - srcs = ["collections.ts"], + srcs = ["collections.mts"], visibility = ["//visibility:public"], ) ts_project( name = "collections_test_lib", - srcs = ["collections_test.ts"], + srcs = ["collections_test.mts"], testonly = True, deps = [ ":collections", @@ -49,13 +49,13 @@ jasmine_node_test( ts_project( name = "formatters", - srcs = ["formatters.ts"], + srcs = ["formatters.mts"], visibility = ["//visibility:public"], ) ts_project( name = "formatters_test_lib", - srcs = ["formatters_test.ts"], + srcs = ["formatters_test.mts"], testonly = True, deps = [ ":formatters", @@ -70,14 +70,14 @@ jasmine_node_test( ts_project( name = "file_system", - srcs = ["file_system.ts"], + srcs = ["file_system.mts"], visibility = ["//visibility:public"], deps = ["//:node_modules/@types/node"], ) ts_project( name = "file_system_fake", - srcs = ["file_system_fake.ts"], + srcs = ["file_system_fake.mts"], visibility = ["//visibility:public"], testonly = True, deps = [ @@ -88,14 +88,14 @@ ts_project( ts_project( name = "http", - srcs = ["http.ts"], + srcs = ["http.mts"], visibility = ["//visibility:public"], deps = ["//:node_modules/@types/node"], ) ts_project( name = "http_test_lib", - srcs = ["http_test.ts"], + srcs = ["http_test.mts"], testonly = True, deps = [ ":http", @@ -139,7 +139,7 @@ paths_test_suite(name = "paths_test") ts_project( name = "prerender_annotation_walker", - srcs = ["prerender_annotation_walker.ts"], + srcs = ["prerender_annotation_walker.mts"], visibility = ["//visibility:public"], deps = [ "//common/models:prerender_annotation", @@ -149,7 +149,7 @@ ts_project( ts_project( name = "prerender_annotation_walker_test_lib", - srcs = ["prerender_annotation_walker_test.ts"], + srcs = ["prerender_annotation_walker_test.mts"], testonly = True, data = ["//:node_modules/node-html-parser"], deps = [ @@ -167,13 +167,13 @@ jasmine_node_test( ts_project( name = "probably", - srcs = ["probably.ts"], + srcs = ["probably.mts"], visibility = ["//visibility:public"], ) ts_project( name = "probably_test_lib", - srcs = ["probably_test.ts"], + srcs = ["probably_test.mts"], testonly = True, deps = [ ":probably", diff --git a/common/binary.ts b/common/binary.mts similarity index 100% rename from common/binary.ts rename to common/binary.mts diff --git a/common/binary_test.ts b/common/binary_test.mts similarity index 97% rename from common/binary_test.ts rename to common/binary_test.mts index 9fb68633..c882254b 100644 --- a/common/binary_test.ts +++ b/common/binary_test.mts @@ -1,4 +1,4 @@ -import { main as mainReal } from './binary'; +import { main as mainReal } from './binary.mjs'; // Wrap `main`'s type to return its `Promise` to easily `await` it. function main(...args: Parameters): Promise { diff --git a/common/collections.ts b/common/collections.mts similarity index 100% rename from common/collections.ts rename to common/collections.mts diff --git a/common/collections_test.ts b/common/collections_test.mts similarity index 95% rename from common/collections_test.ts rename to common/collections_test.mts index ce28c35b..5b70a388 100644 --- a/common/collections_test.ts +++ b/common/collections_test.mts @@ -1,4 +1,4 @@ -import { unique } from './collections'; +import { unique } from './collections.mjs'; describe('collections', () => { describe('unique()', () => { diff --git a/common/file_system.ts b/common/file_system.mts similarity index 100% rename from common/file_system.ts rename to common/file_system.mts diff --git a/common/file_system_fake.ts b/common/file_system_fake.mts similarity index 97% rename from common/file_system_fake.ts rename to common/file_system_fake.mts index c6684d47..9f9848f1 100644 --- a/common/file_system_fake.ts +++ b/common/file_system_fake.mts @@ -1,5 +1,5 @@ import * as path from 'path'; -import { FileSystem } from './file_system'; +import { FileSystem } from './file_system.mjs'; /** * A fake implementation of the `FileSystem` interface which stores everything diff --git a/common/formatters.ts b/common/formatters.mts similarity index 100% rename from common/formatters.ts rename to common/formatters.mts diff --git a/common/formatters_test.ts b/common/formatters_test.mts similarity index 95% rename from common/formatters_test.ts rename to common/formatters_test.mts index 47f2f40c..14d3c74c 100644 --- a/common/formatters_test.ts +++ b/common/formatters_test.mts @@ -1,4 +1,4 @@ -import { mdSpacing } from './formatters'; +import { mdSpacing } from './formatters.mjs'; describe('formatters', () => { describe('spaceMarkdown()', () => { diff --git a/common/http.ts b/common/http.mts similarity index 100% rename from common/http.ts rename to common/http.mts diff --git a/common/http_test.ts b/common/http_test.mts similarity index 98% rename from common/http_test.ts rename to common/http_test.mts index 61a0b54a..d96c45b6 100644 --- a/common/http_test.ts +++ b/common/http_test.mts @@ -1,6 +1,6 @@ import nodeHttp from 'http'; import { URL } from 'url'; -import * as http from './http'; +import * as http from './http.mjs'; describe('http', () => { describe('get', () => { diff --git a/common/models/BUILD.bazel b/common/models/BUILD.bazel index ddca76a4..9f9588d7 100644 --- a/common/models/BUILD.bazel +++ b/common/models/BUILD.bazel @@ -3,13 +3,13 @@ load("//tools/typescript:defs.bzl", "ts_project") ts_project( name = "prerender_annotation", - srcs = ["prerender_annotation.ts"], + srcs = ["prerender_annotation.mts"], visibility = ["//visibility:public"], ) ts_project( name = "prerender_annotation_test_lib", - srcs = ["prerender_annotation_test.ts"], + srcs = ["prerender_annotation_test.mts"], testonly = True, deps = [ ":prerender_annotation", @@ -24,7 +24,7 @@ jasmine_node_test( ts_project( name = "prerender_annotation_mock", - srcs = ["prerender_annotation_mock.ts"], + srcs = ["prerender_annotation_mock.mts"], testonly = True, visibility = ["//visibility:public"], deps = [":prerender_annotation"], @@ -32,13 +32,13 @@ ts_project( ts_project( name = "prerender_metadata", - srcs = ["prerender_metadata.ts"], + srcs = ["prerender_metadata.mts"], visibility = ["//visibility:public"], ) ts_project( name = "prerender_metadata_test_lib", - srcs = ["prerender_metadata_test.ts"], + srcs = ["prerender_metadata_test.mts"], testonly = True, deps = [ ":prerender_metadata", @@ -53,7 +53,7 @@ jasmine_node_test( ts_project( name = "prerender_metadata_mock", - srcs = ["prerender_metadata_mock.ts"], + srcs = ["prerender_metadata_mock.mts"], testonly = True, visibility = ["//visibility:public"], deps = [":prerender_metadata"], @@ -61,14 +61,14 @@ ts_project( ts_project( name = "prerender_resource", - srcs = ["prerender_resource.ts"], + srcs = ["prerender_resource.mts"], visibility = ["//visibility:public"], deps = [":url_path"], ) ts_project( name = "prerender_resource_test_lib", - srcs = ["prerender_resource_test.ts"], + srcs = ["prerender_resource_test.mts"], testonly = True, deps = [ ":prerender_resource", @@ -83,12 +83,12 @@ jasmine_node_test( ts_project( name = "url_path", - srcs = ["url_path.ts"], + srcs = ["url_path.mts"], ) ts_project( name = "url_path_test_lib", - srcs = ["url_path_test.ts"], + srcs = ["url_path_test.mts"], testonly = True, deps = [ ":url_path", diff --git a/common/models/prerender_annotation.ts b/common/models/prerender_annotation.mts similarity index 100% rename from common/models/prerender_annotation.ts rename to common/models/prerender_annotation.mts diff --git a/common/models/prerender_annotation_mock.ts b/common/models/prerender_annotation_mock.mts similarity index 97% rename from common/models/prerender_annotation_mock.ts rename to common/models/prerender_annotation_mock.mts index 7ef4ed7c..e0b56d75 100644 --- a/common/models/prerender_annotation_mock.ts +++ b/common/models/prerender_annotation_mock.mts @@ -3,7 +3,7 @@ * @see /README.md#Mocking */ -import { PrerenderAnnotation, ScriptAnnotation, StyleAnnotation } from './prerender_annotation'; +import { PrerenderAnnotation, ScriptAnnotation, StyleAnnotation } from './prerender_annotation.mjs'; /** * Mocks a {@link PrerenderAnnotation} object. Since this type is a diff --git a/common/models/prerender_annotation_test.ts b/common/models/prerender_annotation_test.mts similarity index 99% rename from common/models/prerender_annotation_test.ts rename to common/models/prerender_annotation_test.mts index 24c0ce0f..36573f10 100644 --- a/common/models/prerender_annotation_test.ts +++ b/common/models/prerender_annotation_test.mts @@ -1,4 +1,4 @@ -import { PrerenderAnnotation, createAnnotation, parseAnnotation, ScriptAnnotation, annotationsEqual, StyleAnnotation } from './prerender_annotation'; +import { PrerenderAnnotation, createAnnotation, parseAnnotation, ScriptAnnotation, annotationsEqual, StyleAnnotation } from './prerender_annotation.mjs'; describe('prerender_annotation', () => { describe('PrerenderAnnotation', () => { diff --git a/common/models/prerender_metadata.ts b/common/models/prerender_metadata.mts similarity index 100% rename from common/models/prerender_metadata.ts rename to common/models/prerender_metadata.mts diff --git a/common/models/prerender_metadata_mock.ts b/common/models/prerender_metadata_mock.mts similarity index 98% rename from common/models/prerender_metadata_mock.ts rename to common/models/prerender_metadata_mock.mts index b83c2014..5a4eff24 100644 --- a/common/models/prerender_metadata_mock.ts +++ b/common/models/prerender_metadata_mock.mts @@ -3,7 +3,7 @@ * @see /README.md#Mocking */ -import { PrerenderMetadata, ScriptMetadata } from './prerender_metadata'; +import { PrerenderMetadata, ScriptMetadata } from './prerender_metadata.mjs'; /** Mocks the {@link PrerenderMetadata} object with the given overrides. */ export function mockPrerenderMetadata( diff --git a/common/models/prerender_metadata_test.ts b/common/models/prerender_metadata_test.mts similarity index 98% rename from common/models/prerender_metadata_test.ts rename to common/models/prerender_metadata_test.mts index c1222f50..c4da255a 100644 --- a/common/models/prerender_metadata_test.ts +++ b/common/models/prerender_metadata_test.mts @@ -1,4 +1,4 @@ -import { PrerenderMetadata, ScriptMetadata } from './prerender_metadata'; +import { PrerenderMetadata, ScriptMetadata } from './prerender_metadata.mjs'; describe('prerender_metadata', () => { describe('PrerenderMetadata', () => { diff --git a/common/models/prerender_resource.ts b/common/models/prerender_resource.mts similarity index 98% rename from common/models/prerender_resource.ts rename to common/models/prerender_resource.mts index 7c7bb99b..b57012ff 100644 --- a/common/models/prerender_resource.ts +++ b/common/models/prerender_resource.mts @@ -1,4 +1,4 @@ -import { UrlPath } from './url_path'; +import { UrlPath } from './url_path.mjs'; /** Represents a resource to be rendered / generated at a particular path. */ export class PrerenderResource { diff --git a/common/models/prerender_resource_test.ts b/common/models/prerender_resource_test.mts similarity index 96% rename from common/models/prerender_resource_test.ts rename to common/models/prerender_resource_test.mts index 28a091eb..35e048f8 100644 --- a/common/models/prerender_resource_test.ts +++ b/common/models/prerender_resource_test.mts @@ -1,4 +1,4 @@ -import { PrerenderResource } from './prerender_resource'; +import { PrerenderResource } from './prerender_resource.mjs'; describe('PrerenderResource', () => { describe('of()', () => { diff --git a/common/models/url_path.ts b/common/models/url_path.mts similarity index 100% rename from common/models/url_path.ts rename to common/models/url_path.mts diff --git a/common/models/url_path_test.ts b/common/models/url_path_test.mts similarity index 91% rename from common/models/url_path_test.ts rename to common/models/url_path_test.mts index c8e6fae3..b9ed2680 100644 --- a/common/models/url_path_test.ts +++ b/common/models/url_path_test.mts @@ -1,4 +1,4 @@ -import { UrlPath } from './url_path'; +import { UrlPath } from './url_path.mjs'; describe('UrlPath', () => { describe('of()', () => { diff --git a/common/prerender_annotation_walker.ts b/common/prerender_annotation_walker.mts similarity index 99% rename from common/prerender_annotation_walker.ts rename to common/prerender_annotation_walker.mts index d1a2014e..f28dbba4 100644 --- a/common/prerender_annotation_walker.ts +++ b/common/prerender_annotation_walker.mts @@ -1,5 +1,5 @@ import { CommentNode, HTMLElement, Node } from 'node-html-parser'; -import { parseAnnotation, PrerenderAnnotation } from './models/prerender_annotation'; +import { parseAnnotation, PrerenderAnnotation } from './models/prerender_annotation.mjs'; /** * A reference to a `node-html-parser` `Node` which contains a @@ -138,4 +138,4 @@ function* walk(node: Node, parent?: HTMLElement): yield* walk(child, node); } } -} \ No newline at end of file +} diff --git a/common/prerender_annotation_walker_test.ts b/common/prerender_annotation_walker_test.mts similarity index 98% rename from common/prerender_annotation_walker_test.ts rename to common/prerender_annotation_walker_test.mts index 885e5833..b57238b6 100644 --- a/common/prerender_annotation_walker_test.ts +++ b/common/prerender_annotation_walker_test.mts @@ -1,6 +1,6 @@ import { HTMLElement, parse } from 'node-html-parser'; -import { createAnnotation } from './models/prerender_annotation'; -import { walkAllAnnotations } from './prerender_annotation_walker'; +import { createAnnotation } from './models/prerender_annotation.mjs'; +import { walkAllAnnotations } from './prerender_annotation_walker.mjs'; describe('prerender_annotation_walker', () => { describe('walkAllAnnotations()', () => { diff --git a/common/probably.ts b/common/probably.mts similarity index 100% rename from common/probably.ts rename to common/probably.mts diff --git a/common/probably_test.ts b/common/probably_test.mts similarity index 96% rename from common/probably_test.ts rename to common/probably_test.mts index 2255fb42..a12c90ed 100644 --- a/common/probably_test.ts +++ b/common/probably_test.mts @@ -1,4 +1,4 @@ -import { definitely, Definitely, Probably } from './probably'; +import { definitely, Definitely, Probably } from './probably.mjs'; interface User { name: string; diff --git a/common/testing/BUILD.bazel b/common/testing/BUILD.bazel index 0246a84f..89e0a66a 100644 --- a/common/testing/BUILD.bazel +++ b/common/testing/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/typescript:defs.bzl", "ts_project") ts_project( name = "binary", - srcs = ["binary.ts"], + srcs = ["binary.mts"], testonly = True, visibility = ["//visibility:public"], deps = ["//:node_modules/@types/node"], @@ -12,7 +12,7 @@ ts_project( ts_project( name = "binary_test_lib", - srcs = ["binary_test.ts"], + srcs = ["binary_test.mts"], testonly = True, deps = [ ":binary", @@ -29,7 +29,7 @@ jasmine_node_test( ts_project( name = "devserver", - srcs = ["devserver.ts"], + srcs = ["devserver.mts"], testonly = True, visibility = ["//visibility:public"], data = [ @@ -49,7 +49,7 @@ ts_project( ts_project( name = "devserver_test_lib", - srcs = ["devserver_test.ts"], + srcs = ["devserver_test.mts"], testonly = True, data = ["//:node_modules/http-status-codes"], deps = [ @@ -84,7 +84,7 @@ jasmine_node_test( ts_project( name = "effects", - srcs = ["effects.ts"], + srcs = ["effects.mts"], testonly = True, deps = [ "//:node_modules/@types/jasmine", @@ -93,7 +93,7 @@ ts_project( ts_project( name = "effects_test_lib", - srcs = ["effects_test.ts"], + srcs = ["effects_test.mts"], testonly = True, deps = [ ":effects", @@ -108,7 +108,7 @@ jasmine_node_test( ts_project( name = "effect_fake", - srcs = ["effect_fake.ts"], + srcs = ["effect_fake.mts"], testonly = True, visibility = ["//visibility:public"], deps = [":effects"], @@ -116,7 +116,7 @@ ts_project( ts_project( name = "effect_fake_test_lib", - srcs = ["effect_fake_test.ts"], + srcs = ["effect_fake_test.mts"], testonly = True, deps = [ ":effects", @@ -132,7 +132,7 @@ jasmine_node_test( ts_project( name = "effect_tester", - srcs = ["effect_tester.ts"], + srcs = ["effect_tester.mts"], testonly = True, visibility = ["//visibility:public"], deps = [ @@ -143,7 +143,7 @@ ts_project( ts_project( name = "effect_tester_test_lib", - srcs = ["effect_tester_test.ts"], + srcs = ["effect_tester_test.mts"], testonly = True, deps = [ ":effects", @@ -160,7 +160,7 @@ jasmine_node_test( ts_project( name = "mocks", - srcs = ["mocks.ts"], + srcs = ["mocks.mts"], testonly = True, visibility = ["//visibility:public"], deps = ["//:node_modules/@types/jasmine"], @@ -168,7 +168,7 @@ ts_project( ts_project( name = "mocks_test_lib", - srcs = ["mocks_test.ts"], + srcs = ["mocks_test.mts"], testonly = True, deps = [ ":mocks", @@ -183,7 +183,7 @@ jasmine_node_test( ts_project( name = "temp_dir", - srcs = ["temp_dir.ts"], + srcs = ["temp_dir.mts"], testonly = True, visibility = ["//visibility:public"], deps = [ @@ -194,7 +194,7 @@ ts_project( ts_project( name = "temp_dir_test_lib", - srcs = ["temp_dir_test.ts"], + srcs = ["temp_dir_test.mts"], testonly = True, deps = [ ":temp_dir", @@ -211,13 +211,13 @@ jasmine_node_test( ts_project( name = "test_server", - srcs = ["test_server.ts"], + srcs = ["test_server.mts"], testonly = True, ) ts_project( name = "test_server_test_lib", - srcs = ["test_server_test.ts"], + srcs = ["test_server_test.mts"], testonly = True, deps = [ ":test_server", @@ -232,7 +232,7 @@ jasmine_node_test( ts_project( name = "webdriver", - srcs = ["webdriver.ts"], + srcs = ["webdriver.mts"], testonly = True, visibility = ["//visibility:public"], data = ["//:node_modules/webdriverio"], @@ -246,7 +246,7 @@ ts_project( ts_project( name = "webdriver_test_lib", - srcs = ["webdriver_test.ts"], + srcs = ["webdriver_test.mts"], testonly = True, deps = [ ":devserver", diff --git a/common/testing/binary.ts b/common/testing/binary.mts similarity index 100% rename from common/testing/binary.ts rename to common/testing/binary.mts diff --git a/common/testing/binary_test.ts b/common/testing/binary_test.mts similarity index 93% rename from common/testing/binary_test.ts rename to common/testing/binary_test.mts index 8ce7e7ce..9dd12ee1 100644 --- a/common/testing/binary_test.ts +++ b/common/testing/binary_test.mts @@ -1,6 +1,6 @@ import { promises as fs } from 'fs'; -import { execBinary } from './binary'; -import { useTempDir } from './temp_dir'; +import { execBinary } from './binary.mjs'; +import { useTempDir } from './temp_dir.mjs'; describe('binary', () => { const tmpDir = useTempDir(); diff --git a/common/testing/devserver.ts b/common/testing/devserver.mts similarity index 98% rename from common/testing/devserver.ts rename to common/testing/devserver.mts index 03c22d56..b8db61f0 100644 --- a/common/testing/devserver.ts +++ b/common/testing/devserver.mts @@ -4,9 +4,9 @@ import killTree from 'tree-kill'; import net from 'net'; import { URL } from 'url'; import { promisify } from 'util'; -import * as http from '../http'; -import { Effect, useForAll } from './effects'; -import { TestServer } from './test_server'; +import * as http from '../http.mjs'; +import { Effect, useForAll } from './effects.mjs'; +import { TestServer } from './test_server.mjs'; type Signal = Parameters[0]; const execFile = promisify(execFileCb); diff --git a/common/testing/devserver_test.ts b/common/testing/devserver_test.mts similarity index 94% rename from common/testing/devserver_test.ts rename to common/testing/devserver_test.mts index 115283c4..cf3888b3 100644 --- a/common/testing/devserver_test.ts +++ b/common/testing/devserver_test.mts @@ -1,8 +1,8 @@ import { URL } from 'url'; import { StatusCodes } from 'http-status-codes'; -import * as http from '../http'; -import { Server, useDevserver } from './devserver'; -import { EffectTester } from './effect_tester'; +import * as http from '../http.mjs'; +import { Server, useDevserver } from './devserver.mjs'; +import { EffectTester } from './effect_tester.mjs'; const devserver = 'common/testing/devserver_test_server.sh'; diff --git a/common/testing/effect_fake.ts b/common/testing/effect_fake.mts similarity index 89% rename from common/testing/effect_fake.ts rename to common/testing/effect_fake.mts index 7c6cfa28..ce552c71 100644 --- a/common/testing/effect_fake.ts +++ b/common/testing/effect_fake.mts @@ -1,4 +1,4 @@ -import { Effect } from './effects'; +import { Effect } from './effects.mjs'; /** * Creates a fake implementation of an {@link Effect} which holds the provided diff --git a/common/testing/effect_fake_test.ts b/common/testing/effect_fake_test.mts similarity index 85% rename from common/testing/effect_fake_test.ts rename to common/testing/effect_fake_test.mts index 43979f2c..e76f6420 100644 --- a/common/testing/effect_fake_test.ts +++ b/common/testing/effect_fake_test.mts @@ -1,5 +1,5 @@ -import { Effect } from './effects'; -import { effectFake } from './effect_fake'; +import { Effect } from './effects.mjs'; +import { effectFake } from './effect_fake.mjs'; describe('effect_fake', () => { describe('effectFake()', () => { diff --git a/common/testing/effect_tester.ts b/common/testing/effect_tester.mts similarity index 99% rename from common/testing/effect_tester.ts rename to common/testing/effect_tester.mts index 880b6478..e1791bc1 100644 --- a/common/testing/effect_tester.ts +++ b/common/testing/effect_tester.mts @@ -1,4 +1,4 @@ -import { Effect } from './effects'; +import { Effect } from './effects.mjs'; /** * Utility class for testing effects. diff --git a/common/testing/effect_tester_test.ts b/common/testing/effect_tester_test.mts similarity index 96% rename from common/testing/effect_tester_test.ts rename to common/testing/effect_tester_test.mts index a77ca476..9eba53fb 100644 --- a/common/testing/effect_tester_test.ts +++ b/common/testing/effect_tester_test.mts @@ -1,6 +1,6 @@ -import { useForEach } from './effects'; -import { effectFake } from './effect_fake'; -import { EffectTester } from './effect_tester'; +import { useForEach } from './effects.mjs'; +import { effectFake } from './effect_fake.mjs'; +import { EffectTester } from './effect_tester.mjs'; describe('EffectTester', () => { it('tests effects', async () => { diff --git a/common/testing/effects.ts b/common/testing/effects.mts similarity index 100% rename from common/testing/effects.ts rename to common/testing/effects.mts diff --git a/common/testing/effects_test.ts b/common/testing/effects_test.mts similarity index 98% rename from common/testing/effects_test.ts rename to common/testing/effects_test.mts index 0d1cad65..aa5789db 100644 --- a/common/testing/effects_test.ts +++ b/common/testing/effects_test.mts @@ -1,4 +1,4 @@ -import { useForAll, useForEach } from './effects'; +import { useForAll, useForEach } from './effects.mjs'; describe('effects', () => { describe('useForEach()', () => { diff --git a/common/testing/mocks.ts b/common/testing/mocks.mts similarity index 100% rename from common/testing/mocks.ts rename to common/testing/mocks.mts diff --git a/common/testing/mocks_test.ts b/common/testing/mocks_test.mts similarity index 96% rename from common/testing/mocks_test.ts rename to common/testing/mocks_test.mts index 3a766a63..7cbe1fcc 100644 --- a/common/testing/mocks_test.ts +++ b/common/testing/mocks_test.mts @@ -1,4 +1,4 @@ -import { unmockedFunc } from './mocks'; +import { unmockedFunc } from './mocks.mjs'; describe('mocks', () => { describe('unmockedFunc()', () => { diff --git a/common/testing/temp_dir.ts b/common/testing/temp_dir.mts similarity index 96% rename from common/testing/temp_dir.ts rename to common/testing/temp_dir.mts index 916cc40c..95a85f92 100644 --- a/common/testing/temp_dir.ts +++ b/common/testing/temp_dir.mts @@ -1,6 +1,6 @@ import { promises as fs } from 'fs'; import { env } from 'process'; -import { Effect, useForEach } from './effects'; +import { Effect, useForEach } from './effects.mjs'; /** * Creates an {@link Effect} of a temporary directory. The directory is deleted diff --git a/common/testing/temp_dir_test.ts b/common/testing/temp_dir_test.mts similarity index 92% rename from common/testing/temp_dir_test.ts rename to common/testing/temp_dir_test.mts index 18d56502..dad9d267 100644 --- a/common/testing/temp_dir_test.ts +++ b/common/testing/temp_dir_test.mts @@ -1,6 +1,6 @@ import { env } from 'process'; -import { useTempDir } from './temp_dir'; -import { EffectTester } from './effect_tester'; +import { useTempDir } from './temp_dir.mjs'; +import { EffectTester } from './effect_tester.mjs'; const originalTempDir = env['TEST_TMPDIR']; describe('temp_dir', () => { diff --git a/common/testing/test_server.ts b/common/testing/test_server.mts similarity index 100% rename from common/testing/test_server.ts rename to common/testing/test_server.mts diff --git a/common/testing/test_server_test.ts b/common/testing/test_server_test.mts similarity index 93% rename from common/testing/test_server_test.ts rename to common/testing/test_server_test.mts index 9c376448..e30e98c1 100644 --- a/common/testing/test_server_test.ts +++ b/common/testing/test_server_test.mts @@ -1,4 +1,4 @@ -import { TestServer } from './test_server'; +import { TestServer } from './test_server.mjs'; describe('test_server', () => { describe('TestServer', () => { diff --git a/common/testing/webdriver.ts b/common/testing/webdriver.mts similarity index 97% rename from common/testing/webdriver.ts rename to common/testing/webdriver.mts index 5cb355fe..24f49dc7 100644 --- a/common/testing/webdriver.ts +++ b/common/testing/webdriver.mts @@ -4,8 +4,8 @@ import { remote, ChainablePromiseElement } from 'webdriverio'; import { env } from 'process'; -import { Effect, useForAll } from './effects'; -import { TestServer } from './test_server'; +import { Effect, useForAll } from './effects.mjs'; +import { TestServer } from './test_server.mjs'; /** * Default timeout value to use for WebDriver tests. They can be quite resource diff --git a/common/testing/webdriver_test.ts b/common/testing/webdriver_test.mts similarity index 90% rename from common/testing/webdriver_test.ts rename to common/testing/webdriver_test.mts index 3af76560..3d79f549 100644 --- a/common/testing/webdriver_test.ts +++ b/common/testing/webdriver_test.mts @@ -1,6 +1,6 @@ -import { useDevserver } from './devserver'; -import { EffectTester } from './effect_tester'; -import { useWebDriver, webDriverTestTimeout } from './webdriver'; +import { useDevserver } from './devserver.mjs'; +import { EffectTester } from './effect_tester.mjs'; +import { useWebDriver, webDriverTestTimeout } from './webdriver.mjs'; describe('webdriver', () => { describe('useWebDriver()', () => { diff --git a/examples/components/BUILD.bazel b/examples/components/BUILD.bazel index 7be6b26b..cabf7462 100644 --- a/examples/components/BUILD.bazel +++ b/examples/components/BUILD.bazel @@ -9,7 +9,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "page", - src = "page.ts", + src = "page.mts", tsconfig = "//:tsconfig", source_map = True, bundle_js = False, # Optimization: No client-side JavaScript on this page. @@ -19,7 +19,7 @@ prerender_pages( prerender_component( name = "component", - srcs = ["component.ts"], + srcs = ["component.mts"], tsconfig = "//:tsconfig", source_map = True, lib_deps = [":ts_dep"], @@ -28,12 +28,12 @@ prerender_component( ts_project( name = "ts_dep", - srcs = ["ts_dep.ts"], + srcs = ["ts_dep.mts"], ) prerender_component( name = "dep", - srcs = ["dep.ts"], + srcs = ["dep.mts"], tsconfig = "//:tsconfig", source_map = True, deps = [":transitive"], @@ -41,7 +41,7 @@ prerender_component( prerender_component( name = "transitive", - srcs = ["transitive.ts"], + srcs = ["transitive.mts"], tsconfig = "//:tsconfig", source_map = True, ) @@ -53,7 +53,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/components/component.ts b/examples/components/component.mts similarity index 83% rename from examples/components/component.ts rename to examples/components/component.mts index 9c406279..6cfd18b3 100644 --- a/examples/components/component.ts +++ b/examples/components/component.mts @@ -1,5 +1,5 @@ -import { tsDep } from './ts_dep'; -import { render as renderDep } from './dep'; +import { tsDep } from './ts_dep.mjs'; +import { render as renderDep } from './dep.mjs'; /** Prerenders this component using other components. */ export function render(): string { diff --git a/examples/components/dep.ts b/examples/components/dep.mts similarity index 79% rename from examples/components/dep.ts rename to examples/components/dep.mts index bddf8ead..d13dbe67 100644 --- a/examples/components/dep.ts +++ b/examples/components/dep.mts @@ -1,4 +1,4 @@ -import { render as renderTransitive } from './transitive'; +import { render as renderTransitive } from './transitive.mjs'; export function render(): string { return ` diff --git a/examples/components/page.ts b/examples/components/page.mts similarity index 88% rename from examples/components/page.ts rename to examples/components/page.mts index 9cba8fb6..a7bc4608 100644 --- a/examples/components/page.ts +++ b/examples/components/page.mts @@ -1,5 +1,5 @@ import { PrerenderResource } from 'rules_prerender'; -import { render as renderComponent } from './component'; +import { render as renderComponent } from './component.mjs'; /** Renders a page using components. */ export default function*(): Generator { diff --git a/examples/components/test.ts b/examples/components/test.mts similarity index 92% rename from examples/components/test.ts rename to examples/components/test.mts index 7c505751..2262d70a 100644 --- a/examples/components/test.ts +++ b/examples/components/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('components', () => { const devserver = useDevserver('examples/components/devserver.sh'); diff --git a/examples/components/transitive.ts b/examples/components/transitive.mts similarity index 100% rename from examples/components/transitive.ts rename to examples/components/transitive.mts diff --git a/examples/components/ts_dep.ts b/examples/components/ts_dep.mts similarity index 100% rename from examples/components/ts_dep.ts rename to examples/components/ts_dep.mts diff --git a/examples/data/BUILD.bazel b/examples/data/BUILD.bazel index 643eefbc..0ef16c25 100644 --- a/examples/data/BUILD.bazel +++ b/examples/data/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "pages", - src = "pages.ts", + src = "pages.mts", tsconfig = "//:tsconfig", source_map = True, data = glob(["content/*.txt"]), @@ -22,7 +22,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/data/pages.ts b/examples/data/pages.mts similarity index 100% rename from examples/data/pages.ts rename to examples/data/pages.mts diff --git a/examples/data/test.ts b/examples/data/test.mts similarity index 95% rename from examples/data/test.ts rename to examples/data/test.mts index 4d5c1816..177ed6ce 100644 --- a/examples/data/test.ts +++ b/examples/data/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('data', () => { const devserver = useDevserver('examples/data/devserver.sh'); diff --git a/examples/declarative_shadow_dom/BUILD.bazel b/examples/declarative_shadow_dom/BUILD.bazel index 1d36c58c..2c8247b2 100644 --- a/examples/declarative_shadow_dom/BUILD.bazel +++ b/examples/declarative_shadow_dom/BUILD.bazel @@ -10,7 +10,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "site", - src = "site.ts", + src = "site.mts", tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], @@ -19,7 +19,7 @@ prerender_pages( prerender_component( name = "component", - srcs = ["component.ts"], + srcs = ["component.mts"], tsconfig = "//:tsconfig", source_map = True, styles = [":styles"], @@ -39,7 +39,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], data = [":devserver"], testonly = True, deps = [ diff --git a/examples/declarative_shadow_dom/component.ts b/examples/declarative_shadow_dom/component.mts similarity index 100% rename from examples/declarative_shadow_dom/component.ts rename to examples/declarative_shadow_dom/component.mts diff --git a/examples/declarative_shadow_dom/site.ts b/examples/declarative_shadow_dom/site.mts similarity index 90% rename from examples/declarative_shadow_dom/site.ts rename to examples/declarative_shadow_dom/site.mts index 34e527eb..e3672cce 100644 --- a/examples/declarative_shadow_dom/site.ts +++ b/examples/declarative_shadow_dom/site.mts @@ -1,5 +1,5 @@ import { PrerenderResource } from 'rules_prerender'; -import { renderComponent } from './component'; +import { renderComponent } from './component.mjs'; export default async function*(): AsyncGenerator { yield PrerenderResource.of('/index.html', ` diff --git a/examples/declarative_shadow_dom/test.ts b/examples/declarative_shadow_dom/test.mts similarity index 91% rename from examples/declarative_shadow_dom/test.ts rename to examples/declarative_shadow_dom/test.mts index 196594ff..4bd7b7b4 100644 --- a/examples/declarative_shadow_dom/test.ts +++ b/examples/declarative_shadow_dom/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('Declarative Shadow DOM', () => { const devserver = useDevserver('examples/declarative_shadow_dom/devserver.sh'); diff --git a/examples/external/BUILD.bazel b/examples/external/BUILD.bazel index 14729cce..fcf1a8ea 100644 --- a/examples/external/BUILD.bazel +++ b/examples/external/BUILD.bazel @@ -43,7 +43,7 @@ ts_config( prerender_pages( name = "site", - src = "site.ts", + src = "site.mts", source_map = True, tsconfig = "//:tsconfig", lib_deps = ["//:node_modules/rules_prerender"], diff --git a/examples/external/component/BUILD.bazel b/examples/external/component/BUILD.bazel index 0ff2bc59..707264ba 100644 --- a/examples/external/component/BUILD.bazel +++ b/examples/external/component/BUILD.bazel @@ -8,7 +8,7 @@ load( prerender_component( name = "component", - srcs = ["component.ts"], + srcs = ["component.mts"], scripts = [":script"], styles = [":style"], resources = [":resources"], @@ -21,7 +21,7 @@ prerender_component( ts_project( name = "script", - srcs = ["script.ts"], + srcs = ["script.mts"], declaration = True, source_map = True, tsconfig = "//:tsconfig_client", diff --git a/examples/external/component/component.ts b/examples/external/component/component.mts similarity index 100% rename from examples/external/component/component.ts rename to examples/external/component/component.mts diff --git a/examples/external/component/script.ts b/examples/external/component/script.mts similarity index 100% rename from examples/external/component/script.ts rename to examples/external/component/script.mts diff --git a/examples/external/site.ts b/examples/external/site.mts similarity index 86% rename from examples/external/site.ts rename to examples/external/site.mts index dbb6e6e6..ee207235 100644 --- a/examples/external/site.ts +++ b/examples/external/site.mts @@ -1,5 +1,5 @@ import { PrerenderResource } from 'rules_prerender'; -import { renderComponent } from './component/component'; +import { renderComponent } from './component/component.mjs'; export default function*(): Generator { yield PrerenderResource.of('/index.html', ` diff --git a/examples/external/tsconfig.json b/examples/external/tsconfig.json index ec2b0998..a467a361 100644 --- a/examples/external/tsconfig.json +++ b/examples/external/tsconfig.json @@ -2,7 +2,8 @@ "exclude": ["**/dist/"], "compilerOptions": { "target": "ES2020", - "module": "CommonJS", + "module": "ES2020", + "moduleResolution": "node", "declaration": true, "sourceMap": true, "paths": { diff --git a/examples/extract/BUILD.bazel b/examples/extract/BUILD.bazel index 55d30ce1..8df291e6 100644 --- a/examples/extract/BUILD.bazel +++ b/examples/extract/BUILD.bazel @@ -3,7 +3,7 @@ load("//:index.bzl", "extract_single_resource", "prerender_pages_unbundled") prerender_pages_unbundled( name = "single_resource", - src = "single_resource.ts", + src = "single_resource.mts", tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], @@ -23,7 +23,7 @@ diff_test( prerender_pages_unbundled( name = "nested_resource", - src = "nested_resource.ts", + src = "nested_resource.mts", tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], diff --git a/examples/extract/nested_resource.ts b/examples/extract/nested_resource.mts similarity index 100% rename from examples/extract/nested_resource.ts rename to examples/extract/nested_resource.mts diff --git a/examples/extract/single_resource.ts b/examples/extract/single_resource.mts similarity index 100% rename from examples/extract/single_resource.ts rename to examples/extract/single_resource.mts diff --git a/examples/javascript/BUILD.bazel b/examples/javascript/BUILD.bazel index 39dd371e..5c407ec2 100644 --- a/examples/javascript/BUILD.bazel +++ b/examples/javascript/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "page", - src = "page.js", + src = "page.mjs", lib_deps = ["//:node_modules/rules_prerender"], deps = ["//examples/javascript/component"], ) @@ -16,7 +16,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/javascript/component/BUILD.bazel b/examples/javascript/component/BUILD.bazel index d24b86a7..4298ce2a 100644 --- a/examples/javascript/component/BUILD.bazel +++ b/examples/javascript/component/BUILD.bazel @@ -3,7 +3,7 @@ load("//:index.bzl", "prerender_component") prerender_component( name = "component", - srcs = ["component.js"], + srcs = ["component.mjs"], lib_deps = [ ":prerender_lib", "//:node_modules/rules_prerender", @@ -17,21 +17,21 @@ prerender_component( js_library( name = "prerender_lib", - srcs = ["prerender_lib.js"], + srcs = ["prerender_lib.mjs"], ) js_library( name = "component_script", - srcs = ["component_script.js"], + srcs = ["component_script.mjs"], deps = [":component_script_dep"], ) js_library( name = "component_script_dep", - srcs = ["component_script_dep.js"], + srcs = ["component_script_dep.mjs"], ) js_library( name = "component_script_unused", - srcs = ["component_script_unused.js"], + srcs = ["component_script_unused.mjs"], ) diff --git a/examples/javascript/component/component.js b/examples/javascript/component/component.mjs similarity index 73% rename from examples/javascript/component/component.js rename to examples/javascript/component/component.mjs index 143ef06e..30cd39ba 100644 --- a/examples/javascript/component/component.js +++ b/examples/javascript/component/component.mjs @@ -1,8 +1,8 @@ -const { includeScript } = require('rules_prerender'); -const { content } = require('./prerender_lib'); +import { includeScript } from 'rules_prerender'; +import { content } from './prerender_lib.mjs'; /** Renders an example component with a script. */ -function renderComponent() { +export function renderComponent() { return `
${content}
@@ -16,11 +16,9 @@ ${includeScript('examples/javascript/component/component_script')} * Renders an example component with a script. This is never called and should * not be seen in the output. Used to validate tree-shaking of JS scripts. */ -function renderUnused() { +export function renderUnused() { return `
ERROR: Should never be rendered.
${includeScript('examples/javascript/component/component_script_unused')} `.trim(); } - -module.exports = { renderComponent, renderUnused }; diff --git a/examples/javascript/component/component_script.js b/examples/javascript/component/component_script.mjs similarity index 100% rename from examples/javascript/component/component_script.js rename to examples/javascript/component/component_script.mjs diff --git a/examples/javascript/component/component_script_dep.js b/examples/javascript/component/component_script_dep.mjs similarity index 100% rename from examples/javascript/component/component_script_dep.js rename to examples/javascript/component/component_script_dep.mjs diff --git a/examples/javascript/component/component_script_unused.js b/examples/javascript/component/component_script_unused.mjs similarity index 100% rename from examples/javascript/component/component_script_unused.js rename to examples/javascript/component/component_script_unused.mjs diff --git a/examples/javascript/component/prerender_lib.js b/examples/javascript/component/prerender_lib.mjs similarity index 51% rename from examples/javascript/component/prerender_lib.js rename to examples/javascript/component/prerender_lib.mjs index d58023e0..e9057927 100644 --- a/examples/javascript/component/prerender_lib.js +++ b/examples/javascript/component/prerender_lib.mjs @@ -1,5 +1,3 @@ /** @fileoverview JS file to be used as a dependency of a prerender library. */ -const content = 'Hello from a JS component!'; - -module.exports = { content }; +export const content = 'Hello from a JS component!'; diff --git a/examples/javascript/page.js b/examples/javascript/page.mjs similarity index 65% rename from examples/javascript/page.js rename to examples/javascript/page.mjs index 784e0a63..ef257f57 100644 --- a/examples/javascript/page.js +++ b/examples/javascript/page.mjs @@ -1,8 +1,8 @@ -const { PrerenderResource } = require('rules_prerender'); -const { renderComponent } = require('./component/component'); +import { PrerenderResource } from 'rules_prerender'; +import { renderComponent } from './component/component.mjs'; /* Renders the page. */ -module.exports = function*() { +export default function* () { yield PrerenderResource.of('/index.html', ` @@ -16,4 +16,4 @@ module.exports = function*() { `.trim()); -}; +} diff --git a/examples/javascript/test.ts b/examples/javascript/test.mts similarity index 87% rename from examples/javascript/test.ts rename to examples/javascript/test.mts index d98171c1..4c0cc25c 100644 --- a/examples/javascript/test.ts +++ b/examples/javascript/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('JavaScript', () => { const devserver = useDevserver('examples/javascript/devserver.sh'); diff --git a/examples/minimal/BUILD.bazel b/examples/minimal/BUILD.bazel index ba4a4c8a..68b2db77 100644 --- a/examples/minimal/BUILD.bazel +++ b/examples/minimal/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "page", - src = "page.ts", + src = "page.mts", tsconfig = "//:tsconfig", source_map = True, bundle_js = False, # Optimization: No client-side JavaScript on this page. @@ -16,13 +16,13 @@ prerender_pages( ts_project( name = "dep", - srcs = ["dep.ts"], + srcs = ["dep.mts"], deps = [":transitive"], ) ts_project( name = "transitive", - srcs = ["transitive.ts"], + srcs = ["transitive.mts"], ) web_resources_devserver( @@ -32,7 +32,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/minimal/dep.ts b/examples/minimal/dep.mts similarity index 70% rename from examples/minimal/dep.ts rename to examples/minimal/dep.mts index d066fbfe..b29fd9b6 100644 --- a/examples/minimal/dep.ts +++ b/examples/minimal/dep.mts @@ -2,4 +2,4 @@ export const foo = 'foo'; // Re-export a transitive dependency. -export { bar } from './transitive'; +export { bar } from './transitive.mjs'; diff --git a/examples/minimal/page.ts b/examples/minimal/page.mts similarity index 93% rename from examples/minimal/page.ts rename to examples/minimal/page.mts index 783f1683..9eeaea25 100644 --- a/examples/minimal/page.ts +++ b/examples/minimal/page.mts @@ -1,4 +1,4 @@ -import { bar, foo } from './dep'; +import { bar, foo } from './dep.mjs'; import { PrerenderResource } from 'rules_prerender'; /** Renders the page. */ diff --git a/examples/minimal/test.ts b/examples/minimal/test.mts similarity index 86% rename from examples/minimal/test.ts rename to examples/minimal/test.mts index 49a9d255..7cbb475b 100644 --- a/examples/minimal/test.ts +++ b/examples/minimal/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('minimal', () => { const devserver = useDevserver('examples/minimal/devserver.sh'); diff --git a/examples/minimal/transitive.ts b/examples/minimal/transitive.mts similarity index 100% rename from examples/minimal/transitive.ts rename to examples/minimal/transitive.mts diff --git a/examples/multi_page/BUILD.bazel b/examples/multi_page/BUILD.bazel index 79cde98f..7b31c79f 100644 --- a/examples/multi_page/BUILD.bazel +++ b/examples/multi_page/BUILD.bazel @@ -10,7 +10,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "pages", - src = "pages.ts", + src = "pages.mts", tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], @@ -26,7 +26,7 @@ css_library( ts_project( name = "script", - srcs = ["script.ts"], + srcs = ["script.mts"], tsconfig = "//:tsconfig_client", ) @@ -44,7 +44,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/multi_page/pages.ts b/examples/multi_page/pages.mts similarity index 100% rename from examples/multi_page/pages.ts rename to examples/multi_page/pages.mts diff --git a/examples/multi_page/script.ts b/examples/multi_page/script.mts similarity index 100% rename from examples/multi_page/script.ts rename to examples/multi_page/script.mts diff --git a/examples/multi_page/test.ts b/examples/multi_page/test.mts similarity index 96% rename from examples/multi_page/test.ts rename to examples/multi_page/test.mts index 9861df83..bcad379c 100644 --- a/examples/multi_page/test.ts +++ b/examples/multi_page/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { getColor, useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('multi_page', () => { const devserver = useDevserver('examples/multi_page/devserver.sh'); diff --git a/examples/prerender_resources/BUILD.bazel b/examples/prerender_resources/BUILD.bazel index a36f3145..086d3b7c 100644 --- a/examples/prerender_resources/BUILD.bazel +++ b/examples/prerender_resources/BUILD.bazel @@ -4,19 +4,19 @@ load("//tools/jasmine:defs.bzl", "jasmine_node_test") ts_project( name = "generator", - srcs = ["generator.ts"], + srcs = ["generator.mts"], deps = ["//:node_modules/rules_prerender"], ) prerender_resources( name = "prerender", - entry_point = "./generator.js", + entry_point = "./generator.mjs", data = [":generator"], ) ts_project( name = "generator_test", - srcs = ["generator_test.ts"], + srcs = ["generator_test.mts"], testonly = True, data = [":prerender"], deps = [ diff --git a/examples/prerender_resources/generator.ts b/examples/prerender_resources/generator.mts similarity index 100% rename from examples/prerender_resources/generator.ts rename to examples/prerender_resources/generator.mts diff --git a/examples/prerender_resources/generator_test.ts b/examples/prerender_resources/generator_test.mts similarity index 100% rename from examples/prerender_resources/generator_test.ts rename to examples/prerender_resources/generator_test.mts diff --git a/examples/resources/BUILD.bazel b/examples/resources/BUILD.bazel index 83f7f030..c40b5966 100644 --- a/examples/resources/BUILD.bazel +++ b/examples/resources/BUILD.bazel @@ -9,7 +9,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "page", - src = "page.ts", + src = "page.mts", tsconfig = "//:tsconfig", source_map = True, bundle_js = False, # Optimization: No client-side JavaScript on this page. @@ -36,7 +36,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/resources/component/BUILD.bazel b/examples/resources/component/BUILD.bazel index 4d1109a3..a263f99f 100644 --- a/examples/resources/component/BUILD.bazel +++ b/examples/resources/component/BUILD.bazel @@ -3,7 +3,7 @@ load("//:index.bzl", "prerender_component", "web_resources") prerender_component( name = "component", - srcs = ["component.ts"], + srcs = ["component.mts"], tsconfig = "//:tsconfig", source_map = True, resources = [":resources"], diff --git a/examples/resources/component/component.ts b/examples/resources/component/component.mts similarity index 78% rename from examples/resources/component/component.ts rename to examples/resources/component/component.mts index 1e493470..37c08008 100644 --- a/examples/resources/component/component.ts +++ b/examples/resources/component/component.mts @@ -1,4 +1,4 @@ -import { renderTransitive } from '../transitive/transitive'; +import { renderTransitive } from '../transitive/transitive.mjs'; export function renderComponent(): string { return ` diff --git a/examples/resources/page.ts b/examples/resources/page.mts similarity index 88% rename from examples/resources/page.ts rename to examples/resources/page.mts index d11b2c76..47e2e01a 100644 --- a/examples/resources/page.ts +++ b/examples/resources/page.mts @@ -1,6 +1,6 @@ import { PrerenderResource } from 'rules_prerender'; -import { renderComponent } from './component/component'; -import { renderTransitive } from './transitive/transitive'; +import { renderComponent } from './component/component.mjs'; +import { renderTransitive } from './transitive/transitive.mjs'; export default function*(): Generator { yield PrerenderResource.of('/index.html', ` diff --git a/examples/resources/test.ts b/examples/resources/test.mts similarity index 91% rename from examples/resources/test.ts rename to examples/resources/test.mts index 20491a81..df865848 100644 --- a/examples/resources/test.ts +++ b/examples/resources/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('resources', () => { const devserver = useDevserver('examples/resources/devserver.sh'); diff --git a/examples/resources/transitive/BUILD.bazel b/examples/resources/transitive/BUILD.bazel index 54cc73af..c04c6c99 100644 --- a/examples/resources/transitive/BUILD.bazel +++ b/examples/resources/transitive/BUILD.bazel @@ -2,7 +2,7 @@ load("//:index.bzl", "prerender_component", "web_resources") prerender_component( name = "transitive", - srcs = ["transitive.ts"], + srcs = ["transitive.mts"], tsconfig = "//:tsconfig", source_map = True, resources = [":resources"], diff --git a/examples/resources/transitive/transitive.ts b/examples/resources/transitive/transitive.mts similarity index 100% rename from examples/resources/transitive/transitive.ts rename to examples/resources/transitive/transitive.mts diff --git a/examples/script_isolation/BUILD.bazel b/examples/script_isolation/BUILD.bazel index 783641ef..8c98797c 100644 --- a/examples/script_isolation/BUILD.bazel +++ b/examples/script_isolation/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "site", - src = "site.ts", + src = "site.mts", scripts = [":foo", ":bar"], tsconfig = "//:tsconfig", source_map = True, @@ -13,13 +13,13 @@ prerender_pages( ts_project( name = "foo", - srcs = ["foo.ts"], + srcs = ["foo.mts"], tsconfig = "//:tsconfig_client", ) ts_project( name = "bar", - srcs = ["bar.ts"], + srcs = ["bar.mts"], tsconfig = "//:tsconfig_client", ) @@ -30,7 +30,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//:node_modules/@types/jasmine", diff --git a/examples/script_isolation/bar.ts b/examples/script_isolation/bar.mts similarity index 100% rename from examples/script_isolation/bar.ts rename to examples/script_isolation/bar.mts diff --git a/examples/script_isolation/foo.ts b/examples/script_isolation/foo.mts similarity index 100% rename from examples/script_isolation/foo.ts rename to examples/script_isolation/foo.mts diff --git a/examples/script_isolation/site.ts b/examples/script_isolation/site.mts similarity index 100% rename from examples/script_isolation/site.ts rename to examples/script_isolation/site.mts diff --git a/examples/script_isolation/test.ts b/examples/script_isolation/test.mts similarity index 93% rename from examples/script_isolation/test.ts rename to examples/script_isolation/test.mts index 3c31350b..b731c56f 100644 --- a/examples/script_isolation/test.ts +++ b/examples/script_isolation/test.mts @@ -1,5 +1,5 @@ -import { useDevserver } from '../../common/testing/devserver'; -import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver'; +import { useDevserver } from '../../common/testing/devserver.mjs'; +import { useWebDriver, webDriverTestTimeout } from '../../common/testing/webdriver.mjs'; describe('Script Isolation', () => { const devserver = useDevserver('examples/script_isolation/devserver.sh'); diff --git a/examples/scripts/BUILD.bazel b/examples/scripts/BUILD.bazel index f5ea8bbb..032b0e61 100644 --- a/examples/scripts/BUILD.bazel +++ b/examples/scripts/BUILD.bazel @@ -4,7 +4,7 @@ load("//tools/jasmine:defs.bzl", "jasmine_web_test_suite") prerender_pages( name = "page", - src = "page.ts", + src = "page.mts", tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], @@ -14,7 +14,7 @@ prerender_pages( ts_project( name = "script", - srcs = ["script.ts"], + srcs = ["script.mts"], tsconfig = "//:tsconfig_client", ) @@ -25,7 +25,7 @@ web_resources_devserver( ts_project( name = "test_lib", - srcs = ["test.ts"], + srcs = ["test.mts"], testonly = True, deps = [ "//common/testing:devserver", diff --git a/examples/scripts/component/BUILD.bazel b/examples/scripts/component/BUILD.bazel index bf1013fb..cbc6d8e5 100644 --- a/examples/scripts/component/BUILD.bazel +++ b/examples/scripts/component/BUILD.bazel @@ -3,7 +3,7 @@ load("//:index.bzl", "prerender_component") prerender_component( name = "component", - srcs = ["component.ts"], + srcs = ["component.mts"], tsconfig = "//:tsconfig", source_map = True, lib_deps = ["//:node_modules/rules_prerender"], @@ -14,6 +14,6 @@ prerender_component( ts_project( name = "component_script", - srcs = ["component_script.ts"], + srcs = ["component_script.mts"], tsconfig = "//:tsconfig_client", ) diff --git a/examples/scripts/component/component.ts b/examples/scripts/component/component.mts similarity index 87% rename from examples/scripts/component/component.ts rename to examples/scripts/component/component.mts index 54a6e280..4d4fc942 100644 --- a/examples/scripts/component/component.ts +++ b/examples/scripts/component/component.mts @@ -1,5 +1,5 @@ import { includeScript } from 'rules_prerender'; -import { renderTransitive } from '../transitive/transitive'; +import { renderTransitive } from '../transitive/transitive.mjs'; /** Renders HTML which expects a JavaScript library to be included. */ export function renderComponent(): string { diff --git a/examples/scripts/component/component_script.ts b/examples/scripts/component/component_script.mts similarity index 100% rename from examples/scripts/component/component_script.ts rename to examples/scripts/component/component_script.mts diff --git a/examples/scripts/page.ts b/examples/scripts/page.mts similarity index 91% rename from examples/scripts/page.ts rename to examples/scripts/page.mts index a5e3f117..6d14d3d1 100644 --- a/examples/scripts/page.ts +++ b/examples/scripts/page.mts @@ -1,5 +1,5 @@ import { PrerenderResource, includeScript } from 'rules_prerender'; -import { renderComponent } from './component/component'; +import { renderComponent } from './component/component.mjs'; /** Render some HTML with a `