Skip to content

Commit

Permalink
fix: use .cjs extension for fs patches
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jun 26, 2024
1 parent b1dc67f commit 4d48034
Show file tree
Hide file tree
Showing 28 changed files with 48 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
js/private/js_image_layer.mjs
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand Down
1 change: 1 addition & 0 deletions e2e/bzlmod/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"private": true,
"type": "module",
"dependencies": {
"chalk": "5.3.0",
"less": "4.1.3",
Expand Down
4 changes: 2 additions & 2 deletions e2e/js_image_docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ app
| | `-- js
| | `-- private
| | `-- node-patches
| | |-- fs.js
| | `-- register.js
| | |-- fs.cjs
| | `-- register.cjs
| |-- bazel_tools
| | `-- tools
| | `-- bash
Expand Down
4 changes: 2 additions & 2 deletions e2e/js_image_oci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ app
| | `-- js
| | `-- private
| | `-- node-patches
| | |-- fs.js
| | `-- register.js
| | |-- fs.cjs
| | `-- register.cjs
| |-- bazel_tools
| | `-- tools
| | `-- bash
Expand Down
6 changes: 6 additions & 0 deletions e2e/npm_link_package-esm/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
1 change: 1 addition & 0 deletions e2e/npm_link_package-esm/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "simple",
"type": "module",
"dependencies": {
"@aspect-test/a": "5.0.2",
"sharp": "0.32.1",
Expand Down
1 change: 1 addition & 0 deletions e2e/repo_mapping/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"private": true,
"type": "module",
"dependencies": {
"chalk": "5.3.0"
}
Expand Down
4 changes: 2 additions & 2 deletions js/private/js_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
}

Expand Down
6 changes: 3 additions & 3 deletions js/private/node-patches/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
])
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 5 additions & 5 deletions js/private/node-patches/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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__"],
)
File renamed without changes.
2 changes: 1 addition & 1 deletion js/private/node-patches/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"module": "commonjs",
"target": "es2017"
},
"include": ["*.ts"]
"include": ["*.cts"]
}
4 changes: 2 additions & 2 deletions js/private/test/image/checksum.expected
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion js/private/test/image/custom_owner_app.listing
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions js/private/test/image/custom_owner_node.listing
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/image/default_app.listing
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions js/private/test/image/default_node.listing
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions js/private/test/node-patches/escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/node-patches/lstat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/node-patches/opendir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/node-patches/readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/node-patches/readlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion js/private/test/node-patches/realpath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions js/private/test/snapshots/bzlmod/launcher.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/private/test/snapshots/wksp/launcher.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d48034

Please sign in to comment.