From c5685839dcb5141aea6af364df44c6772da6e924 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Thu, 26 Sep 2019 13:11:31 -0700 Subject: [PATCH] fix(builtin): support for scoped modules in linker --- internal/linker/index.js | 28 +++++++++++++++---- internal/linker/link_node_modules.ts | 27 +++++++++++++++--- internal/linker/test/integration/BUILD.bazel | 2 ++ .../dynamic_linked_scoped_pkg/BUILD.bazel | 10 +++++++ .../dynamic_linked_scoped_pkg/index.js | 5 ++++ internal/linker/test/integration/golden.txt | 2 +- internal/linker/test/integration/program.js | 8 +++++- .../static_linked_scoped_pkg/BUILD.bazel | 9 ++++++ .../static_linked_scoped_pkg/index.js | 5 ++++ 9 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 internal/linker/test/integration/dynamic_linked_scoped_pkg/BUILD.bazel create mode 100644 internal/linker/test/integration/dynamic_linked_scoped_pkg/index.js create mode 100644 internal/linker/test/integration/static_linked_scoped_pkg/BUILD.bazel create mode 100644 internal/linker/test/integration/static_linked_scoped_pkg/index.js diff --git a/internal/linker/index.js b/internal/linker/index.js index 850fc0c041..57dadfc308 100644 --- a/internal/linker/index.js +++ b/internal/linker/index.js @@ -40,6 +40,16 @@ Include as much of the build output as you can without disclosing anything confi ${m} `); } + /** + * Create a new directory and any necessary subdirectories + * if they do not exist. + */ + function mkdirp(p) { + if (!fs.existsSync(p)) { + mkdirp(path.dirname(p)); + fs.mkdirSync(p); + } + } function symlink(target, path) { return __awaiter(this, void 0, void 0, function* () { log_verbose(`symlink( ${path} -> ${target} )`); @@ -62,7 +72,7 @@ Include as much of the build output as you can without disclosing anything confi // any unneeded file I/O if (!fs.existsSync(path)) { log_verbose('ERROR\n***\nLooks like we created a bad symlink:' + - `\n pwd ${process.cwd()}\n target ${target}\n***`); + `\n pwd ${process.cwd()}\n target ${target}\n path ${path}\n***`); } } }); @@ -239,7 +249,7 @@ Include as much of the build output as you can without disclosing anything confi yield symlink(rootDir, 'node_modules'); process.chdir(rootDir); // Symlinks to packages need to reach back to the workspace/runfiles directory - const workspaceRelative = path.relative('.', workspaceDir); + const workspaceAbs = path.resolve(workspaceDir); // Now add symlinks to each of our first-party packages so they appear under the node_modules tree const links = []; const linkModule = (name, root, modulePath) => __awaiter(this, void 0, void 0, function* () { @@ -247,7 +257,7 @@ Include as much of the build output as you can without disclosing anything confi switch (root) { case 'bin': // FIXME(#1196) - target = path.join(workspaceRelative, bin, toWorkspaceDir(modulePath)); + target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath)); // Spend an extra FS lookup to give better error in this case if (!(yield exists(target))) { // TODO: there should be some docs explaining how users are @@ -261,7 +271,7 @@ Include as much of the build output as you can without disclosing anything confi } break; case 'src': - target = path.join(workspaceRelative, toWorkspaceDir(modulePath)); + target = path.join(workspaceAbs, toWorkspaceDir(modulePath)); break; case 'runfiles': target = runfiles.resolve(modulePath) || ''; @@ -270,6 +280,14 @@ Include as much of the build output as you can without disclosing anything confi yield symlink(target, name); }); for (const m of Object.keys(modules)) { + const segments = m.split('/'); + if (segments.length > 2) { + throw new Error(`module ${m} has more than 2 segments which is not a valid node module name`); + } + if (segments.length == 2) { + // ensure the scope exists + mkdirp(segments[0]); + } const [kind, modulePath] = modules[m]; links.push(linkModule(m, kind, modulePath)); } @@ -289,4 +307,4 @@ Include as much of the build output as you can without disclosing anything confi }))(); } }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGlua19ub2RlX21vZHVsZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9pbnRlcm5hbC9saW5rZXIvbGlua19ub2RlX21vZHVsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7OztJQUFBOzs7O09BSUc7SUFDSCx5QkFBeUI7SUFDekIsNkJBQTZCO0lBRTdCLGdFQUFnRTtJQUNoRSxNQUFNLFlBQVksR0FBRyxDQUFDLENBQUM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yKGBtb2R1bGUgJHttfSBoYXMgbW9yZSB0aGFuIDIgc2VnbWVudHMgd2hpY2ggaXMgbm90IGEgdmFsaWQgbm9kZSBtb2R1bGUgbmFtZWApO1xuICAgIH1cbiAgICBpZiAoc2VnbWVudHMubGVuZ3RoID09IDIpIHtcbiAgICAgIC8vIGVuc3VyZSB0aGUgc2NvcGUgZXhpc3RzXG4gICAgICBta2RpcnAoc2VnbWVudHNbMF0pO1xuICAgIH1cbiAgICBjb25zdCBba2luZCwgbW9kdWxlUGF0aF0gPSBtb2R1bGVzW21dO1xuICAgIGxpbmtzLnB1c2gobGlua01vZHVsZShtLCBraW5kLCBtb2R1bGVQYXRoKSk7XG4gIH1cblxuICBsZXQgY29kZSA9IDA7XG4gIGF3YWl0IFByb21pc2UuYWxsKGxpbmtzKS5jYXRjaChlID0+IHtcbiAgICBjb25zb2xlLmVycm9yKGUpO1xuICAgIGNvZGUgPSAxO1xuICB9KTtcblxuICByZXR1cm4gY29kZTtcbn1cblxuZXhwb3J0IGNvbnN0IHJ1bmZpbGVzID0gbmV3IFJ1bmZpbGVzKHByb2Nlc3MuZW52KTtcblxuaWYgKHJlcXVpcmUubWFpbiA9PT0gbW9kdWxlKSB7XG4gIChhc3luYyAoKSA9PiB7XG4gICAgcHJvY2Vzcy5leGl0Q29kZSA9IGF3YWl0IG1haW4ocHJvY2Vzcy5hcmd2LnNsaWNlKDIpLCBydW5maWxlcyk7XG4gIH0pKCk7XG59XG4iXX0= \ No newline at end of file diff --git a/internal/linker/link_node_modules.ts b/internal/linker/link_node_modules.ts index 60d106d19b..0df3eb81bb 100644 --- a/internal/linker/link_node_modules.ts +++ b/internal/linker/link_node_modules.ts @@ -24,6 +24,17 @@ Include as much of the build output as you can without disclosing anything confi `); } +/** + * Create a new directory and any necessary subdirectories + * if they do not exist. + */ +function mkdirp(p: string) { + if (!fs.existsSync(p)) { + mkdirp(path.dirname(p)); + fs.mkdirSync(p); + } +} + async function symlink(target: string, path: string) { log_verbose(`symlink( ${path} -> ${target} )`); // Use junction on Windows since symlinks require elevated permissions. @@ -46,7 +57,7 @@ async function symlink(target: string, path: string) { if (!fs.existsSync(path)) { log_verbose( 'ERROR\n***\nLooks like we created a bad symlink:' + - `\n pwd ${process.cwd()}\n target ${target}\n***`); + `\n pwd ${process.cwd()}\n target ${target}\n path ${path}\n***`); } } } @@ -262,7 +273,7 @@ export async function main(args: string[], runfiles: Runfiles) { process.chdir(rootDir); // Symlinks to packages need to reach back to the workspace/runfiles directory - const workspaceRelative = path.relative('.', workspaceDir); + const workspaceAbs = path.resolve(workspaceDir); // Now add symlinks to each of our first-party packages so they appear under the node_modules tree const links = []; @@ -273,7 +284,7 @@ export async function main(args: string[], runfiles: Runfiles) { switch (root) { case 'bin': // FIXME(#1196) - target = path.join(workspaceRelative, bin, toWorkspaceDir(modulePath)); + target = path.join(workspaceAbs, bin, toWorkspaceDir(modulePath)); // Spend an extra FS lookup to give better error in this case if (!await exists(target)) { // TODO: there should be some docs explaining how users are @@ -287,7 +298,7 @@ export async function main(args: string[], runfiles: Runfiles) { } break; case 'src': - target = path.join(workspaceRelative, toWorkspaceDir(modulePath)); + target = path.join(workspaceAbs, toWorkspaceDir(modulePath)); break; case 'runfiles': target = runfiles.resolve(modulePath) || ''; @@ -298,6 +309,14 @@ export async function main(args: string[], runfiles: Runfiles) { } for (const m of Object.keys(modules)) { + const segments = m.split('/'); + if (segments.length > 2) { + throw new Error(`module ${m} has more than 2 segments which is not a valid node module name`); + } + if (segments.length == 2) { + // ensure the scope exists + mkdirp(segments[0]); + } const [kind, modulePath] = modules[m]; links.push(linkModule(m, kind, modulePath)); } diff --git a/internal/linker/test/integration/BUILD.bazel b/internal/linker/test/integration/BUILD.bazel index f154e01c80..91ab65d977 100644 --- a/internal/linker/test/integration/BUILD.bazel +++ b/internal/linker/test/integration/BUILD.bazel @@ -21,6 +21,7 @@ sh_binary( ":program.js", "//internal/linker:index.js", "//internal/linker/test/integration/static_linked_pkg", + "//internal/linker/test/integration/static_linked_scoped_pkg", "@bazel_tools//tools/bash/runfiles", "@build_bazel_rules_nodejs//toolchains/node:node_bin", ], @@ -35,6 +36,7 @@ linked( "//%s/absolute_import:index.js" % package_name(), ":run_program", "//internal/linker/test/integration/dynamic_linked_pkg", + "//internal/linker/test/integration/dynamic_linked_scoped_pkg", "@npm//semver", ], ) diff --git a/internal/linker/test/integration/dynamic_linked_scoped_pkg/BUILD.bazel b/internal/linker/test/integration/dynamic_linked_scoped_pkg/BUILD.bazel new file mode 100644 index 0000000000..6e863cfbb7 --- /dev/null +++ b/internal/linker/test/integration/dynamic_linked_scoped_pkg/BUILD.bazel @@ -0,0 +1,10 @@ +load("//internal/js_library:js_library.bzl", "js_library") + +package(default_visibility = ["//internal/linker/test:__subpackages__"]) + +js_library( + name = "dynamic_linked_scoped_pkg", + srcs = ["index.js"], + module_from_src = True, + module_name = "@linker_scoped/dynamic_linked", +) diff --git a/internal/linker/test/integration/dynamic_linked_scoped_pkg/index.js b/internal/linker/test/integration/dynamic_linked_scoped_pkg/index.js new file mode 100644 index 0000000000..a88998bdb3 --- /dev/null +++ b/internal/linker/test/integration/dynamic_linked_scoped_pkg/index.js @@ -0,0 +1,5 @@ +function addD(str) { + return `${str}_d`; +} + +exports.addD = addD; \ No newline at end of file diff --git a/internal/linker/test/integration/golden.txt b/internal/linker/test/integration/golden.txt index 7fa3bafab1..7f08382f13 100644 --- a/internal/linker/test/integration/golden.txt +++ b/internal/linker/test/integration/golden.txt @@ -1 +1 @@ -1.2.3_c_b_a +1.2.3_a_b_c_d_e diff --git a/internal/linker/test/integration/program.js b/internal/linker/test/integration/program.js index 3bce634a48..ceb8d0cb37 100644 --- a/internal/linker/test/integration/program.js +++ b/internal/linker/test/integration/program.js @@ -6,9 +6,15 @@ const a = require('static_linked'); const b = require('dynamic_linked'); // We've always supported `require('my_workspace')` for absolute imports like Google does it const c = require('build_bazel_rules_nodejs/internal/linker/test/integration/absolute_import'); +// First-party package from ./static_linked_scoped_pkg +// it should get resolved through runfiles +const d = require('@linker_scoped/dynamic_linked'); +// First-party package from ./dynamic_linked_scoped_pkg +// it should get resolved from the execroot +const e = require('@linker_scoped/static_linked'); // Third-party package installed in the root node_modules const semver = require('semver'); // This output should match what's in the golden.txt file -console.log(a.addA(b.addB(c.addC(semver.clean(' =v1.2.3 '))))); +console.log(e.addE(d.addD(c.addC(b.addB(a.addA(semver.clean(' =v1.2.3 '))))))); diff --git a/internal/linker/test/integration/static_linked_scoped_pkg/BUILD.bazel b/internal/linker/test/integration/static_linked_scoped_pkg/BUILD.bazel new file mode 100644 index 0000000000..74a8741930 --- /dev/null +++ b/internal/linker/test/integration/static_linked_scoped_pkg/BUILD.bazel @@ -0,0 +1,9 @@ +load("//internal/js_library:js_library.bzl", "js_library") + +package(default_visibility = ["//internal/linker/test:__subpackages__"]) + +js_library( + name = "static_linked_scoped_pkg", + srcs = ["index.js"], + module_name = "@linker_scoped/static_linked", +) diff --git a/internal/linker/test/integration/static_linked_scoped_pkg/index.js b/internal/linker/test/integration/static_linked_scoped_pkg/index.js new file mode 100644 index 0000000000..37a64cb21b --- /dev/null +++ b/internal/linker/test/integration/static_linked_scoped_pkg/index.js @@ -0,0 +1,5 @@ +function addE(str) { + return `${str}_e`; +} + +exports.addE = addE; \ No newline at end of file