From 8d778279428294617cf313eac369b6f50ae8cff2 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 4 Feb 2020 16:11:59 -0800 Subject: [PATCH] feat(builtin): expose `@npm//foo__all_files` filegroup that includes all files in the npm package (#1600) Including files with spaces & unicode characters & files that have been filtered out by the `included_files` attribute. This filegroup cannot be used in runfiles because of Bazel issue https://github.com/bazelbuild/bazel/issues/4327, but it can be used for other purposes such as the srcs input to a pkg_tar for generating a tar of an npm package pulled down with yarn_install or npm_install. --- WORKSPACE | 10 + internal/node/node.bzl | 2 + internal/npm_install/generate_build_file.js | 168 ++++++++-------- internal/npm_install/generate_build_file.ts | 185 ++++++++++-------- internal/npm_install/test/BUILD.bazel | 6 +- .../golden/@angular/core/BUILD.bazel.golden | 15 +- .../golden/@gregmagolan/BUILD.bazel.golden | 4 +- .../@gregmagolan/test-a/BUILD.bazel.golden | 15 +- .../@gregmagolan/test-b/BUILD.bazel.golden | 11 +- .../test/golden/BUILD.bazel.golden | 80 +++++--- .../test/golden/ajv/BUILD.bazel.golden | 29 +-- .../test/golden/jasmine/BUILD.bazel.golden | 19 +- .../test/golden/rxjs/BUILD.bazel.golden | 29 +-- .../test/golden/unidiff/BUILD.bazel.golden | 15 +- .../test/golden/zone.js/BUILD.bazel.golden | 19 +- package.json | 1 + tools/fine_grained_goldens/package.json | 2 +- tools/fine_grained_goldens/yarn.lock | 8 +- yarn.lock | 5 + 19 files changed, 362 insertions(+), 261 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 6ca5c6015a..3bd9b5a41c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -227,6 +227,16 @@ yarn_install( yarn_install( name = "fine_grained_goldens", + included_files = [ + "", + ".js", + ".jst", + ".ts", + ".map", + ".d.ts", + ".json", + ".proto", + ], manual_build_file_contents = """ filegroup( name = "golden_files", diff --git a/internal/node/node.bzl b/internal/node/node.bzl index b3a29cae65..5c4d6c8c44 100644 --- a/internal/node/node.bzl +++ b/internal/node/node.bzl @@ -148,6 +148,8 @@ def _nodejs_binary_impl(ctx): node_modules_manifest = write_node_modules_manifest(ctx) node_modules_depsets = [] node_modules_depsets.append(depset(ctx.files.node_modules)) + if NpmPackageInfo in ctx.attr.node_modules: + node_modules_depsets.append(ctx.attr.node_modules[NpmPackageInfo].sources) # Also include files from npm fine grained deps as inputs. # These deps are identified by the NpmPackageInfo provider. diff --git a/internal/npm_install/generate_build_file.js b/internal/npm_install/generate_build_file.js index 3fcd82e76b..2906bc1594 100644 --- a/internal/npm_install/generate_build_file.js +++ b/internal/npm_install/generate_build_file.js @@ -161,17 +161,12 @@ for installation instructions.`); * Generates the root BUILD file. */ function generateRootBuildFile(pkgs) { - let exportsStarlark = ''; - pkgs.forEach(pkg => { - pkg._files.forEach(f => { - exportsStarlark += ` "node_modules/${pkg._dir}/${f}", -`; - }); - }); - let filesStarlark = ''; + let pkgFilesStarlark = ''; if (pkgs.length) { - const list = pkgs.map(pkg => `"//${pkg._dir}:${pkg._name}__all_files",`).join('\n '); - filesStarlark = ` + const list = pkgs.map(pkg => `"//${pkg._dir}:${pkg._name}__files", + "//${pkg._dir}:${pkg._name}__nested_node_modules",`) + .join('\n '); + pkgFilesStarlark = ` # direct sources listed for strict deps support srcs = [ ${list} @@ -186,6 +181,13 @@ for installation instructions.`); ${list} ],`; } + let exportsStarlark = ''; + pkgs.forEach(pkg => { + pkg._files.forEach(f => { + exportsStarlark += ` "node_modules/${pkg._dir}/${f}", +`; + }); + }); let buildFile = BUILD_FILE_HEADER + `load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library") @@ -197,7 +199,7 @@ ${exportsStarlark}]) # there are many files in target. # See https://github.com/bazelbuild/bazel/issues/5153. node_module_library( - name = "node_modules",${filesStarlark}${depsStarlark} + name = "node_modules",${pkgFilesStarlark}${depsStarlark} ) `; @@ -390,9 +392,6 @@ def _maybe(repo_rule, name, **kwargs): } return isDirectory ? files.concat(listFiles(rootDir, relPath)) : files.concat(relPath); }, []) - // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in - // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327 - .filter(f => !/[^\x21-\x7E]/.test(f)) // We return a sorted array so that the order of files // is the same regardless of platform .sort(); @@ -480,6 +479,10 @@ def _maybe(repo_rule, name, **kwargs): pkg._isNested = /\/node_modules\//.test(p); // List all the files in the npm package for later use pkg._files = listFiles(p); + // The subset of files that are valid in runfiles. + // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in + // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327 + pkg._runfiles = pkg._files.filter((f) => !/[^\x21-\x7E]/.test(f)); // Initialize _dependencies to an empty array // which is later filled with the flattened dependency list pkg._dependencies = []; @@ -686,10 +689,11 @@ def _maybe(repo_rule, name, **kwargs): */ function printJson(pkg) { // Clone and modify _dependencies to avoid circular issues when JSONifying - // & delete _files array + // & delete _files & _runfiles arrays const cloned = Object.assign({}, pkg); cloned._dependencies = pkg._dependencies.map(dep => dep._dir); delete cloned._files; + delete cloned._runfiles; return JSON.stringify(cloned, null, 2).split('\n').map(line => `# ${line}`).join('\n'); } /** @@ -748,15 +752,6 @@ def _maybe(repo_rule, name, **kwargs): return false; }); } - /** - * If the package is in the Angular package format returns list - * of package files that end with `.umd.js`, `.ngfactory.js` and `.ngsummary.js`. - */ - function getNgApfScripts(pkg) { - return isNgApfPackage(pkg) ? - filterFiles(pkg._files, ['.umd.js', '.ngfactory.js', '.ngsummary.js']) : - []; - } /** * Looks for a file within a package and returns it if found. */ @@ -773,91 +768,98 @@ def _maybe(repo_rule, name, **kwargs): * Given a pkg, return the skylark `node_module_library` targets for the package. */ function printPackage(pkg) { - const sources = filterFiles(pkg._files, INCLUDED_FILES); - const files = sources.filter((f) => !f.startsWith('node_modules/')); - const nestedNodeModules = sources.filter((f) => f.startsWith('node_modules/')); - const dtsSources = filterFiles(pkg._files, ['.d.ts']); - // TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they - // are named? - const namedSources = getNgApfScripts(pkg); - const deps = [pkg].concat(pkg._dependencies.filter(dep => dep !== pkg && !dep._isNested)); - let namedSourcesStarlark = ''; - if (namedSources.length) { - namedSourcesStarlark = ` - # subset of srcs that are javascript named-UMD or named-AMD scripts - named_module_srcs = [ - ${namedSources.map((f) => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} - ],`; - } - let filesStarlark = ''; - if (files.length) { - filesStarlark = ` - # ${pkg._dir} package files (and files in nested node_modules) - srcs = [ + function starlarkFiles(attr, files, comment = '') { + return ` + ${comment ? comment + '\n ' : ''}${attr} = [ ${files.map((f) => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} ],`; } - let nestedNodeModulesStarlark = ''; - if (nestedNodeModules.length) { - nestedNodeModulesStarlark = ` - # ${pkg._dir} package files (and files in nested node_modules) - srcs = [ - ${nestedNodeModules.map((f) => `"//:node_modules/${pkg._dir}/${f}",`) - .join('\n ')} - ],`; - } - let depsStarlark = ''; - if (deps.length) { - const list = deps.map(dep => `"//${dep._dir}:${dep._name}__contents",`).join('\n '); - depsStarlark = ` - # flattened list of direct and transitive dependencies hoisted to root by the package manager - deps = [ - ${list} - ],`; - } - let dtsStarlark = ''; - if (dtsSources.length) { - dtsStarlark = ` - # ${pkg._dir} package declaration files (and declaration files in nested node_modules) - srcs = [ - ${dtsSources.map(f => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} - ],`; - } + const includedRunfiles = filterFiles(pkg._runfiles, INCLUDED_FILES); + // Files that are part of the npm package not including its nested node_modules + // (filtered by the 'included_files' attribute) + const pkgFiles = includedRunfiles.filter((f) => !f.startsWith('node_modules/')); + const pkgFilesStarlark = pkgFiles.length ? starlarkFiles('srcs', pkgFiles) : ''; + // Files that are in the npm package's nested node_modules + // (filtered by the 'included_files' attribute) + const nestedNodeModules = includedRunfiles.filter((f) => f.startsWith('node_modules/')); + const nestedNodeModulesStarlark = nestedNodeModules.length ? starlarkFiles('srcs', nestedNodeModules) : ''; + // Files that have been excluded from the ${pkg._name}__files target above because + // they are filtered out by 'included_files' or because they are not valid runfiles + // See https://github.com/bazelbuild/bazel/issues/4327. + const notPkgFiles = pkg._files.filter((f) => !f.startsWith('node_modules/') && !includedRunfiles.includes(f)); + const notPkgFilesStarlark = notPkgFiles.length ? starlarkFiles('srcs', notPkgFiles) : ''; + // If the package is in the Angular package format returns list + // of package files that end with `.umd.js`, `.ngfactory.js` and `.ngsummary.js`. + // TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they + // are named? + const namedSources = isNgApfPackage(pkg) ? + filterFiles(pkg._runfiles, ['.umd.js', '.ngfactory.js', '.ngsummary.js']) : + []; + const namedSourcesStarlark = namedSources.length ? + starlarkFiles('named_module_srcs', namedSources, '# subset of srcs that are javascript named-UMD or named-AMD scripts') : + ''; + // Typings files that are part of the npm package not including nested node_modules + const dtsSources = filterFiles(pkg._runfiles, ['.d.ts']).filter((f) => !f.startsWith('node_modules/')); + const dtsStarlark = dtsSources.length ? + starlarkFiles('srcs', dtsSources, `# ${pkg._dir} package declaration files (and declaration files in nested node_modules)`) : + ''; + // Flattened list of direct and transitive dependencies hoisted to root by the package manager + const deps = [pkg].concat(pkg._dependencies.filter(dep => dep !== pkg && !dep._isNested)); + const depsStarlark = deps.map(dep => `"//${dep._dir}:${dep._name}__contents",`).join('\n '); let result = `load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library") # Generated targets for npm package "${pkg._dir}" ${printJson(pkg)} +# Files that are part of the npm package not including its nested node_modules +# (filtered by the 'included_files' attribute) filegroup( - name = "${pkg._name}__files",${filesStarlark} + name = "${pkg._name}__files",${pkgFilesStarlark} ) +# Files that are in the npm package's nested node_modules +# (filtered by the 'included_files' attribute) filegroup( name = "${pkg._name}__nested_node_modules",${nestedNodeModulesStarlark} + visibility = ["//:__subpackages__"], +) + +# Files that have been excluded from the ${pkg._name}__files target above because +# they are filtered out by 'included_files' or because they are not valid runfiles +# See https://github.com/bazelbuild/bazel/issues/4327. +filegroup( + name = "${pkg._name}__not_files",${notPkgFilesStarlark} visibility = ["//visibility:private"], ) +# All of the files in the npm package including files that have been +# filtered out by 'included_files' or because they are not valid runfiles +# but not including nested node_modules. filegroup( name = "${pkg._name}__all_files", - srcs = [":${pkg._name}__files", ":${pkg._name}__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":${pkg._name}__files", ":${pkg._name}__not_files"], ) +# The primary target for this package for use in rule deps node_module_library( name = "${pkg._name}", # direct sources listed for strict deps support - srcs = [":${pkg._name}__all_files"],${depsStarlark} + srcs = [":${pkg._name}__files"], + # nested node_modules for this package plus flattened list of direct and transitive dependencies + # hoisted to root by the package manager + deps = [ + ${depsStarlark} + ], ) -# ${pkg._name}__contents target is used as dep for main targets to prevent -# circular dependencies errors +# Target is used as dep for main targets to prevent circular dependencies errors node_module_library( name = "${pkg._name}__contents", - srcs = [":${pkg._name}__all_files"],${namedSourcesStarlark} + srcs = [":${pkg._name}__files", ":${pkg._name}__nested_node_modules"],${namedSourcesStarlark} visibility = ["//:__subpackages__"], ) -# ${pkg._name}__typings is the subset of ${pkg._name}__contents that are declarations +# Typings files that are part of the npm package not including nested node_modules node_module_library( name = "${pkg._name}__typings",${dtsStarlark} ) @@ -1013,10 +1015,10 @@ def ${name.replace(/-/g, '_')}_test(**kwargs): }); // filter out duplicate deps deps = [...pkgs, ...new Set(deps)]; - let filesStarlark = ''; + let pkgFilesStarlark = ''; if (deps.length) { - const list = deps.map(dep => `"//${dep._dir}:${dep._name}__all_files",`).join('\n '); - filesStarlark = ` + const list = deps.map(dep => `"//${dep._dir}:${dep._name}__files",`).join('\n '); + pkgFilesStarlark = ` # direct sources listed for strict deps support srcs = [ ${list} @@ -1035,7 +1037,7 @@ def ${name.replace(/-/g, '_')}_test(**kwargs): # Generated target for npm scope ${scope} node_module_library( - name = "${scope}",${filesStarlark}${depsStarlark} + name = "${scope}",${pkgFilesStarlark}${depsStarlark} ) `; diff --git a/internal/npm_install/generate_build_file.ts b/internal/npm_install/generate_build_file.ts index 22b5e71b44..8efb6fdfe8 100644 --- a/internal/npm_install/generate_build_file.ts +++ b/internal/npm_install/generate_build_file.ts @@ -164,16 +164,12 @@ for installation instructions.`); * Generates the root BUILD file. */ function generateRootBuildFile(pkgs: Dep[]) { - let exportsStarlark = ''; - pkgs.forEach(pkg => {pkg._files.forEach(f => { - exportsStarlark += ` "node_modules/${pkg._dir}/${f}", -`; - })}); - - let filesStarlark = ''; + let pkgFilesStarlark = ''; if (pkgs.length) { - const list = pkgs.map(pkg => `"//${pkg._dir}:${pkg._name}__all_files",`).join('\n '); - filesStarlark = ` + const list = pkgs.map(pkg => `"//${pkg._dir}:${pkg._name}__files", + "//${pkg._dir}:${pkg._name}__nested_node_modules",`) + .join('\n '); + pkgFilesStarlark = ` # direct sources listed for strict deps support srcs = [ ${list} @@ -190,6 +186,12 @@ function generateRootBuildFile(pkgs: Dep[]) { ],`; } + let exportsStarlark = ''; + pkgs.forEach(pkg => {pkg._files.forEach(f => { + exportsStarlark += ` "node_modules/${pkg._dir}/${f}", +`; + })}); + let buildFile = BUILD_FILE_HEADER + `load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library") @@ -201,7 +203,7 @@ ${exportsStarlark}]) # there are many files in target. # See https://github.com/bazelbuild/bazel/issues/5153. node_module_library( - name = "node_modules",${filesStarlark}${depsStarlark} + name = "node_modules",${pkgFilesStarlark}${depsStarlark} ) ` @@ -425,9 +427,6 @@ function listFiles(rootDir: string, subDir: string = ''): string[] { return isDirectory ? files.concat(listFiles(rootDir, relPath)) : files.concat(relPath); }, []) - // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in - // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327 - .filter(f => !/[^\x21-\x7E]/.test(f)) // We return a sorted array so that the order of files // is the same regardless of platform .sort(); @@ -534,6 +533,11 @@ export function parsePackage(p: string, hide: boolean = true): Dep { // List all the files in the npm package for later use pkg._files = listFiles(p); + // The subset of files that are valid in runfiles. + // Files with spaces (\x20) or unicode characters (<\x20 && >\x7E) are not allowed in + // Bazel runfiles. See https://github.com/bazelbuild/bazel/issues/4327 + pkg._runfiles = pkg._files.filter((f: string) => !/[^\x21-\x7E]/.test(f)) + // Initialize _dependencies to an empty array // which is later filled with the flattened dependency list pkg._dependencies = []; @@ -763,10 +767,11 @@ function flattenPkgDependencies(pkg: Dep, dep: Dep, pkgsMap: Map) { */ function printJson(pkg: Dep) { // Clone and modify _dependencies to avoid circular issues when JSONifying - // & delete _files array + // & delete _files & _runfiles arrays const cloned: any = {...pkg}; cloned._dependencies = pkg._dependencies.map(dep => dep._dir); delete cloned._files; + delete cloned._runfiles; return JSON.stringify(cloned, null, 2).split('\n').map(line => `# ${line}`).join('\n'); } @@ -827,16 +832,6 @@ function isNgApfPackage(pkg: Dep) { }); } -/** - * If the package is in the Angular package format returns list - * of package files that end with `.umd.js`, `.ngfactory.js` and `.ngsummary.js`. - */ -function getNgApfScripts(pkg: Dep) { - return isNgApfPackage(pkg) ? - filterFiles(pkg._files, ['.umd.js', '.ngfactory.js', '.ngsummary.js']) : - []; -} - /** * Looks for a file within a package and returns it if found. */ @@ -854,62 +849,60 @@ function findFile(pkg: Dep, m: string) { * Given a pkg, return the skylark `node_module_library` targets for the package. */ function printPackage(pkg: Dep) { - const sources = filterFiles(pkg._files, INCLUDED_FILES); - const files = sources.filter((f: string) => !f.startsWith('node_modules/')); - const nestedNodeModules = sources.filter((f: string) => f.startsWith('node_modules/')); - const dtsSources = filterFiles(pkg._files, ['.d.ts']); - // TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they - // are named? - const namedSources = getNgApfScripts(pkg); - const deps = [pkg].concat(pkg._dependencies.filter(dep => dep !== pkg && !dep._isNested)); - - let namedSourcesStarlark = ''; - if (namedSources.length) { - namedSourcesStarlark = ` - # subset of srcs that are javascript named-UMD or named-AMD scripts - named_module_srcs = [ - ${namedSources.map((f: string) => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} - ],`; - } - - let filesStarlark = ''; - if (files.length) { - filesStarlark = ` - # ${pkg._dir} package files (and files in nested node_modules) - srcs = [ + function starlarkFiles(attr: string, files: string[], comment: string = '') { + return ` + ${comment ? comment + '\n ' : ''}${attr} = [ ${files.map((f: string) => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} ],`; } - let nestedNodeModulesStarlark = ''; - if (nestedNodeModules.length) { - nestedNodeModulesStarlark = ` - # ${pkg._dir} package files (and files in nested node_modules) - srcs = [ - ${ - nestedNodeModules.map((f: string) => `"//:node_modules/${pkg._dir}/${f}",`) - .join('\n ')} - ],`; - } + const includedRunfiles = filterFiles(pkg._runfiles, INCLUDED_FILES); - let depsStarlark = ''; - if (deps.length) { - const list = deps.map(dep => `"//${dep._dir}:${dep._name}__contents",`).join('\n '); - depsStarlark = ` - # flattened list of direct and transitive dependencies hoisted to root by the package manager - deps = [ - ${list} - ],`; - } + // Files that are part of the npm package not including its nested node_modules + // (filtered by the 'included_files' attribute) + const pkgFiles = includedRunfiles.filter((f: string) => !f.startsWith('node_modules/')); + const pkgFilesStarlark = pkgFiles.length ? starlarkFiles('srcs', pkgFiles) : ''; - let dtsStarlark = ''; - if (dtsSources.length) { - dtsStarlark = ` - # ${pkg._dir} package declaration files (and declaration files in nested node_modules) - srcs = [ - ${dtsSources.map(f => `"//:node_modules/${pkg._dir}/${f}",`).join('\n ')} - ],`; - } + // Files that are in the npm package's nested node_modules + // (filtered by the 'included_files' attribute) + const nestedNodeModules = includedRunfiles.filter((f: string) => f.startsWith('node_modules/')); + const nestedNodeModulesStarlark = + nestedNodeModules.length ? starlarkFiles('srcs', nestedNodeModules) : ''; + + // Files that have been excluded from the ${pkg._name}__files target above because + // they are filtered out by 'included_files' or because they are not valid runfiles + // See https://github.com/bazelbuild/bazel/issues/4327. + const notPkgFiles = pkg._files.filter( + (f: string) => !f.startsWith('node_modules/') && !includedRunfiles.includes(f)); + const notPkgFilesStarlark = notPkgFiles.length ? starlarkFiles('srcs', notPkgFiles) : ''; + + // If the package is in the Angular package format returns list + // of package files that end with `.umd.js`, `.ngfactory.js` and `.ngsummary.js`. + // TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they + // are named? + const namedSources = isNgApfPackage(pkg) ? + filterFiles(pkg._runfiles, ['.umd.js', '.ngfactory.js', '.ngsummary.js']) : + []; + const namedSourcesStarlark = namedSources.length ? + starlarkFiles( + 'named_module_srcs', namedSources, + '# subset of srcs that are javascript named-UMD or named-AMD scripts') : + ''; + + // Typings files that are part of the npm package not including nested node_modules + const dtsSources = + filterFiles(pkg._runfiles, ['.d.ts']).filter((f: string) => !f.startsWith('node_modules/')); + const dtsStarlark = dtsSources.length ? + starlarkFiles( + 'srcs', dtsSources, + `# ${ + pkg._dir} package declaration files (and declaration files in nested node_modules)`) : + ''; + + // Flattened list of direct and transitive dependencies hoisted to root by the package manager + const deps = [pkg].concat(pkg._dependencies.filter(dep => dep !== pkg && !dep._isNested)); + const depsStarlark = + deps.map(dep => `"//${dep._dir}:${dep._name}__contents",`).join('\n '); let result = `load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", "node_module_library") @@ -917,36 +910,55 @@ function printPackage(pkg: Dep) { # Generated targets for npm package "${pkg._dir}" ${printJson(pkg)} +# Files that are part of the npm package not including its nested node_modules +# (filtered by the 'included_files' attribute) filegroup( - name = "${pkg._name}__files",${filesStarlark} + name = "${pkg._name}__files",${pkgFilesStarlark} ) +# Files that are in the npm package's nested node_modules +# (filtered by the 'included_files' attribute) filegroup( name = "${pkg._name}__nested_node_modules",${nestedNodeModulesStarlark} + visibility = ["//:__subpackages__"], +) + +# Files that have been excluded from the ${pkg._name}__files target above because +# they are filtered out by 'included_files' or because they are not valid runfiles +# See https://github.com/bazelbuild/bazel/issues/4327. +filegroup( + name = "${pkg._name}__not_files",${notPkgFilesStarlark} visibility = ["//visibility:private"], ) +# All of the files in the npm package including files that have been +# filtered out by 'included_files' or because they are not valid runfiles +# but not including nested node_modules. filegroup( name = "${pkg._name}__all_files", - srcs = [":${pkg._name}__files", ":${pkg._name}__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":${pkg._name}__files", ":${pkg._name}__not_files"], ) +# The primary target for this package for use in rule deps node_module_library( name = "${pkg._name}", # direct sources listed for strict deps support - srcs = [":${pkg._name}__all_files"],${depsStarlark} + srcs = [":${pkg._name}__files"], + # nested node_modules for this package plus flattened list of direct and transitive dependencies + # hoisted to root by the package manager + deps = [ + ${depsStarlark} + ], ) -# ${pkg._name}__contents target is used as dep for main targets to prevent -# circular dependencies errors +# Target is used as dep for main targets to prevent circular dependencies errors node_module_library( name = "${pkg._name}__contents", - srcs = [":${pkg._name}__all_files"],${namedSourcesStarlark} + srcs = [":${pkg._name}__files", ":${pkg._name}__nested_node_modules"],${namedSourcesStarlark} visibility = ["//:__subpackages__"], ) -# ${pkg._name}__typings is the subset of ${pkg._name}__contents that are declarations +# Typings files that are part of the npm package not including nested node_modules node_module_library( name = "${pkg._name}__typings",${dtsStarlark} ) @@ -1107,6 +1119,7 @@ type Dep = { _isNested: boolean, _dependencies: Dep[], _files: string[], + _runfiles: string[], [k: string]: any } @@ -1122,10 +1135,10 @@ function printScope(scope: string, pkgs: Dep[]) { // filter out duplicate deps deps = [...pkgs, ...new Set(deps)]; - let filesStarlark = ''; + let pkgFilesStarlark = ''; if (deps.length) { - const list = deps.map(dep => `"//${dep._dir}:${dep._name}__all_files",`).join('\n '); - filesStarlark = ` + const list = deps.map(dep => `"//${dep._dir}:${dep._name}__files",`).join('\n '); + pkgFilesStarlark = ` # direct sources listed for strict deps support srcs = [ ${list} @@ -1146,7 +1159,7 @@ function printScope(scope: string, pkgs: Dep[]) { # Generated target for npm scope ${scope} node_module_library( - name = "${scope}",${filesStarlark}${depsStarlark} + name = "${scope}",${pkgFilesStarlark}${depsStarlark} ) `; diff --git a/internal/npm_install/test/BUILD.bazel b/internal/npm_install/test/BUILD.bazel index b38efe3c15..f7e9583afa 100644 --- a/internal/npm_install/test/BUILD.bazel +++ b/internal/npm_install/test/BUILD.bazel @@ -92,7 +92,7 @@ sh_test( ], ) -# Test what happens when we depend on the catch-all "node_modules" rule rather +# Test what happens when we depend on the catch-all "node_modules" target rather # than declare our dependencies on individual npm packages. # This is the legacy behavior prior to 0.13, so it also proves backwards-compatibility. [jasmine_node_test( @@ -128,8 +128,8 @@ sh_test( "@fine_grained_deps_%s//ajv" % pkgmgr, "@fine_grained_deps_%s//typescript" % pkgmgr, "@fine_grained_deps_%s//rxjs" % pkgmgr, - # Note, test-b depends on test-a@0.0.1 which should get - # hoisted to node_modules/test-b/node_modules/test-a + # Note, test-b depends on test-a@0.0.1 which should be + # layed out at node_modules/test-b/node_modules/test-a "@fine_grained_deps_%s//@gregmagolan/test-b" % pkgmgr, ], ) for pkgmgr in [ diff --git a/internal/npm_install/test/golden/@angular/core/BUILD.bazel.golden b/internal/npm_install/test/golden/@angular/core/BUILD.bazel.golden index f113b2d469..a7fe7c8578 100644 --- a/internal/npm_install/test/golden/@angular/core/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/@angular/core/BUILD.bazel.golden @@ -6,7 +6,6 @@ filegroup( srcs = [ "//:node_modules/@angular/core/ANGULAR_PACKAGE", "//:node_modules/@angular/core/BUILD_INFO", - "//:node_modules/@angular/core/README.md", "//:node_modules/@angular/core/bundles/core-testing.umd.js", "//:node_modules/@angular/core/bundles/core-testing.umd.js.map", "//:node_modules/@angular/core/bundles/core-testing.umd.min.js", @@ -666,16 +665,22 @@ filegroup( ) filegroup( name = "core__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "core__not_files", + srcs = [ + "//:node_modules/@angular/core/README.md", + ], visibility = ["//visibility:private"], ) filegroup( name = "core__all_files", - srcs = [":core__files", ":core__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":core__files", ":core__not_files"], ) node_module_library( name = "core", - srcs = [":core__all_files"], + srcs = [":core__files"], deps = [ "//@angular/core:core__contents", "//tslib:tslib__contents", @@ -685,7 +690,7 @@ node_module_library( ) node_module_library( name = "core__contents", - srcs = [":core__all_files"], + srcs = [":core__files", ":core__nested_node_modules"], named_module_srcs = [ "//:node_modules/@angular/core/bundles/core-testing.umd.js", "//:node_modules/@angular/core/bundles/core.umd.js", diff --git a/internal/npm_install/test/golden/@gregmagolan/BUILD.bazel.golden b/internal/npm_install/test/golden/@gregmagolan/BUILD.bazel.golden index 795893c9df..0cbf7c526e 100644 --- a/internal/npm_install/test/golden/@gregmagolan/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/@gregmagolan/BUILD.bazel.golden @@ -4,8 +4,8 @@ load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", node_module_library( name = "@gregmagolan", srcs = [ - "//@gregmagolan/test-a:test-a__all_files", - "//@gregmagolan/test-b:test-b__all_files", + "//@gregmagolan/test-a:test-a__files", + "//@gregmagolan/test-b:test-b__files", ], deps = [ "//@gregmagolan/test-a:test-a__contents", diff --git a/internal/npm_install/test/golden/@gregmagolan/test-a/BUILD.bazel.golden b/internal/npm_install/test/golden/@gregmagolan/test-a/BUILD.bazel.golden index 60e22cc90a..e480bc011d 100644 --- a/internal/npm_install/test/golden/@gregmagolan/test-a/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/@gregmagolan/test-a/BUILD.bazel.golden @@ -11,23 +11,30 @@ filegroup( ) filegroup( name = "test-a__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "test-a__not_files", + srcs = [ + "//:node_modules/@gregmagolan/test-a/filename with spaces.js", + "//:node_modules/@gregmagolan/test-a/filenamË-with-unicodË-chars.js", + ], visibility = ["//visibility:private"], ) filegroup( name = "test-a__all_files", - srcs = [":test-a__files", ":test-a__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":test-a__files", ":test-a__not_files"], ) node_module_library( name = "test-a", - srcs = [":test-a__all_files"], + srcs = [":test-a__files"], deps = [ "//@gregmagolan/test-a:test-a__contents", ], ) node_module_library( name = "test-a__contents", - srcs = [":test-a__all_files"], + srcs = [":test-a__files", ":test-a__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/@gregmagolan/test-b/BUILD.bazel.golden b/internal/npm_install/test/golden/@gregmagolan/test-b/BUILD.bazel.golden index 34c64b684f..585d7a324f 100644 --- a/internal/npm_install/test/golden/@gregmagolan/test-b/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/@gregmagolan/test-b/BUILD.bazel.golden @@ -14,23 +14,26 @@ filegroup( "//:node_modules/@gregmagolan/test-b/node_modules/@gregmagolan/test-a/main.js", "//:node_modules/@gregmagolan/test-b/node_modules/@gregmagolan/test-a/package.json", ], + visibility = ["//:__subpackages__"], +) +filegroup( + name = "test-b__not_files", visibility = ["//visibility:private"], ) filegroup( name = "test-b__all_files", - srcs = [":test-b__files", ":test-b__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":test-b__files", ":test-b__not_files"], ) node_module_library( name = "test-b", - srcs = [":test-b__all_files"], + srcs = [":test-b__files"], deps = [ "//@gregmagolan/test-b:test-b__contents", ], ) node_module_library( name = "test-b__contents", - srcs = [":test-b__all_files"], + srcs = [":test-b__files", ":test-b__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/BUILD.bazel.golden b/internal/npm_install/test/golden/BUILD.bazel.golden index 26d3c9ac4c..77459dcaa9 100644 --- a/internal/npm_install/test/golden/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/BUILD.bazel.golden @@ -4677,6 +4677,8 @@ exports_files([ "node_modules/@angular/core/testing/testing.d.ts", "node_modules/@angular/core/testing/testing.metadata.json", "node_modules/@gregmagolan/test-a/@bin/test.js", + "node_modules/@gregmagolan/test-a/filename with spaces.js", + "node_modules/@gregmagolan/test-a/filenamË-with-unicodË-chars.js", "node_modules/@gregmagolan/test-a/main.js", "node_modules/@gregmagolan/test-a/package.json", "node_modules/@gregmagolan/test-b/main.js", @@ -4687,32 +4689,58 @@ exports_files([ node_module_library( name = "node_modules", srcs = [ - "//ajv:ajv__all_files", - "//balanced-match:balanced-match__all_files", - "//brace-expansion:brace-expansion__all_files", - "//co:co__all_files", - "//concat-map:concat-map__all_files", - "//diff:diff__all_files", - "//fast-deep-equal:fast-deep-equal__all_files", - "//fast-json-stable-stringify:fast-json-stable-stringify__all_files", - "//fs.realpath:fs.realpath__all_files", - "//glob:glob__all_files", - "//inflight:inflight__all_files", - "//inherits:inherits__all_files", - "//jasmine:jasmine__all_files", - "//jasmine-core:jasmine-core__all_files", - "//json-schema-traverse:json-schema-traverse__all_files", - "//minimatch:minimatch__all_files", - "//once:once__all_files", - "//path-is-absolute:path-is-absolute__all_files", - "//rxjs:rxjs__all_files", - "//tslib:tslib__all_files", - "//unidiff:unidiff__all_files", - "//wrappy:wrappy__all_files", - "//zone.js:zone.js__all_files", - "//@angular/core:core__all_files", - "//@gregmagolan/test-a:test-a__all_files", - "//@gregmagolan/test-b:test-b__all_files", + "//ajv:ajv__files", + "//ajv:ajv__nested_node_modules", + "//balanced-match:balanced-match__files", + "//balanced-match:balanced-match__nested_node_modules", + "//brace-expansion:brace-expansion__files", + "//brace-expansion:brace-expansion__nested_node_modules", + "//co:co__files", + "//co:co__nested_node_modules", + "//concat-map:concat-map__files", + "//concat-map:concat-map__nested_node_modules", + "//diff:diff__files", + "//diff:diff__nested_node_modules", + "//fast-deep-equal:fast-deep-equal__files", + "//fast-deep-equal:fast-deep-equal__nested_node_modules", + "//fast-json-stable-stringify:fast-json-stable-stringify__files", + "//fast-json-stable-stringify:fast-json-stable-stringify__nested_node_modules", + "//fs.realpath:fs.realpath__files", + "//fs.realpath:fs.realpath__nested_node_modules", + "//glob:glob__files", + "//glob:glob__nested_node_modules", + "//inflight:inflight__files", + "//inflight:inflight__nested_node_modules", + "//inherits:inherits__files", + "//inherits:inherits__nested_node_modules", + "//jasmine:jasmine__files", + "//jasmine:jasmine__nested_node_modules", + "//jasmine-core:jasmine-core__files", + "//jasmine-core:jasmine-core__nested_node_modules", + "//json-schema-traverse:json-schema-traverse__files", + "//json-schema-traverse:json-schema-traverse__nested_node_modules", + "//minimatch:minimatch__files", + "//minimatch:minimatch__nested_node_modules", + "//once:once__files", + "//once:once__nested_node_modules", + "//path-is-absolute:path-is-absolute__files", + "//path-is-absolute:path-is-absolute__nested_node_modules", + "//rxjs:rxjs__files", + "//rxjs:rxjs__nested_node_modules", + "//tslib:tslib__files", + "//tslib:tslib__nested_node_modules", + "//unidiff:unidiff__files", + "//unidiff:unidiff__nested_node_modules", + "//wrappy:wrappy__files", + "//wrappy:wrappy__nested_node_modules", + "//zone.js:zone.js__files", + "//zone.js:zone.js__nested_node_modules", + "//@angular/core:core__files", + "//@angular/core:core__nested_node_modules", + "//@gregmagolan/test-a:test-a__files", + "//@gregmagolan/test-a:test-a__nested_node_modules", + "//@gregmagolan/test-b:test-b__files", + "//@gregmagolan/test-b:test-b__nested_node_modules", ], deps = [ "//ajv:ajv__contents", diff --git a/internal/npm_install/test/golden/ajv/BUILD.bazel.golden b/internal/npm_install/test/golden/ajv/BUILD.bazel.golden index 85e801865f..2b1e5931f4 100644 --- a/internal/npm_install/test/golden/ajv/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/ajv/BUILD.bazel.golden @@ -6,7 +6,6 @@ filegroup( srcs = [ "//:node_modules/ajv/.tonic_example.js", "//:node_modules/ajv/LICENSE", - "//:node_modules/ajv/README.md", "//:node_modules/ajv/dist/ajv.bundle.js", "//:node_modules/ajv/dist/ajv.min.js", "//:node_modules/ajv/dist/ajv.min.js.map", @@ -33,18 +32,13 @@ filegroup( "//:node_modules/ajv/lib/dot/_limitProperties.jst", "//:node_modules/ajv/lib/dot/allOf.jst", "//:node_modules/ajv/lib/dot/anyOf.jst", - "//:node_modules/ajv/lib/dot/coerce.def", "//:node_modules/ajv/lib/dot/const.jst", "//:node_modules/ajv/lib/dot/contains.jst", "//:node_modules/ajv/lib/dot/custom.jst", - "//:node_modules/ajv/lib/dot/defaults.def", - "//:node_modules/ajv/lib/dot/definitions.def", "//:node_modules/ajv/lib/dot/dependencies.jst", "//:node_modules/ajv/lib/dot/enum.jst", - "//:node_modules/ajv/lib/dot/errors.def", "//:node_modules/ajv/lib/dot/format.jst", "//:node_modules/ajv/lib/dot/items.jst", - "//:node_modules/ajv/lib/dot/missing.def", "//:node_modules/ajv/lib/dot/multipleOf.jst", "//:node_modules/ajv/lib/dot/not.jst", "//:node_modules/ajv/lib/dot/oneOf.jst", @@ -55,7 +49,6 @@ filegroup( "//:node_modules/ajv/lib/dot/required.jst", "//:node_modules/ajv/lib/dot/uniqueItems.jst", "//:node_modules/ajv/lib/dot/validate.jst", - "//:node_modules/ajv/lib/dotjs/README.md", "//:node_modules/ajv/lib/dotjs/_limit.js", "//:node_modules/ajv/lib/dotjs/_limitItems.js", "//:node_modules/ajv/lib/dotjs/_limitLength.js", @@ -86,7 +79,6 @@ filegroup( "//:node_modules/ajv/lib/refs/json-schema-draft-06.json", "//:node_modules/ajv/lib/refs/json-schema-v5.json", "//:node_modules/ajv/package.json", - "//:node_modules/ajv/scripts/.eslintrc.yml", "//:node_modules/ajv/scripts/bundle.js", "//:node_modules/ajv/scripts/compile-dots.js", "//:node_modules/ajv/scripts/info", @@ -96,16 +88,29 @@ filegroup( ) filegroup( name = "ajv__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "ajv__not_files", + srcs = [ + "//:node_modules/ajv/README.md", + "//:node_modules/ajv/lib/dot/coerce.def", + "//:node_modules/ajv/lib/dot/defaults.def", + "//:node_modules/ajv/lib/dot/definitions.def", + "//:node_modules/ajv/lib/dot/errors.def", + "//:node_modules/ajv/lib/dot/missing.def", + "//:node_modules/ajv/lib/dotjs/README.md", + "//:node_modules/ajv/scripts/.eslintrc.yml", + ], visibility = ["//visibility:private"], ) filegroup( name = "ajv__all_files", - srcs = [":ajv__files", ":ajv__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":ajv__files", ":ajv__not_files"], ) node_module_library( name = "ajv", - srcs = [":ajv__all_files"], + srcs = [":ajv__files"], deps = [ "//ajv:ajv__contents", "//co:co__contents", @@ -116,7 +121,7 @@ node_module_library( ) node_module_library( name = "ajv__contents", - srcs = [":ajv__all_files"], + srcs = [":ajv__files", ":ajv__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/jasmine/BUILD.bazel.golden b/internal/npm_install/test/golden/jasmine/BUILD.bazel.golden index 9dd37d5a27..59d80d504b 100644 --- a/internal/npm_install/test/golden/jasmine/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/jasmine/BUILD.bazel.golden @@ -5,10 +5,7 @@ filegroup( name = "jasmine__files", srcs = [ "//:node_modules/jasmine/.editorconfig", - "//:node_modules/jasmine/.travis.yml", "//:node_modules/jasmine/Gruntfile.js", - "//:node_modules/jasmine/MIT.LICENSE", - "//:node_modules/jasmine/README.md", "//:node_modules/jasmine/bin/jasmine.js", "//:node_modules/jasmine/lib/command.js", "//:node_modules/jasmine/lib/examples/jasmine.json", @@ -22,16 +19,24 @@ filegroup( ) filegroup( name = "jasmine__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "jasmine__not_files", + srcs = [ + "//:node_modules/jasmine/.travis.yml", + "//:node_modules/jasmine/MIT.LICENSE", + "//:node_modules/jasmine/README.md", + ], visibility = ["//visibility:private"], ) filegroup( name = "jasmine__all_files", - srcs = [":jasmine__files", ":jasmine__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":jasmine__files", ":jasmine__not_files"], ) node_module_library( name = "jasmine", - srcs = [":jasmine__all_files"], + srcs = [":jasmine__files"], deps = [ "//jasmine:jasmine__contents", "//glob:glob__contents", @@ -50,7 +55,7 @@ node_module_library( ) node_module_library( name = "jasmine__contents", - srcs = [":jasmine__all_files"], + srcs = [":jasmine__files", ":jasmine__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/rxjs/BUILD.bazel.golden b/internal/npm_install/test/golden/rxjs/BUILD.bazel.golden index 66dc614088..20edd2b0f6 100644 --- a/internal/npm_install/test/golden/rxjs/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/rxjs/BUILD.bazel.golden @@ -13,7 +13,6 @@ filegroup( "//:node_modules/rxjs/InnerSubscriber.d.ts", "//:node_modules/rxjs/InnerSubscriber.js", "//:node_modules/rxjs/InnerSubscriber.js.map", - "//:node_modules/rxjs/LICENSE.txt", "//:node_modules/rxjs/Notification.d.ts", "//:node_modules/rxjs/Notification.js", "//:node_modules/rxjs/Notification.js.map", @@ -29,7 +28,6 @@ filegroup( "//:node_modules/rxjs/OuterSubscriber.d.ts", "//:node_modules/rxjs/OuterSubscriber.js", "//:node_modules/rxjs/OuterSubscriber.js.map", - "//:node_modules/rxjs/README.md", "//:node_modules/rxjs/ReplaySubject.d.ts", "//:node_modules/rxjs/ReplaySubject.js", "//:node_modules/rxjs/ReplaySubject.js.map", @@ -51,8 +49,6 @@ filegroup( "//:node_modules/rxjs/Subscription.d.ts", "//:node_modules/rxjs/Subscription.js", "//:node_modules/rxjs/Subscription.js.map", - "//:node_modules/rxjs/_esm2015/LICENSE.txt", - "//:node_modules/rxjs/_esm2015/README.md", "//:node_modules/rxjs/_esm2015/ajax/index.js", "//:node_modules/rxjs/_esm2015/ajax/index.js.map", "//:node_modules/rxjs/_esm2015/fetch/index.js", @@ -504,8 +500,6 @@ filegroup( "//:node_modules/rxjs/_esm2015/testing/index.js.map", "//:node_modules/rxjs/_esm2015/webSocket/index.js", "//:node_modules/rxjs/_esm2015/webSocket/index.js.map", - "//:node_modules/rxjs/_esm5/LICENSE.txt", - "//:node_modules/rxjs/_esm5/README.md", "//:node_modules/rxjs/_esm5/ajax/index.js", "//:node_modules/rxjs/_esm5/ajax/index.js.map", "//:node_modules/rxjs/_esm5/fetch/index.js", @@ -2819,14 +2813,12 @@ filegroup( "//:node_modules/rxjs/src/AsyncSubject.ts", "//:node_modules/rxjs/src/BehaviorSubject.ts", "//:node_modules/rxjs/src/InnerSubscriber.ts", - "//:node_modules/rxjs/src/LICENSE.txt", "//:node_modules/rxjs/src/MiscJSDoc.ts", "//:node_modules/rxjs/src/Notification.ts", "//:node_modules/rxjs/src/Observable.ts", "//:node_modules/rxjs/src/Observer.ts", "//:node_modules/rxjs/src/Operator.ts", "//:node_modules/rxjs/src/OuterSubscriber.ts", - "//:node_modules/rxjs/src/README.md", "//:node_modules/rxjs/src/ReplaySubject.ts", "//:node_modules/rxjs/src/Rx.global.js", "//:node_modules/rxjs/src/Rx.ts", @@ -3615,16 +3607,29 @@ filegroup( ) filegroup( name = "rxjs__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "rxjs__not_files", + srcs = [ + "//:node_modules/rxjs/LICENSE.txt", + "//:node_modules/rxjs/README.md", + "//:node_modules/rxjs/_esm2015/LICENSE.txt", + "//:node_modules/rxjs/_esm2015/README.md", + "//:node_modules/rxjs/_esm5/LICENSE.txt", + "//:node_modules/rxjs/_esm5/README.md", + "//:node_modules/rxjs/src/LICENSE.txt", + "//:node_modules/rxjs/src/README.md", + ], visibility = ["//visibility:private"], ) filegroup( name = "rxjs__all_files", - srcs = [":rxjs__files", ":rxjs__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":rxjs__files", ":rxjs__not_files"], ) node_module_library( name = "rxjs", - srcs = [":rxjs__all_files"], + srcs = [":rxjs__files"], deps = [ "//rxjs:rxjs__contents", "//tslib:tslib__contents", @@ -3632,7 +3637,7 @@ node_module_library( ) node_module_library( name = "rxjs__contents", - srcs = [":rxjs__all_files"], + srcs = [":rxjs__files", ":rxjs__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/unidiff/BUILD.bazel.golden b/internal/npm_install/test/golden/unidiff/BUILD.bazel.golden index 075beb88b7..7aaea8236d 100644 --- a/internal/npm_install/test/golden/unidiff/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/unidiff/BUILD.bazel.golden @@ -8,7 +8,6 @@ filegroup( "//:node_modules/unidiff/LICENSE", "//:node_modules/unidiff/hunk.js", "//:node_modules/unidiff/package.json", - "//:node_modules/unidiff/readme.md", "//:node_modules/unidiff/test/example.js", "//:node_modules/unidiff/test/table.js", "//:node_modules/unidiff/test/test_hunk.js", @@ -18,16 +17,22 @@ filegroup( ) filegroup( name = "unidiff__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "unidiff__not_files", + srcs = [ + "//:node_modules/unidiff/readme.md", + ], visibility = ["//visibility:private"], ) filegroup( name = "unidiff__all_files", - srcs = [":unidiff__files", ":unidiff__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":unidiff__files", ":unidiff__not_files"], ) node_module_library( name = "unidiff", - srcs = [":unidiff__all_files"], + srcs = [":unidiff__files"], deps = [ "//unidiff:unidiff__contents", "//diff:diff__contents", @@ -35,7 +40,7 @@ node_module_library( ) node_module_library( name = "unidiff__contents", - srcs = [":unidiff__all_files"], + srcs = [":unidiff__files", ":unidiff__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/internal/npm_install/test/golden/zone.js/BUILD.bazel.golden b/internal/npm_install/test/golden/zone.js/BUILD.bazel.golden index c2969711f0..e2079693df 100644 --- a/internal/npm_install/test/golden/zone.js/BUILD.bazel.golden +++ b/internal/npm_install/test/golden/zone.js/BUILD.bazel.golden @@ -4,10 +4,7 @@ load("@build_bazel_rules_nodejs//internal/npm_install:node_module_library.bzl", filegroup( name = "zone.js__files", srcs = [ - "//:node_modules/zone.js/CHANGELOG.md", "//:node_modules/zone.js/LICENSE", - "//:node_modules/zone.js/LICENSE.wrapped", - "//:node_modules/zone.js/README.md", "//:node_modules/zone.js/dist/async-test.js", "//:node_modules/zone.js/dist/fake-async-test.js", "//:node_modules/zone.js/dist/jasmine-patch.js", @@ -136,23 +133,31 @@ filegroup( ) filegroup( name = "zone.js__nested_node_modules", + visibility = ["//:__subpackages__"], +) +filegroup( + name = "zone.js__not_files", + srcs = [ + "//:node_modules/zone.js/CHANGELOG.md", + "//:node_modules/zone.js/LICENSE.wrapped", + "//:node_modules/zone.js/README.md", + ], visibility = ["//visibility:private"], ) filegroup( name = "zone.js__all_files", - srcs = [":zone.js__files", ":zone.js__nested_node_modules"], - visibility = ["//:__subpackages__"], + srcs = [":zone.js__files", ":zone.js__not_files"], ) node_module_library( name = "zone.js", - srcs = [":zone.js__all_files"], + srcs = [":zone.js__files"], deps = [ "//zone.js:zone.js__contents", ], ) node_module_library( name = "zone.js__contents", - srcs = [":zone.js__all_files"], + srcs = [":zone.js__files", ":zone.js__nested_node_modules"], visibility = ["//:__subpackages__"], ) node_module_library( diff --git a/package.json b/package.json index 993e12e3f3..034e8da21c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@bazel/ibazel": "^0.10.3", "@commitlint/cli": "^8.0.0", "@commitlint/config-conventional": "^8.0.0", + "@gregmagolan/test-a": "0.0.5", "@types/hammerjs": "2.0.35", "@types/jasmine": "~3.3.13", "@types/node": "10.12.20", diff --git a/tools/fine_grained_goldens/package.json b/tools/fine_grained_goldens/package.json index 2416d98868..ab44cbe043 100644 --- a/tools/fine_grained_goldens/package.json +++ b/tools/fine_grained_goldens/package.json @@ -3,7 +3,7 @@ "private": true, "devDependencies": { "@angular/core": "angular/core-builds#9.0.0-next.5+b5eda603a", - "@gregmagolan/test-a": "0.0.4", + "@gregmagolan/test-a": "0.0.5", "@gregmagolan/test-b": "0.0.2", "ajv": "5.5.2", "jasmine": "3.2.0", diff --git a/tools/fine_grained_goldens/yarn.lock b/tools/fine_grained_goldens/yarn.lock index 048541b220..ccd836ca4d 100644 --- a/tools/fine_grained_goldens/yarn.lock +++ b/tools/fine_grained_goldens/yarn.lock @@ -13,10 +13,10 @@ 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.4": - version "0.0.4" - resolved "https://registry.yarnpkg.com/@gregmagolan/test-a/-/test-a-0.0.4.tgz#d2a4cf0dc6be9b503d772bb7af16c279e2daa1d3" - integrity sha512-AhnqEFS5ZAC511I0d5/637dAHCRcumvfjgYL7bKw9ltI9ug9kNPCx3AFIpvJlWaColwPWgFCKigAsr8iCoDQHg== +"@gregmagolan/test-a@0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@gregmagolan/test-a/-/test-a-0.0.5.tgz#70133ee86d5fd41d7a7bea425275813240ed7e65" + integrity sha512-3lapkuCUxoMicBemybiuBdCSMsU3A6RugvFTMlZr7feTw7RHUeal7U52Ys71jAz/Vk+LbSb6FZYP+TFe5/0bwA== "@gregmagolan/test-b@0.0.2": version "0.0.2" diff --git a/yarn.lock b/yarn.lock index b476728990..67b541cca3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -902,6 +902,11 @@ dependencies: find-up "^4.0.0" +"@gregmagolan/test-a@0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@gregmagolan/test-a/-/test-a-0.0.5.tgz#70133ee86d5fd41d7a7bea425275813240ed7e65" + integrity sha512-3lapkuCUxoMicBemybiuBdCSMsU3A6RugvFTMlZr7feTw7RHUeal7U52Ys71jAz/Vk+LbSb6FZYP+TFe5/0bwA== + "@marionebl/sander@^0.6.0": version "0.6.1" resolved "https://registry.yarnpkg.com/@marionebl/sander/-/sander-0.6.1.tgz#1958965874f24bc51be48875feb50d642fc41f7b"