11load ("@aspect_bazel_lib//lib:copy_to_bin.bzl" , "copy_to_bin" )
2- load ("@npm//:@babel/cli/package_json.bzl" , babel_bin = "bin" )
3- load ("//js:defs.bzl" , "js_test" )
2+ load ("@npm//:defs.bzl" , "npm_link_all_packages" )
3+ load ("@npm//js/private/test/node-patches:@babel/cli/package_json.bzl" , babel_bin = "bin" )
4+ load ("//js:defs.bzl" , "js_library" , "js_test" )
45
56TESTS = [
67 "escape.js" ,
@@ -37,6 +38,8 @@ TOOLCHAINS_VERSIONS = [
3738 for n in TOOLCHAINS_NAMES
3839]
3940
41+ npm_link_all_packages ()
42+
4043# We need to copy the entry points to the bin so that the tests below don't follow the execroot
4144# symlink back to the source tree since the fs patches are not on for the tests as they are the code
4245# under test
@@ -48,12 +51,17 @@ TOOLCHAINS_VERSIONS = [
4851 for t in TESTS + MJS_TESTS
4952]
5053
54+ js_library (
55+ name = "babel_config" ,
56+ srcs = ["babel.config.js" ],
57+ deps = [
58+ ":node_modules/@babel/plugin-transform-modules-commonjs" ,
59+ ],
60+ )
61+
5162babel_bin .babel (
5263 name = "babel_mjs2js" ,
53- srcs = MJS_TESTS + [
54- "babel.config.js" ,
55- "//:node_modules/@babel/plugin-transform-modules-commonjs" ,
56- ],
64+ srcs = MJS_TESTS + [":babel_config" ],
5765 outs = [t .replace (".mjs" , ".cjs" ) for t in MJS_TESTS ],
5866 args = [
5967 "--extensions" ,
@@ -77,7 +85,7 @@ babel_bin.babel(
7785 toolchain_name ,
7886 ),
7987 data = [
80- "// :node_modules/inline-fixtures" ,
88+ ":node_modules/inline-fixtures" ,
8189 "//js/private/node-patches/src:compile" ,
8290 ],
8391 entry_point = "copy_entry_{}" .format (t ),
@@ -98,7 +106,7 @@ babel_bin.babel(
98106 toolchain_name ,
99107 ),
100108 data = [
101- "// :node_modules/inline-fixtures" ,
109+ ":node_modules/inline-fixtures" ,
102110 "//js/private/node-patches/src:compile" ,
103111 ],
104112 entry_point = t ,
0 commit comments