diff --git a/.prettierignore b/.prettierignore index 14ef4c357..d6e63a9d3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,9 +3,9 @@ docs/*_*.md e2e/**/*-docs.md examples/**/*-docs.md js/private/coverage/coverage.js -js/private/node-patches/fs.js +js/private/node-patches/fs.cjs min/ npm/private/test/vendored/ js/private/worker/worker.js js/private/worker/src/worker_protocol.ts -js/private/js_image_layer.mjs \ No newline at end of file +js/private/js_image_layer.mjs diff --git a/docs/README.md b/docs/README.md index 1da132199..cabddef55 100644 --- a/docs/README.md +++ b/docs/README.md @@ -187,11 +187,11 @@ load("@npm//:typescript/package_json.bzl", typescript_bin = "bin") typescript_bin.tsc( name = "compile", srcs = [ - "fs.ts", + "fs.cts", "tsconfig.json", "//:node_modules/@types/node", ], - outs = ["fs.js"], + outs = ["fs.cjs"], chdir = package_name(), args = ["-p", "tsconfig.json"], ) diff --git a/e2e/bzlmod/package.json b/e2e/bzlmod/package.json index 55a3bdb22..3a8254296 100644 --- a/e2e/bzlmod/package.json +++ b/e2e/bzlmod/package.json @@ -1,5 +1,6 @@ { "private": true, + "type": "module", "dependencies": { "chalk": "5.3.0", "less": "4.1.3", diff --git a/e2e/js_image_docker/README.md b/e2e/js_image_docker/README.md index 223fd77ce..cefc41e5f 100644 --- a/e2e/js_image_docker/README.md +++ b/e2e/js_image_docker/README.md @@ -64,8 +64,8 @@ app | | `-- js | | `-- private | | `-- node-patches -| | |-- fs.js -| | `-- register.js +| | |-- fs.cjs +| | `-- register.cjs | |-- bazel_tools | | `-- tools | | `-- bash diff --git a/e2e/js_image_oci/README.md b/e2e/js_image_oci/README.md index f58857529..7e162ba4a 100644 --- a/e2e/js_image_oci/README.md +++ b/e2e/js_image_oci/README.md @@ -37,8 +37,8 @@ app | | `-- js | | `-- private | | `-- node-patches -| | |-- fs.js -| | `-- register.js +| | |-- fs.cjs +| | `-- register.cjs | |-- bazel_tools | | `-- tools | | `-- bash diff --git a/e2e/npm_link_package-esm/package.json b/e2e/npm_link_package-esm/package.json index ae854800d..2353b9bb4 100644 --- a/e2e/npm_link_package-esm/package.json +++ b/e2e/npm_link_package-esm/package.json @@ -1,5 +1,6 @@ { "name": "simple", + "type": "module", "dependencies": { "@aspect-test/a": "5.0.2", "sharp": "0.32.1", diff --git a/e2e/repo_mapping/package.json b/e2e/repo_mapping/package.json index 8e6a823bd..dc5cb8af2 100644 --- a/e2e/repo_mapping/package.json +++ b/e2e/repo_mapping/package.json @@ -1,5 +1,6 @@ { "private": true, + "type": "module", "dependencies": { "chalk": "5.3.0" } diff --git a/js/private/js_binary.bzl b/js/private/js_binary.bzl index c29a50a2b..5baa777d7 100644 --- a/js/private/js_binary.bzl +++ b/js/private/js_binary.bzl @@ -315,11 +315,11 @@ _ATTRS = { "_windows_constraint": attr.label(default = "@platforms//os:windows"), "_node_patches_files": attr.label_list( allow_files = True, - default = [Label("@aspect_rules_js//js/private/node-patches:fs.js")], + default = [Label("@aspect_rules_js//js/private/node-patches:fs.cjs")], ), "_node_patches": attr.label( allow_single_file = True, - default = Label("@aspect_rules_js//js/private/node-patches:register.js"), + default = Label("@aspect_rules_js//js/private/node-patches:register.cjs"), ), } diff --git a/js/private/node-patches/BUILD.bazel b/js/private/node-patches/BUILD.bazel index 03a32ecf2..d6af777ee 100644 --- a/js/private/node-patches/BUILD.bazel +++ b/js/private/node-patches/BUILD.bazel @@ -3,11 +3,11 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") write_source_files( name = "checked_in_compile", files = { - "fs.js": "//js/private/node-patches/src:fs-generated.js", + "fs.cjs": "//js/private/node-patches/src:fs-generated.cjs", }, ) exports_files([ - "fs.js", - "register.js", + "fs.cjs", + "register.cjs", ]) diff --git a/js/private/node-patches/fs.js b/js/private/node-patches/fs.cjs similarity index 100% rename from js/private/node-patches/fs.js rename to js/private/node-patches/fs.cjs diff --git a/js/private/node-patches/register.js b/js/private/node-patches/register.cjs similarity index 97% rename from js/private/node-patches/register.js rename to js/private/node-patches/register.cjs index 607afeb37..944e576ae 100644 --- a/js/private/node-patches/register.js +++ b/js/private/node-patches/register.cjs @@ -1,4 +1,4 @@ -const patchfs = require('./fs').patcher +const patchfs = require('./fs.cjs').patcher const { JS_BINARY__FS_PATCH_ROOTS, JS_BINARY__LOG_DEBUG, diff --git a/js/private/node-patches/src/BUILD.bazel b/js/private/node-patches/src/BUILD.bazel index 5b6ffc67b..5ed1769c5 100644 --- a/js/private/node-patches/src/BUILD.bazel +++ b/js/private/node-patches/src/BUILD.bazel @@ -3,12 +3,12 @@ load("@npm//:typescript/package_json.bzl", typescript_bin = "bin") typescript_bin.tsc( name = "compile", srcs = [ - "fs.ts", + "fs.cts", "tsconfig.json", "//:node_modules/@types/node", ], outs = [ - "fs.js", + "fs.cjs", ], args = [ "-p", @@ -20,8 +20,8 @@ typescript_bin.tsc( genrule( name = "fs_generated", - srcs = ["fs.js"], - outs = ["fs-generated.js"], - cmd = "echo \"// Generated by //js/private/node-patches:compile\" > $@ && cat $(execpath :fs.js) >> $@", + srcs = ["fs.cjs"], + outs = ["fs-generated.cjs"], + cmd = "echo \"// Generated by //js/private/node-patches:compile\" > $@ && cat $(execpath :fs.cjs) >> $@", visibility = ["//js/private/node-patches:__pkg__"], ) diff --git a/js/private/node-patches/src/fs.ts b/js/private/node-patches/src/fs.cts similarity index 100% rename from js/private/node-patches/src/fs.ts rename to js/private/node-patches/src/fs.cts diff --git a/js/private/node-patches/src/tsconfig.json b/js/private/node-patches/src/tsconfig.json index a171f2e0d..c8f887d64 100644 --- a/js/private/node-patches/src/tsconfig.json +++ b/js/private/node-patches/src/tsconfig.json @@ -3,5 +3,5 @@ "module": "commonjs", "target": "es2017" }, - "include": ["*.ts"] + "include": ["*.cts"] } diff --git a/js/private/test/image/checksum.expected b/js/private/test/image/checksum.expected index 559f95e36..d4ed000c6 100644 --- a/js/private/test/image/checksum.expected +++ b/js/private/test/image/checksum.expected @@ -1,5 +1,5 @@ -71282f1d6f069723a2030909e98cfbc181430da6e33a1158cca1112c8705ad9a js/private/test/image/cksum_app.tar -1158897106dbb52f3fcd7b5c5c6ea9f3e4a992fa701041b7756c0e4cb6f7a8b3 js/private/test/image/cksum_node.tar +f600a91e4d70057892e2a548d9cc6072a2afce6e091afa97184ee159bd012a13 js/private/test/image/cksum_app.tar +c603eafdacc184f3df28ef966704cd580bf5f53c7d599f77132abaac45c110fc js/private/test/image/cksum_node.tar c7e5a122704601296eed4b106e5a323ab8fc267c36355784a9538aff9b7ed20b js/private/test/image/cksum_node_modules.tar 9395e137de4767edfdd663bc6010a597844bdb68663f8b3ecb036175122bcb2f js/private/test/image/cksum_package_store_1p.tar 842c83159aa2f59c53678ed4cc7d0e23d7e1ea9de0f80af272d1694300bd8012 js/private/test/image/cksum_package_store_3p.tar diff --git a/js/private/test/image/custom_owner_app.listing b/js/private/test/image/custom_owner_app.listing index 21e2f6ac0..e66a07da0 100644 --- a/js/private/test/image/custom_owner_app.listing +++ b/js/private/test/image/custom_owner_app.listing @@ -17,7 +17,7 @@ drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.ru drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_ --r-xr-xr-x 0 100 0 23908 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin +-r-xr-xr-x 0 100 0 23910 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin -r-xr-xr-x 0 100 0 133 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin/node -r-xr-xr-x 0 100 0 20 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/main.js diff --git a/js/private/test/image/custom_owner_node.listing b/js/private/test/image/custom_owner_node.listing index 0278e3fe1..cc78f0f82 100644 --- a/js/private/test/image/custom_owner_node.listing +++ b/js/private/test/image/custom_owner_node.listing @@ -8,8 +8,8 @@ drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.ru drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches --r-xr-xr-x 0 100 0 32555 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/fs.js --r-xr-xr-x 0 100 0 1698 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/register.js +-r-xr-xr-x 0 100 0 32555 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/fs.cjs +-r-xr-xr-x 0 100 0 1702 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/register.cjs drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64 drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64/bin drwxr-xr-x 0 100 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64/bin/nodejs diff --git a/js/private/test/image/default_app.listing b/js/private/test/image/default_app.listing index ebc885a4d..d43c9ff84 100644 --- a/js/private/test/image/default_app.listing +++ b/js/private/test/image/default_app.listing @@ -17,7 +17,7 @@ drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.ru drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_ --r-xr-xr-x 0 0 0 23908 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin +-r-xr-xr-x 0 0 0 23910 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_/bin drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin -r-xr-xr-x 0 0 0 133 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/bin_node_bin/node -r-xr-xr-x 0 0 0 20 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/test/image/main.js diff --git a/js/private/test/image/default_node.listing b/js/private/test/image/default_node.listing index b063f3798..bd8ba9e16 100644 --- a/js/private/test/image/default_node.listing +++ b/js/private/test/image/default_node.listing @@ -8,8 +8,8 @@ drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.ru drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches --r-xr-xr-x 0 0 0 32555 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/fs.js --r-xr-xr-x 0 0 0 1698 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/register.js +-r-xr-xr-x 0 0 0 32555 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/fs.cjs +-r-xr-xr-x 0 0 0 1702 Jan 1 1970 app/js/private/test/image/bin.runfiles/aspect_rules_js/js/private/node-patches/register.cjs drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64 drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64/bin drwxr-xr-x 0 0 0 0 Jan 1 1970 app/js/private/test/image/bin.runfiles/nodejs_linux_amd64/bin/nodejs diff --git a/js/private/test/node-patches/escape.js b/js/private/test/node-patches/escape.js index ac83864f7..9761f352b 100644 --- a/js/private/test/node-patches/escape.js +++ b/js/private/test/node-patches/escape.js @@ -16,8 +16,8 @@ */ const assert = require('assert') const path = require('path') -const escapeFunction = require('../../node-patches/src/fs').escapeFunction -const isSubPath = require('../../node-patches/src/fs').isSubPath +const escapeFunction = require('../../node-patches/src/fs.cjs').escapeFunction +const isSubPath = require('../../node-patches/src/fs.cjs').isSubPath // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/node-patches/lstat.js b/js/private/test/node-patches/lstat.js index 138cb826c..1c3c8e7d5 100644 --- a/js/private/test/node-patches/lstat.js +++ b/js/private/test/node-patches/lstat.js @@ -20,7 +20,7 @@ const withFixtures = require('inline-fixtures').withFixtures const path = require('path') const util = require('util') -const patcher = require('../../node-patches/src/fs').patcher +const patcher = require('../../node-patches/src/fs.cjs').patcher // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/node-patches/opendir.js b/js/private/test/node-patches/opendir.js index 8e844a6b5..f6c4dd462 100644 --- a/js/private/test/node-patches/opendir.js +++ b/js/private/test/node-patches/opendir.js @@ -20,7 +20,7 @@ const withFixtures = require('inline-fixtures').withFixtures const path = require('path') const util = require('util') -const patcher = require('../../node-patches/src/fs').patcher +const patcher = require('../../node-patches/src/fs.cjs').patcher // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/node-patches/readdir.js b/js/private/test/node-patches/readdir.js index b227a6af2..df3ce626d 100644 --- a/js/private/test/node-patches/readdir.js +++ b/js/private/test/node-patches/readdir.js @@ -20,7 +20,7 @@ const withFixtures = require('inline-fixtures').withFixtures const path = require('path') const util = require('util') -const patcher = require('../../node-patches/src/fs').patcher +const patcher = require('../../node-patches/src/fs.cjs').patcher // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/node-patches/readlink.js b/js/private/test/node-patches/readlink.js index bd18a3850..21797a8f7 100644 --- a/js/private/test/node-patches/readlink.js +++ b/js/private/test/node-patches/readlink.js @@ -20,7 +20,7 @@ const withFixtures = require('inline-fixtures').withFixtures const path = require('path') const util = require('util') -const patcher = require('../../node-patches/src/fs').patcher +const patcher = require('../../node-patches/src/fs.cjs').patcher // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/node-patches/realpath.js b/js/private/test/node-patches/realpath.js index 39b8d9a1b..c316387e2 100644 --- a/js/private/test/node-patches/realpath.js +++ b/js/private/test/node-patches/realpath.js @@ -20,7 +20,7 @@ const withFixtures = require('inline-fixtures').withFixtures const path = require('path') const util = require('util') -const patcher = require('../../node-patches/src/fs').patcher +const patcher = require('../../node-patches/src/fs.cjs').patcher // We don't want to bring jest into this repo so we just fake the describe and it functions here async function describe(_, fn) { diff --git a/js/private/test/snapshots/bzlmod/launcher.sh b/js/private/test/snapshots/bzlmod/launcher.sh index 16938dc01..106b436e3 100644 --- a/js/private/test/snapshots/bzlmod/launcher.sh +++ b/js/private/test/snapshots/bzlmod/launcher.sh @@ -434,9 +434,9 @@ fi if [ "${JS_BINARY__NO_RUNFILES:-}" ]; then export JS_BINARY__NODE_PATCHES - JS_BINARY__NODE_PATCHES=$(resolve_execroot_src_path "js/private/node-patches/register.js") + JS_BINARY__NODE_PATCHES=$(resolve_execroot_src_path "js/private/node-patches/register.cjs") else - export JS_BINARY__NODE_PATCHES="$JS_BINARY__RUNFILES/_main/js/private/node-patches/register.js" + export JS_BINARY__NODE_PATCHES="$JS_BINARY__RUNFILES/_main/js/private/node-patches/register.cjs" fi if [ ! -f "$JS_BINARY__NODE_PATCHES" ]; then logf_fatal "node patches '%s' not found" "$JS_BINARY__NODE_PATCHES" diff --git a/js/private/test/snapshots/wksp/launcher.sh b/js/private/test/snapshots/wksp/launcher.sh index f3c4dd14c..29501144f 100644 --- a/js/private/test/snapshots/wksp/launcher.sh +++ b/js/private/test/snapshots/wksp/launcher.sh @@ -434,9 +434,9 @@ fi if [ "${JS_BINARY__NO_RUNFILES:-}" ]; then export JS_BINARY__NODE_PATCHES - JS_BINARY__NODE_PATCHES=$(resolve_execroot_src_path "js/private/node-patches/register.js") + JS_BINARY__NODE_PATCHES=$(resolve_execroot_src_path "js/private/node-patches/register.cjs") else - export JS_BINARY__NODE_PATCHES="$JS_BINARY__RUNFILES/aspect_rules_js/js/private/node-patches/register.js" + export JS_BINARY__NODE_PATCHES="$JS_BINARY__RUNFILES/aspect_rules_js/js/private/node-patches/register.cjs" fi if [ ! -f "$JS_BINARY__NODE_PATCHES" ]; then logf_fatal "node patches '%s' not found" "$JS_BINARY__NODE_PATCHES"