diff --git a/.bazelignore b/.bazelignore index 618108ddc6..e6789ba901 100644 --- a/.bazelignore +++ b/.bazelignore @@ -15,6 +15,5 @@ internal/e2e/fine_grained_deps/npm/node_modules internal/e2e/fine_grained_deps/yarn/node_modules internal/e2e/fine_grained_no_bin/node_modules internal/e2e/fine_grained_symlinks -internal/e2e/node_loader_no_preserve_symlinks internal/e2e/node_loader_preserve_symlinks internal/e2e/packages diff --git a/WORKSPACE b/WORKSPACE index 8e5a5115a4..e172045a8f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -68,7 +68,6 @@ node_repositories( "@examples_program//:package.json", "//internal/npm_install/test:package/package.json", ], - preserve_symlinks = True, ) yarn_install( diff --git a/internal/e2e/node_loader_no_preserve_symlinks/.bazelignore b/internal/e2e/node_loader_no_preserve_symlinks/.bazelignore deleted file mode 100644 index b512c09d47..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/.bazelignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/internal/e2e/node_loader_no_preserve_symlinks/.bazelrc b/internal/e2e/node_loader_no_preserve_symlinks/.bazelrc deleted file mode 100644 index 86508414c9..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/.bazelrc +++ /dev/null @@ -1 +0,0 @@ -import %workspace%/../../../common.bazelrc diff --git a/internal/e2e/node_loader_no_preserve_symlinks/BUILD.bazel b/internal/e2e/node_loader_no_preserve_symlinks/BUILD.bazel deleted file mode 100644 index 25c83c1c15..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/BUILD.bazel +++ /dev/null @@ -1,11 +0,0 @@ -load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test") - -package(default_visibility = ["//visibility:public"]) - -jasmine_node_test( - name = "test", - srcs = [ - "node_loader_test.spec.js", - ], - node_modules = "@npm//:node_modules", -) diff --git a/internal/e2e/node_loader_no_preserve_symlinks/WORKSPACE b/internal/e2e/node_loader_no_preserve_symlinks/WORKSPACE deleted file mode 100644 index 44ea5259f7..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/WORKSPACE +++ /dev/null @@ -1,21 +0,0 @@ -workspace( - name = "node_loader_e2e_no_preserve_symlinks", - managed_directories = { - "@npm": ["node_modules"], - }, -) - -local_repository( - name = "build_bazel_rules_nodejs", - path = "../../../dist/build_bazel_rules_nodejs/release", -) - -load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories", "yarn_install") - -node_repositories(preserve_symlinks = False) - -yarn_install( - name = "npm", - package_json = "//:package.json", - yarn_lock = "//:yarn.lock", -) diff --git a/internal/e2e/node_loader_no_preserve_symlinks/node_loader_test.spec.js b/internal/e2e/node_loader_no_preserve_symlinks/node_loader_test.spec.js deleted file mode 100644 index 95fbefd2eb..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/node_loader_test.spec.js +++ /dev/null @@ -1,26 +0,0 @@ -describe('node_loader_test', () => { - it('should fail to resolve minimist', () => { - try { - require('minimist'); - expect(false).toEqual(true); - } catch (e) { - expect(true).toEqual(true); - } - }); - - it('should resolve tmp', () => { - require('tmp'); - expect(true).toEqual(true); - }); - - it('should resolve @gregmagolan/test-a to version 0.0.2', () => { - const testA = require('@gregmagolan/test-a'); - expect(testA).toEqual('test-a-0.0.2'); - }); - - it('should resolve @gregmagolan/test-b to version 0.0.2 with a @gregmagolan/test-a dependency of 0.0.1', - () => { - const testB = require('@gregmagolan/test-b'); - expect(testB).toEqual('test-b-0.0.2/test-a-0.0.1'); - }); -}); diff --git a/internal/e2e/node_loader_no_preserve_symlinks/package.json b/internal/e2e/node_loader_no_preserve_symlinks/package.json deleted file mode 100644 index 2382761ead..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "description": "e2e node_loader testing dependencies", - "devDependencies": {}, - "dependencies": { - "@gregmagolan/test-b": "0.0.2", - "@gregmagolan/test-a": "0.0.2", - "jasmine": "~2.8.0", - "tmp": "0.0.33" - }, - "scripts": { - "test": "bazel test //..." - } -} diff --git a/internal/e2e/node_loader_no_preserve_symlinks/yarn.lock b/internal/e2e/node_loader_no_preserve_symlinks/yarn.lock deleted file mode 100644 index a1631d82cc..0000000000 --- a/internal/e2e/node_loader_no_preserve_symlinks/yarn.lock +++ /dev/null @@ -1,123 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@gregmagolan/test-a@0.0.1": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@gregmagolan/test-a/-/test-a-0.0.1.tgz#c90ebc0676f13b34400da8d1e55ffe5aa76655b4" - integrity sha512-nMZ3MKkXZ+uYbrm8R3dfdt3v1gOOLtf88CdDciWxMYGLr29oVjQG11y2fz4IRBR6R7hI2Gj+G9sHZ69wLTnjfA== - -"@gregmagolan/test-a@0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@gregmagolan/test-a/-/test-a-0.0.2.tgz#86ab79a55f44860b02d8275e22d282a1f82b8768" - integrity sha512-u8pW4cm5Xk58fQeA1tGER3KwCfHZ1sBEx0YDWs5Spdi7tiw/21DN7btDvGqx4sG3d2UnUdAnvXPsdwArjNGdmg== - -"@gregmagolan/test-b@0.0.2": - version "0.0.2" - resolved "https://registry.yarnpkg.com/@gregmagolan/test-b/-/test-b-0.0.2.tgz#7549fb9f39895c0d744c2c24c98b0e5817e46bd7" - integrity sha512-h+LeJUbUued9XyQwxKMUdklGiGxPYJ1RvTAK9612ctCiMS2Fn0wu/Au5kHsMHxm8l4bOfpgAWmQ0OQQy7wUBCg== - dependencies: - "@gregmagolan/test-a" "0.0.1" - -balanced-match@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" - integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= - -exit@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= - -glob@^7.0.6: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - integrity sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - -jasmine-core@~2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" - integrity sha1-vMl5rh+f0FcB5F5S5l06XWPxok4= - -jasmine@~2.8.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.8.0.tgz#6b089c0a11576b1f16df11b80146d91d4e8b8a3e" - integrity sha1-awicChFXax8W3xG4AUbZHU6Lij4= - dependencies: - exit "^0.1.2" - glob "^7.0.6" - jasmine-core "~2.8.0" - -minimatch@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== - dependencies: - brace-expansion "^1.1.7" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= - dependencies: - wrappy "1" - -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= - -tmp@0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= diff --git a/internal/node/generate_build_file.js b/internal/node/generate_build_file.js index ba5a98ac69..2b903ea6ed 100644 --- a/internal/node/generate_build_file.js +++ b/internal/node/generate_build_file.js @@ -76,7 +76,6 @@ function generateBuildFile() { package(default_visibility = ["//visibility:public"]) exports_files([ "run_npm.sh.template", - "bin/node_args.sh", "${NODE_DIR}/bin/node", "bin/node${binaryExt}", "bin/npm${binaryExt}", diff --git a/internal/node/node.bzl b/internal/node/node.bzl index 9a7831c262..1807f38f1f 100644 --- a/internal/node/node.bzl +++ b/internal/node/node.bzl @@ -159,7 +159,6 @@ def _nodejs_binary_impl(ctx): "TEMPLATED_env_vars": env_vars, "TEMPLATED_expected_exit_code": str(expected_exit_code), "TEMPLATED_node": _short_path_to_manifest_path(ctx, node.short_path), - "TEMPLATED_repository_args": _short_path_to_manifest_path(ctx, ctx.file._repository_args.short_path), "TEMPLATED_script_path": script_path, } ctx.actions.expand_template( @@ -169,7 +168,7 @@ def _nodejs_binary_impl(ctx): is_executable = True, ) - runfiles = depset([node, ctx.outputs.loader, ctx.file._repository_args] + ctx.files._node_runfiles, transitive = [sources, node_modules]) + runfiles = depset([node, ctx.outputs.loader] + ctx.files._node_runfiles, transitive = [sources, node_modules]) return [DefaultInfo( executable = ctx.outputs.script, @@ -312,10 +311,6 @@ _NODEJS_EXECUTABLE_ATTRS = { default = Label("@nodejs//:node_runfiles"), allow_files = True, ), - "_repository_args": attr.label( - default = Label("@nodejs//:bin/node_args.sh"), - allow_single_file = True, - ), "_source_map_support_files": attr.label_list( default = [ Label("//third_party/github.com/buffer-from:contents"), diff --git a/internal/node/node_launcher.sh b/internal/node/node_launcher.sh index 3a2bb376f2..1991cb6c76 100644 --- a/internal/node/node_launcher.sh +++ b/internal/node/node_launcher.sh @@ -115,14 +115,12 @@ TEMPLATED_env_vars # find . -name thingImLookingFor 1>&2 readonly node=$(rlocation "TEMPLATED_node") -readonly repository_args=$(rlocation "TEMPLATED_repository_args") readonly script=$(rlocation "TEMPLATED_script_path") -source $repository_args - ARGS=() NODE_OPTIONS=() -ALL_ARGS=(TEMPLATED_args $NODE_REPOSITORY_ARGS "$@") +# TODO: Add --preserve-symlinks-main as well for node >= 10.2.0 +ALL_ARGS=(TEMPLATED_args --node_options=--preserve-symlinks "$@") for ARG in "${ALL_ARGS[@]}"; do case "$ARG" in --node_options=*) NODE_OPTIONS+=( "${ARG#--node_options=}" ) ;; diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index 3a9dbef2fb..500ffa0ec0 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl @@ -224,9 +224,6 @@ def _prepare_node(repository_ctx): npm_script_relative = npm_script if repository_ctx.attr.vendored_node else paths.relativize(npm_script, "bin") yarn_script_relative = yarn_script if repository_ctx.attr.vendored_yarn else paths.relativize(yarn_script, "bin") - if not repository_ctx.attr.preserve_symlinks: - print("\nWARNING: The preserve_symlinks option is deprecated and will go away in the future.\n") - # The entry points for node for osx/linux and windows if not is_windows: # Sets PATH and runs the application @@ -250,16 +247,6 @@ SET PATH=%SCRIPT_DIR%;%PATH% CALL "%SCRIPT_DIR%\\{node}" %* """.format(node = node_exec_relative)) - # Shell script to set repository arguments for node used by nodejs_binary & nodejs_test launcher - # TODO(gregmagolan): add --node_options=--preserve-symlinks-main as well if preserve_symlinks is True & - # node version >= 10.2.0 - repository_ctx.file("bin/node_args.sh", content = """#!/usr/bin/env bash -# Immediately exit if any command fails. -set -e -# Generated by node_repositories.bzl -export NODE_REPOSITORY_ARGS={} -""".format("--node_options=--preserve-symlinks" if repository_ctx.attr.preserve_symlinks else ""), executable = True) - # The entry points for npm for osx/linux and windows # Runs npm using appropriate node entry point # --scripts-prepend-node-path is set to false since the correct paths @@ -437,7 +424,6 @@ _nodejs_repo = repository_rule( # Options to override node version "node_version": attr.string(default = DEFAULT_NODE_VERSION), "package_json": attr.label_list(), - "preserve_symlinks": attr.bool(default = True), "vendored_node": attr.label(allow_single_file = True), "vendored_yarn": attr.label(allow_single_file = True), "yarn_repositories": attr.string_list_dict(default = YARN_REPOSITORIES), @@ -467,8 +453,7 @@ def node_repositories( node_repositories = NODE_REPOSITORIES, yarn_repositories = YARN_REPOSITORIES, node_urls = NODE_URLS, - yarn_urls = YARN_URLS, - preserve_symlinks = True): + yarn_urls = YARN_URLS): """To be run in user's WORKSPACE to install rules_nodejs dependencies. This rule sets up node, npm, and yarn. @@ -523,13 +508,6 @@ def node_repositories( yarn_repositories: optional; custom list of yarn repositories to use. node_urls: optional; custom list of URLs to use to download NodeJS. yarn_urls: optional; custom list of URLs to use to download Yarn. - preserve_symlinks: Turn on --node_options=--preserve-symlinks for nodejs_binary and nodejs_test rules. - The default for this is currently True but the options is deprecated and will be removed in the future. - When this option is turned on, node will preserve the symlinked path for resolves instead of the default - behavior of resolving to the real path. This means that all required files must be in be included in your - runfiles as it prevents the default behavior of potentially resolving outside of the runfiles. For example, - all required files need to be included in your node_modules filegroup. This option is desirable as it gives - a stronger guarantee of hermiticity which is required for remote execution. """ # 0.14.0: @bazel_tools//tools/bash/runfiles is required for nodejs @@ -550,7 +528,6 @@ def node_repositories( yarn_repositories = yarn_repositories, node_urls = node_urls, yarn_urls = yarn_urls, - preserve_symlinks = preserve_symlinks, ) _maybe(