ng-packagr 13.0.5 → 13.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,7 +82,7 @@ async function rollupBundleFile(opts) {
82
82
  }
83
83
  const { code, map } = output.output[0];
84
84
  return {
85
- code,
85
+ code: code + '//# sourceMapping' + `URL=${path.basename(opts.dest)}.map\n`,
86
86
  map,
87
87
  cache: bundle.cache,
88
88
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;AAC7B,+CAAiC;AAEjC,wFAAkD;AAElD,0CAAgE;AAChE,kDAAoC;AACpC,wCAA+C;AAmB/C,mEAAmE;AAC5D,KAAK,UAAU,gBAAgB,CACpC,IAAmB;;IAEnB,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAEvE,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAE3C,oBAAoB;IACpB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;QACjC,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC;QACpD,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACvG,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE;YACP,IAAA,6BAAW,GAAE;YACb,IAAA,kCAAU,EAAC;gBACT,QAAQ,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ACnF;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEvC,OAAO;QACL,IAAI;QACJ,GAAG;QACH,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AA9DD,4CA8DC;AAED,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,oEAAoE;IACpE,yFAAyF;IACzF,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACrF,yGAAyG;QACzG,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as path from 'path';\nimport * as rollup from 'rollup';\nimport { TransformHook } from 'rollup';\nimport sourcemaps from 'rollup-plugin-sourcemaps';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n dest: string;\n sourceRoot: string;\n transform?: TransformHook;\n cache?: rollup.RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: rollup.RollupCache; code: string; map: rollup.SourceMap }> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest}`);\n\n const cacheDirectory = opts.cacheDirectory;\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => isExternalDependency(moduleId),\n inlineDynamicImports: false,\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins: [\n nodeResolve(),\n sourcemaps({\n readFile: (path: string, callback: (error: Error | null, data: Buffer | string) => void) => {\n const fileData = opts.fileCache.get(ensureUnixPath(path));\n callback(fileData ? null : new Error(`Could not load '${path}' from memory.`), fileData?.content);\n },\n }),\n rollupJson(),\n opts.transform ? { transform: opts.transform, name: 'downlevel-ts' } : undefined,\n ],\n onwarn: warning => {\n switch (warning.code) {\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n file: opts.dest,\n banner: '',\n sourcemap: true,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));\n }\n\n const { code, map } = output.output[0];\n\n return {\n code,\n map,\n cache: bundle.cache,\n };\n}\n\nfunction isExternalDependency(moduleId: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;AAC7B,+CAAiC;AAEjC,wFAAkD;AAElD,0CAAgE;AAChE,kDAAoC;AACpC,wCAA+C;AAmB/C,mEAAmE;AAC5D,KAAK,UAAU,gBAA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I,CAAC;AACd,CAAC","sourcesContent":["import rollupJson from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as path from 'path';\nimport * as rollup from 'rollup';\nimport { TransformHook } from 'rollup';\nimport sourcemaps from 'rollup-plugin-sourcemaps';\nimport { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Options used in `ng-packagr` for writing flat bundle files.\n *\n * These options are passed through to rollup.\n */\nexport interface RollupOptions {\n moduleName: string;\n entry: string;\n dest: string;\n sourceRoot: string;\n transform?: TransformHook;\n cache?: rollup.RollupCache;\n cacheDirectory?: string | false;\n fileCache: OutputFileCache;\n cacheKey: string;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(\n opts: RollupOptions,\n): Promise<{ cache: rollup.RollupCache; code: string; map: rollup.SourceMap }> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest}`);\n\n const cacheDirectory = opts.cacheDirectory;\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => isExternalDependency(moduleId),\n inlineDynamicImports: false,\n cache: opts.cache ?? (cacheDirectory ? await readCacheEntry(cacheDirectory, opts.cacheKey) : undefined),\n input: opts.entry,\n plugins: [\n nodeResolve(),\n sourcemaps({\n readFile: (path: string, callback: (error: Error | null, data: Buffer | string) => void) => {\n const fileData = opts.fileCache.get(ensureUnixPath(path));\n callback(fileData ? null : new Error(`Could not load '${path}' from memory.`), fileData?.content);\n },\n }),\n rollupJson(),\n opts.transform ? { transform: opts.transform, name: 'downlevel-ts' } : undefined,\n ],\n onwarn: warning => {\n switch (warning.code) {\n case 'UNUSED_EXTERNAL_IMPORT':\n case 'THIS_IS_UNDEFINED':\n break;\n\n default:\n log.warn(warning.message);\n break;\n }\n },\n preserveSymlinks: true,\n // Disable treeshaking when generating bundles\n // see: https://github.com/angular/angular/pull/32069\n treeshake: false,\n });\n\n // Output the bundle to disk\n const output = await bundle.write({\n name: opts.moduleName,\n format: 'es',\n file: opts.dest,\n banner: '',\n sourcemap: true,\n });\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, opts.cacheKey, JSON.stringify(bundle.cache));\n }\n\n const { code, map } = output.output[0];\n\n return {\n code: code + '//# sourceMapping' + `URL=${path.basename(opts.dest)}.map\\n`,\n map,\n cache: bundle.cache,\n };\n}\n\nfunction isExternalDependency(moduleId: string): boolean {\n // more information about why we don't check for 'node_modules' path\n // https://github.com/rollup/rollup-plugin-node-resolve/issues/110#issuecomment-350353632\n if (moduleId.startsWith('.') || moduleId.startsWith('/') || path.isAbsolute(moduleId)) {\n // if it's either 'absolute', marked to embed, starts with a '.' or '/' or is the umd bundle and is tslib\n return false;\n }\n\n return true;\n}\n"]}
@@ -246,8 +246,7 @@ function checkNonPeerDependencies(packageJson, property, allowed, spinner) {
246
246
  * This is supposed to match with: https://github.com/angular/angular/blob/e0667efa6eada64d1fb8b143840689090fc82e52/packages/bazel/src/ng_package/packager.ts#L415.
247
247
  */
248
248
  function generatePackageExports({ destinationPath, packageJson }, graph) {
249
- var _a;
250
- const exports = (_a = packageJson.exports) !== null && _a !== void 0 ? _a : {};
249
+ const exports = packageJson.exports ? JSON.parse(JSON.stringify(packageJson.exports)) : {};
251
250
  const insertMappingOrError = (subpath, mapping) => {
252
251
  if (exports[subpath] === undefined) {
253
252
  exports[subpath] = {};
@@ -1 +1 @@
1
- {"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,2CAA6B;AAE7B,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAkE;AAClE,2CAA6C;AAC7C,qDAAuC;AACvC,2CAAkD;AAClD,oCAAiH;AAO1G,MAAM,qBAAq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E,CAAC,CAAC,CAAC,GAAG,CAAC;QAEhF,oBAAoB,CAAC,OAAO,EAAE;YAC5B,KAAK,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,YAAY,CAAC;YAC9D,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3D,MAAM,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;YAC3D,MAAM,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;YAC3D,IAAI,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;YACzD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC7D,CAAC,CAAC;KACJ;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, rmdir, stat, writeFile } from '../../utils/fs';\nimport { globFiles } from '../../utils/glob';\nimport * as log from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, fileUrl, isEntryPoint, isEntryPointInProgress, isPackage } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n const assetFiles: string[] = [];\n\n // COPY ASSET FILES TO DESTINATION\n spinner.start('Copying assets');\n\n try {\n for (const asset of [...ngPackage.assets, 'LICENSE', '**/README.md']) {\n let assetFullPath = path.join(ngPackage.src, asset);\n\n try {\n const stats = await stat(assetFullPath);\n if (stats.isFile()) {\n assetFiles.push(assetFullPath);\n continue;\n }\n\n if (stats.isDirectory()) {\n assetFullPath = path.join(assetFullPath, '**/*');\n }\n } catch {}\n\n if (asset === 'LICENSE') {\n continue;\n }\n\n const files = await globFiles(assetFullPath, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n });\n\n if (files.length) {\n assetFiles.push(...files);\n }\n }\n\n for (const file of assetFiles) {\n const relativePath = path.relative(ngPackage.src, file);\n const destination = path.resolve(ngPackage.dest, relativePath);\n const nodeUri = fileUrl(ensureUnixPath(file));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n entryPoint.dependsOn(node);\n await copyFile(file, destination);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n try {\n spinner.start('Writing package manifest');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),\n fesm2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n exports: ngEntryPoint.isSecondaryEntryPoint ? undefined : generatePackageExports(ngEntryPoint, graph),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = `0.0.0-watch+${Date.now()}`;\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n\n delete packageJson.peerDependencies.tslib;\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (!entryPoint.isSecondaryEntryPoint && compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep}` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n\ntype PackageExports = Record<string, ConditionalExport>;\n\n/**\n * Type describing the conditional exports descriptor for an entry-point.\n * https://nodejs.org/api/packages.html#packages_conditional_exports\n */\ntype ConditionalExport = {\n node?: string;\n types?: string;\n esm2020?: string;\n es2020?: string;\n es2015?: string;\n default?: string;\n};\n\n/**\n * Generates the `package.json` package exports following APF v13.\n * This is supposed to match with: https://github.com/angular/angular/blob/e0667efa6eada64d1fb8b143840689090fc82e52/packages/bazel/src/ng_package/packager.ts#L415.\n */\nfunction generatePackageExports({ destinationPath, packageJson }: NgEntryPoint, graph: BuildGraph): PackageExports {\n const exports: PackageExports = packageJson.exports ?? {};\n\n const insertMappingOrError = (subpath: string, mapping: ConditionalExport) => {\n if (exports[subpath] === undefined) {\n exports[subpath] = {};\n }\n\n const subpathExport = exports[subpath];\n\n // Go through all conditions that should be inserted. If the condition is already\n // manually set of the subpath export, we throw an error. In general, we allow for\n // additional conditions to be set. These will always precede the generated ones.\n for (const conditionName of Object.keys(mapping) as [keyof ConditionalExport]) {\n if (subpathExport[conditionName] !== undefined) {\n throw Error(\n `Found a conflicting export condition for \"${subpath}\". The \"${conditionName}\" ` +\n `condition would be overridden by ng-packagr. Please unset it.`,\n );\n }\n\n // **Note**: The order of the conditions is preserved even though we are setting\n // the conditions once at a time (the latest assignment will be at the end).\n subpathExport[conditionName] = mapping[conditionName];\n }\n };\n\n const relativeUnixFromDestPath = (filePath: string) =>\n './' + ensureUnixPath(path.relative(destinationPath, filePath));\n\n insertMappingOrError('./package.json', { default: './package.json' });\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n const { destinationFiles, isSecondaryEntryPoint } = entryPoint.data.entryPoint;\n const subpath = isSecondaryEntryPoint ? `./${destinationFiles.directory}` : '.';\n\n insertMappingOrError(subpath, {\n types: relativeUnixFromDestPath(destinationFiles.declarations),\n esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),\n es2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n node: relativeUnixFromDestPath(destinationFiles.fesm2015),\n default: relativeUnixFromDestPath(destinationFiles.fesm2020),\n });\n }\n\n return exports;\n}\n"]}
1
+ {"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,2CAA6B;AAE7B,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAkE;AAClE,2CAA6C;AAC7C,qDAAuC;AACvC,2CAAkD;AAClD,oCAAiH;AAO1G,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;;IACjC,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,C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C;YAC3D,IAAI,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;YACzD,OAAO,EAAE,wBAAwB,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC7D,CAAC,CAAC;KACJ;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, rmdir, stat, writeFile } from '../../utils/fs';\nimport { globFiles } from '../../utils/glob';\nimport * as log from '../../utils/log';\nimport { ensureUnixPath } from '../../utils/path';\nimport { EntryPointNode, PackageNode, fileUrl, isEntryPoint, isEntryPointInProgress, isPackage } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\nimport { NgPackage } from '../package';\nimport { NgEntryPoint } from './entry-point';\n\ntype CompilationMode = 'partial' | 'full' | undefined;\n\nexport const writePackageTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n const assetFiles: string[] = [];\n\n // COPY ASSET FILES TO DESTINATION\n spinner.start('Copying assets');\n\n try {\n for (const asset of [...ngPackage.assets, 'LICENSE', '**/README.md']) {\n let assetFullPath = path.join(ngPackage.src, asset);\n\n try {\n const stats = await stat(assetFullPath);\n if (stats.isFile()) {\n assetFiles.push(assetFullPath);\n continue;\n }\n\n if (stats.isDirectory()) {\n assetFullPath = path.join(assetFullPath, '**/*');\n }\n } catch {}\n\n if (asset === 'LICENSE') {\n continue;\n }\n\n const files = await globFiles(assetFullPath, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n });\n\n if (files.length) {\n assetFiles.push(...files);\n }\n }\n\n for (const file of assetFiles) {\n const relativePath = path.relative(ngPackage.src, file);\n const destination = path.resolve(ngPackage.dest, relativePath);\n const nodeUri = fileUrl(ensureUnixPath(file));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n entryPoint.dependsOn(node);\n await copyFile(file, destination);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n try {\n spinner.start('Writing package manifest');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const { compilationMode } = entryPoint.data.tsConfig.options;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),\n fesm2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n exports: ngEntryPoint.isSecondaryEntryPoint ? undefined : generatePackageExports(ngEntryPoint, graph),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.packageJson.sideEffects ?? false,\n },\n !!options.watch,\n compilationMode as CompilationMode,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] | ConditionalExport },\n isWatchMode: boolean,\n compilationMode: CompilationMode,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = `0.0.0-watch+${Date.now()}`;\n }\n\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n\n delete packageJson.peerDependencies.tslib;\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rmdir(entryPoint.destinationPath, { recursive: true });\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (!entryPoint.isSecondaryEntryPoint && compilationMode !== 'partial') {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy in full compilation mode. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package with Ivy partial compilation mode, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep}` +\n `to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n\ntype PackageExports = Record<string, ConditionalExport>;\n\n/**\n * Type describing the conditional exports descriptor for an entry-point.\n * https://nodejs.org/api/packages.html#packages_conditional_exports\n */\ntype ConditionalExport = {\n node?: string;\n types?: string;\n esm2020?: string;\n es2020?: string;\n es2015?: string;\n default?: string;\n};\n\n/**\n * Generates the `package.json` package exports following APF v13.\n * This is supposed to match with: https://github.com/angular/angular/blob/e0667efa6eada64d1fb8b143840689090fc82e52/packages/bazel/src/ng_package/packager.ts#L415.\n */\nfunction generatePackageExports({ destinationPath, packageJson }: NgEntryPoint, graph: BuildGraph): PackageExports {\n const exports: PackageExports = packageJson.exports ? JSON.parse(JSON.stringify(packageJson.exports)) : {};\n\n const insertMappingOrError = (subpath: string, mapping: ConditionalExport) => {\n if (exports[subpath] === undefined) {\n exports[subpath] = {};\n }\n\n const subpathExport = exports[subpath];\n\n // Go through all conditions that should be inserted. If the condition is already\n // manually set of the subpath export, we throw an error. In general, we allow for\n // additional conditions to be set. These will always precede the generated ones.\n for (const conditionName of Object.keys(mapping) as [keyof ConditionalExport]) {\n if (subpathExport[conditionName] !== undefined) {\n throw Error(\n `Found a conflicting export condition for \"${subpath}\". The \"${conditionName}\" ` +\n `condition would be overridden by ng-packagr. Please unset it.`,\n );\n }\n\n // **Note**: The order of the conditions is preserved even though we are setting\n // the conditions once at a time (the latest assignment will be at the end).\n subpathExport[conditionName] = mapping[conditionName];\n }\n };\n\n const relativeUnixFromDestPath = (filePath: string) =>\n './' + ensureUnixPath(path.relative(destinationPath, filePath));\n\n insertMappingOrError('./package.json', { default: './package.json' });\n\n const entryPoints = graph.filter(isEntryPoint);\n for (const entryPoint of entryPoints) {\n const { destinationFiles, isSecondaryEntryPoint } = entryPoint.data.entryPoint;\n const subpath = isSecondaryEntryPoint ? `./${destinationFiles.directory}` : '.';\n\n insertMappingOrError(subpath, {\n types: relativeUnixFromDestPath(destinationFiles.declarations),\n esm2020: relativeUnixFromDestPath(destinationFiles.esm2020),\n es2020: relativeUnixFromDestPath(destinationFiles.fesm2020),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n node: relativeUnixFromDestPath(destinationFiles.fesm2015),\n default: relativeUnixFromDestPath(destinationFiles.fesm2020),\n });\n }\n\n return exports;\n}\n"]}
@@ -22,10 +22,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.colors = void 0;
23
23
  const ansiColors = __importStar(require("ansi-colors"));
24
24
  const tty_1 = require("tty");
25
- const supportsColor = process.stdout instanceof tty_1.WriteStream && process.stdout.getColorDepth() > 1;
25
+ function supportColor() {
26
+ if (process.env.FORCE_COLOR !== undefined) {
27
+ // 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1
28
+ // 16 colors: FORCE_COLOR = 1, depth 4
29
+ // 256 colors: FORCE_COLOR = 2, depth 8
30
+ // 16,777,216 colors: FORCE_COLOR = 3, depth 16
31
+ // See: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_getcolordepth_env
32
+ // and https://github.com/nodejs/node/blob/b9f36062d7b5c5039498e98d2f2c180dca2a7065/lib/internal/tty.js#L106;
33
+ switch (process.env.FORCE_COLOR) {
34
+ case '':
35
+ case 'true':
36
+ case '1':
37
+ case '2':
38
+ case '3':
39
+ return true;
40
+ default:
41
+ return false;
42
+ }
43
+ }
44
+ if (process.stdout instanceof tty_1.WriteStream) {
45
+ return process.stdout.getColorDepth() > 1;
46
+ }
47
+ return false;
48
+ }
26
49
  // Create a separate instance to prevent unintended global changes to the color configuration
27
50
  // Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44
28
51
  const colors = ansiColors.create();
29
52
  exports.colors = colors;
30
- colors.enabled = supportsColor;
53
+ colors.enabled = supportColor();
31
54
  //# sourceMappingURL=color.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/lib/utils/color.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAC1C,6BAAkC;AAIlC,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,YAAY,iBAAW,IAAI,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAElG,6FAA6F;AAC7F,mGAAmG;AACnG,MAAM,MAAM,GAAI,UAAwD,CAAC,MAAM,EAAE,CAAC;AAGzE,wBAAM;AAFf,MAAM,CAAC,OAAO,GAAG,aAAa,CAAC","sourcesContent":["import * as ansiColors from 'ansi-colors';\nimport { WriteStream } from 'tty';\n\ntype AnsiColors = typeof ansiColors;\n\nconst supportsColor = process.stdout instanceof WriteStream && process.stdout.getColorDepth() > 1;\n\n// Create a separate instance to prevent unintended global changes to the color configuration\n// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44\nconst colors = (ansiColors as AnsiColors & { create: () => AnsiColors }).create();\ncolors.enabled = supportsColor;\n\nexport { colors };\n"]}
1
+ {"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/lib/utils/color.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAC1C,6BAAkC;AAIlC,SAAS,YAAY;IACnB,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,EAAE;QACzC,uDAAuD;QACvD,sCAAsC;QACtC,uCAAuC;QACvC,+CAA+C;QAC/C,gGAAgG;QAChG,6GAA6G;QAC7G,QAAQ,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;YAC/B,KAAK,EAAE,CAAC;YACR,KAAK,MAAM,CAAC;YACZ,KAAK,GAAG,CAAC;YACT,KAAK,GAAG,CAAC;YACT,KAAK,GAAG;gBACN,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;KACF;IAED,IAAI,OAAO,CAAC,MAAM,YAAY,iBAAW,EAAE;QACzC,OAAO,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;KAC3C;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAGD,6FAA6F;AAC7F,mGAAmG;AACnG,MAAM,MAAM,GAAI,UAAwD,CAAC,MAAM,EAAE,CAAC;AAGzE,wBAAM;AAFf,MAAM,CAAC,OAAO,GAAG,YAAY,EAAE,CAAC","sourcesContent":["import * as ansiColors from 'ansi-colors';\nimport { WriteStream } from 'tty';\n\ntype AnsiColors = typeof ansiColors;\n\nfunction supportColor(): boolean {\n if (process.env.FORCE_COLOR !== undefined) {\n // 2 colors: FORCE_COLOR = 0 (Disables colors), depth 1\n // 16 colors: FORCE_COLOR = 1, depth 4\n // 256 colors: FORCE_COLOR = 2, depth 8\n // 16,777,216 colors: FORCE_COLOR = 3, depth 16\n // See: https://nodejs.org/dist/latest-v12.x/docs/api/tty.html#tty_writestream_getcolordepth_env\n // and https://github.com/nodejs/node/blob/b9f36062d7b5c5039498e98d2f2c180dca2a7065/lib/internal/tty.js#L106;\n switch (process.env.FORCE_COLOR) {\n case '':\n case 'true':\n case '1':\n case '2':\n case '3':\n return true;\n default:\n return false;\n }\n }\n\n if (process.stdout instanceof WriteStream) {\n return process.stdout.getColorDepth() > 1;\n }\n\n return false;\n}\n\n\n// Create a separate instance to prevent unintended global changes to the color configuration\n// Create function is not defined in the typings. See: https://github.com/doowb/ansi-colors/pull/44\nconst colors = (ansiColors as AnsiColors & { create: () => AnsiColors }).create();\ncolors.enabled = supportColor();\n\nexport { colors };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "13.0.5",
3
+ "version": "13.1.0",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -38,7 +38,7 @@
38
38
  "chokidar": "^3.5.1",
39
39
  "commander": "^8.0.0",
40
40
  "dependency-graph": "^0.11.0",
41
- "esbuild-wasm": "^0.13.0",
41
+ "esbuild-wasm": "^0.14.0",
42
42
  "find-cache-dir": "^3.3.1",
43
43
  "glob": "^7.1.6",
44
44
  "injection-js": "^2.4.0",
@@ -46,7 +46,7 @@
46
46
  "less": "^4.1.0",
47
47
  "ora": "^5.1.0",
48
48
  "postcss": "^8.2.4",
49
- "postcss-preset-env": "^7.0.0",
49
+ "postcss-preset-env": "^6.7.0",
50
50
  "postcss-url": "^10.1.1",
51
51
  "rollup": "^2.45.1",
52
52
  "rollup-plugin-sourcemaps": "^0.6.3",
@@ -55,11 +55,11 @@
55
55
  "stylus": "^0.55.0"
56
56
  },
57
57
  "optionalDependencies": {
58
- "esbuild": "^0.13.0"
58
+ "esbuild": "^0.14.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@angular/compiler-cli": "^13.0.0 || ^13.1.0-next",
61
+ "@angular/compiler-cli": "^13.0.0 || ^13.2.0-next",
62
62
  "tslib": "^2.3.0",
63
- "typescript": "~4.4.0"
63
+ "typescript": ">=4.4.0 <4.6"
64
64
  }
65
65
  }