diff --git a/BUILD.bazel b/BUILD.bazel index 3d5e3723b0..9be5ebad98 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -68,7 +68,7 @@ pkg_npm( ], # Don't rename BUILD files as this package is not published to npm # but is compressed in "release" below and published as a .tar.gz to GitHub - rename_build_files = False, + hide_build_files = False, # Don't replace the default 0.0.0-PLACEHOLDER for this pkg_npm since # we are packaging up the packager itself and this replacement will break it replace_with_version = "", diff --git a/internal/pkg_npm/packager.js b/internal/pkg_npm/packager.js index 3a49c08235..0f12a54782 100644 --- a/internal/pkg_npm/packager.js +++ b/internal/pkg_npm/packager.js @@ -60,9 +60,9 @@ function main(args) { args = fs.readFileSync(args[0], {encoding: 'utf-8'}).split('\n').map(unquoteArgs); const [outDir, baseDir, srcsArg, binDir, genDir, depsArg, packagesArg, substitutionsArg, packPath, - publishPath, replaceWithVersion, stampFile, vendorExternalArg, renameBuildFilesArg, + publishPath, replaceWithVersion, stampFile, vendorExternalArg, hideBuildFilesArg, runNpmTemplatePath] = args; - const renameBuildFiles = parseInt(renameBuildFilesArg); + const renameBuildFiles = parseInt(hideBuildFilesArg); const substitutions = [ // Strip content between BEGIN-INTERNAL / END-INTERNAL comments diff --git a/internal/pkg_npm/pkg_npm.bzl b/internal/pkg_npm/pkg_npm.bzl index b531adab4c..c626352112 100644 --- a/internal/pkg_npm/pkg_npm.bzl +++ b/internal/pkg_npm/pkg_npm.bzl @@ -64,7 +64,7 @@ def create_package(ctx, deps_sources, nested_packages): args.add(ctx.attr.replace_with_version) args.add(ctx.version_file.path if stamp else "") args.add_joined(ctx.attr.vendor_external, join_with = ",", omit_if_empty = False) - args.add("1" if ctx.attr.rename_build_files else "0") + args.add("1" if ctx.attr.hide_build_files else "0") # require.resolve expects the path to start with the workspace name and not "external" run_npm_template_path = strip_external(ctx.file._run_npm_template.path) @@ -123,6 +123,16 @@ PKG_NPM_ATTRS = { doc = """Files inside this directory which are simply copied into the package.""", allow_files = True, ), + "hide_build_files": attr.bool( + doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package. + The default is True since npm packages that contain BUILD files don't work with + `yarn_install` and `npm_install` without a post-install step that deletes or renames them. + + NB: Bazel has a change in https://github.com/bazelbuild/bazel/pull/10261 + (expected in version 2.1) that adds .bazelignore + support for external repositories, which will make this attribute obsolete.""", + default = True, + ), "nested_packages": attr.label_list( doc = """Other pkg_npm rules whose content is copied into this package.""", allow_files = True, @@ -132,12 +142,6 @@ PKG_NPM_ATTRS = { providers = [NodeContextInfo], doc = "Internal use only", ), - "rename_build_files": attr.bool( - doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package. - The default is True since npm packages that contain BUILD files don't work with - `yarn_install` and `npm_install` without a post-install step that deletes or renames them.""", - default = True, - ), "replace_with_version": attr.string( doc = """If set this value is replaced with the version stamp data. See the section on stamping in the README.""",