function printPackage(pkg) {
        const sources = filterFiles(pkg._files, INCLUDED_FILES);
        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 srcsStarlark = '';
        if (sources.length) {
            srcsStarlark = `
    # ${pkg._dir} package files (and files in nested node_modules)
    srcs = [
        ${sources.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        ')}
    ],`;
        }
        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)}

filegroup(
    name = "${pkg._name}__files",${srcsStarlark}
)

node_module_library(
    name = "${pkg._name}",
    # direct sources listed for strict deps support
    srcs = [":${pkg._name}__files"],${depsStarlark}
)

# ${pkg._name}__contents target is used as dep for main targets to prevent
# circular dependencies errors
node_module_library(
    name = "${pkg._name}__contents",
    srcs = [":${pkg._name}__files"],${namedSourcesStarlark}
)

# ${pkg._name}__typings is the subset of ${pkg._name}__contents that are declarations
node_module_library(
    name = "${pkg._name}__typings",${dtsStarlark}
)

`;
        let mainEntryPoint = resolvePkgMainFile(pkg);
        // add an `npm_umd_bundle` target to generate an UMD bundle if one does
        // not exists
        if (mainEntryPoint && !findFile(pkg, `${pkg._name}.umd.js`)) {
            result +=
                `load("@build_bazel_rules_nodejs//internal/npm_install:npm_umd_bundle.bzl", "npm_umd_bundle")

npm_umd_bundle(
    name = "${pkg._name}__umd",
    package_name = "${pkg._name}",
    entry_point = "//:node_modules/${pkg._dir}/${mainEntryPoint}",
    package = ":${pkg._name}",
)

`;
        }
        return result;
    }
/**
     * Given a pkg, return the skylark `node_module_library` targets for the package.
     */
Given a pkg, return the skylark `node_module_library` targets for the package.
Given a pkg return the skylark ` node_module_library ` targets for the package .
function printPackage(pkg) {
        const sources = filterFiles(pkg._files, INCLUDED_FILES);
        const dtsSources = filterFiles(pkg._files, ['.d.ts']);
        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 srcsStarlark = '';
        if (sources.length) {
            srcsStarlark = `
    # ${pkg._dir} package files (and files in nested node_modules)
    srcs = [
        ${sources.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        ')}
    ],`;
        }
        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)}
filegroup(
    name = "${pkg._name}__files",${srcsStarlark}
)
node_module_library(
    name = "${pkg._name}",
    # direct sources listed for strict deps support
    srcs = [":${pkg._name}__files"],${depsStarlark}
)
# ${pkg._name}__contents target is used as dep for main targets to prevent
# circular dependencies errors
node_module_library(
    name = "${pkg._name}__contents",
    srcs = [":${pkg._name}__files"],${namedSourcesStarlark}
)
# ${pkg._name}__typings is the subset of ${pkg._name}__contents that are declarations
node_module_library(
    name = "${pkg._name}__typings",${dtsStarlark}
)
`;
        let mainEntryPoint = resolvePkgMainFile(pkg);
        if (mainEntryPoint && !findFile(pkg, `${pkg._name}.umd.js`)) {
            result +=
                `load("@build_bazel_rules_nodejs//internal/npm_install:npm_umd_bundle.bzl", "npm_umd_bundle")
npm_umd_bundle(
    name = "${pkg._name}__umd",
    package_name = "${pkg._name}",
    entry_point = "//:node_modules/${pkg._dir}/${mainEntryPoint}",
    package = ":${pkg._name}",
)
`;
        }
        return result;
    }
function printPackage ( pkg ) { const sources = filterFiles ( pkg . _files , INCLUDED_FILES ) ; const dtsSources = filterFiles ( pkg . _files , [ '.d.ts' ] ) ; const namedSources = getNgApfScripts ( pkg ) ; const deps = [ pkg ] . concat ( pkg . _dependencies . filter ( dep => dep !== pkg && ! dep . _isNested ) ) ; let namedSourcesStarlark = '' ; if ( namedSources . length ) { namedSourcesStarlark = ` ${ namedSources . map ( ( f ) => ` ${ pkg . _dir } ${ f } ` ) . join ( '\n        ' ) } ` ; } let srcsStarlark = '' ; if ( sources . length ) { srcsStarlark = ` ${ pkg . _dir } ${ sources . map ( ( f ) => ` ${ pkg . _dir } ${ f } ` ) . join ( '\n        ' ) } ` ; } let depsStarlark = '' ; if ( deps . length ) { const list = deps . map ( dep => ` ${ dep . _dir } ${ dep . _name } ` ) . join ( '\n        ' ) ; depsStarlark = ` ${ list } ` ; } let dtsStarlark = '' ; if ( dtsSources . length ) { dtsStarlark = ` ${ pkg . _dir } ${ dtsSources . map ( f => ` ${ pkg . _dir } ${ f } ` ) . join ( '\n        ' ) } ` ; } let result = ` ${ pkg . _dir } ${ printJson ( pkg ) } ${ pkg . _name } ${ srcsStarlark } ${ pkg . _name } ${ pkg . _name } ${ depsStarlark } ${ pkg . _name } ${ pkg . _name } ${ pkg . _name } ${ namedSourcesStarlark } ${ pkg . _name } ${ pkg . _name } ${ pkg . _name } ${ dtsStarlark } ` ; let mainEntryPoint = resolvePkgMainFile ( pkg ) ; if ( mainEntryPoint && ! findFile ( pkg , ` ${ pkg . _name } ` ) ) { result += ` ${ pkg . _name } ${ pkg . _name } ${ pkg . _dir } ${ mainEntryPoint } ${ pkg . _name } ` ; } return result ; }
Given a pkg, return the skylark `node_module_library` targets for the package.
Given a pkg return the skylark ` node_module_library ` targets for the package .
// TODO(gmagolan): add UMD & AMD scripts to scripts even if not an APF package _but_ only if they // are named? // add an `npm_umd_bundle` target to generate an UMD bundle if one does // not exists