Skip to content

Commit d945dbf

Browse files
committed
revert back to rules_nodejs 6.3
1 parent 85cfa5c commit d945dbf

5 files changed

Lines changed: 74 additions & 2 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bazel_dep(name = "bazel_features", version = "1.9.0")
1414
bazel_dep(name = "bazel_lib", version = "3.0.0")
1515
bazel_dep(name = "bazel_skylib", version = "1.5.0")
1616
bazel_dep(name = "platforms", version = "0.0.5")
17-
bazel_dep(name = "rules_nodejs", version = "6.4.0")
17+
bazel_dep(name = "rules_nodejs", version = "6.3.0")
1818
bazel_dep(name = "yq.bzl", version = "0.3.2")
1919

2020
tel = use_extension("@aspect_tools_telemetry//:extension.bzl", "telemetry")

js/private/test/node-patches/BUILD.bazel

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
22
load("@npm//:@babel/cli/package_json.bzl", babel_bin = "bin")
3-
load("//js:defs.bzl", "js_test")
3+
load("//js:defs.bzl", "js_library", "js_test")
44

55
TESTS = [
66
"escape.js",
@@ -160,3 +160,29 @@ babel_bin.babel(
160160
TOOLCHAINS_VERSIONS,
161161
)
162162
]
163+
164+
# TODO: this doesn't fail with patch_node_esm_loader=False, need failing test!!
165+
[
166+
js_test(
167+
name = "esm_test_%s" % toolchain_name,
168+
data = [":lib"],
169+
entry_point = "esm.mjs",
170+
node_toolchain = toolchain,
171+
patch_node_esm_loader = True,
172+
patch_node_fs = True,
173+
)
174+
for toolchain_name, toolchain in zip(
175+
TOOLCHAINS_NAMES,
176+
TOOLCHAINS_VERSIONS,
177+
)
178+
if toolchain_name != "node16" # ESM json loading not supported on Node 16
179+
]
180+
181+
# A basic library with esm imports, esm json data etc
182+
js_library(
183+
name = "lib",
184+
srcs = [
185+
"data.json",
186+
"lib.mjs",
187+
],
188+
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "json-data",
3+
"answer": 42
4+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { fileURLToPath } from 'url'
2+
import { dirname } from 'node:path'
3+
import { data2, data3, my__dirname, my__filename, my__pwd } from './lib.mjs'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = dirname(__filename)
7+
8+
console.log('process.cwd():', my__pwd)
9+
console.log('data2:', data2)
10+
console.log('data3:', data3)
11+
12+
if (my__dirname !== __dirname) {
13+
throw new Error('__dirname does not match expected value')
14+
}
15+
16+
if (my__pwd !== process.cwd()) {
17+
throw new Error('process.cwd() does not match expected value')
18+
}
19+
20+
if (dirname(my__filename) !== dirname(__filename)) {
21+
throw new Error('__filename does not match expected value')
22+
}
23+
24+
if (
25+
dirname(__filename) !=
26+
dirname(fileURLToPath(import.meta.resolve('./lib2.mjs')))
27+
) {
28+
throw new Error('import.meta.resolve does not match expected value')
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { fileURLToPath } from 'url'
2+
import { dirname } from 'path'
3+
import data from './data.json' with { type: 'json' }
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = dirname(__filename)
7+
8+
export const my__dirname = __dirname
9+
export const my__filename = __filename
10+
export const my__pwd = process.cwd()
11+
12+
export const data2 = data
13+
export const data3 = { ...data, addedKey: 'addedValue' }

0 commit comments

Comments
 (0)