ng-packagr 15.2.1 → 15.2.2
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.
|
@@ -88,6 +88,7 @@ class NgEntryPoint {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
get destinationFiles() {
|
|
91
|
+
var _a;
|
|
91
92
|
let primaryDestPath = this.destinationPath;
|
|
92
93
|
let secondaryDir = '';
|
|
93
94
|
if (this.secondaryData) {
|
|
@@ -97,7 +98,7 @@ class NgEntryPoint {
|
|
|
97
98
|
const flatModuleFile = this.flatModuleFile;
|
|
98
99
|
const pathJoinWithDest = (...paths) => path.join(primaryDestPath, ...paths);
|
|
99
100
|
return {
|
|
100
|
-
directory: (0, path_1.ensureUnixPath)(secondaryDir),
|
|
101
|
+
directory: (_a = (0, path_1.ensureUnixPath)(secondaryDir)) !== null && _a !== void 0 ? _a : '',
|
|
101
102
|
declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),
|
|
102
103
|
esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),
|
|
103
104
|
fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAG7B,2CAAkD;AAoBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACvB;IACE,+DAA+D;IAC/C,WAAgC;IAChD,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,iGAAiG;IAChF,aAAsC;QANvC,gBAAW,GAAX,WAAW,CAAqB;QAEhC,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CA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C;IACH,CAAC;IAEO,eAAe,CAAC,SAAS,GAAG,GAAG;QACrC,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9D;aAAM;YACL,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjD;IACH,CAAC;CACF;AA7GD,oCA6GC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../../utils/path';\n\n/** A list of output absolute paths for various formats */\nexport interface DestinationFiles {\n /** Absolute path of this entry point `declarations` */\n declarations: string;\n /** Absolute path of this entry point `FESM2020` module */\n fesm2020: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2020` module */\n esm2020: string;\n /** Sub path of entrypoint distributable. */\n directory: string;\n /** Absolute path of this entry point `FESM2020` directory */\n fesm2020Dir: string;\n /** Absolute path of this entry point `FESM2015` directory */\n fesm2015Dir: string;\n}\n\n/**\n * An entry point - quoting Angular Package Format - is:\n *\n * > a module intended to be imported by the user. It is referenced by a unique module ID and\n * > exports the public API referenced by that module ID. An example is `@angular/core` or\n * > `@angular/core/testing`. Both entry points exist in the `@angular/core` package, but they\n * > export different symbols. A package can have many entry points.\n *\n * #### Public API, source file tree and build output\n *\n * An entry point serves as the root of a source tree.\n * The entry point's public API references one TypeScript source file (`*.ts`).\n * That source file, e.g. `public_api.ts`, references other source files who in turn may reference\n * other source files, thus creating a tree of source code files.\n * The source files may be TypeScript (`*.ts`), Templates (`.html`) or Stylesheets\n * (`.css`, `.scss`, ..), or other formats.\n *\n * The compilation process for an entry point is a series of transformations applied to the source\n * files, e.g. TypeScript compilation, Inlining of Stylesheets and Templates, and so on.\n * As a result of the compilation process, an entry point is transpiled to a set of artefacts\n * (the build output) which include a FESM'15 Bundle, a FESM'5 Bundle, AoT metadata, TypeScript\n * type definitions, and so on.\n *\n * #### Representation in the domain\n *\n * The set of artefacts is reflected by `NgArtefacts`;\n * one `NgEntryPoint` relates to one `NgArtefacts`.\n * The parent package of an entry point is reflected by `NgPackage`.\n */\nexport class NgEntryPoint {\n constructor(\n /** Values from the `package.json` file of this entry point. */\n public readonly packageJson: Record<string, any>,\n /** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */\n public readonly ngPackageJson: NgPackageConfig,\n /** Absolute directory path of this entry point's `package.json` location. */\n public readonly basePath: string,\n /** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */\n private readonly secondaryData?: { [key: string]: any },\n ) {}\n\n /** Absolute file path of the entry point's source code entry file. */\n public get entryFilePath(): string {\n return path.resolve(this.basePath, this.entryFile);\n }\n\n /** Whether or not the entrypoint is secondary */\n public get isSecondaryEntryPoint(): boolean {\n return !!this.secondaryData;\n }\n\n /** Absolute directory path of this entry point's 'package.json'. */\n public get destinationPath(): string {\n if (this.secondaryData) {\n return this.secondaryData.destinationPath;\n } else {\n return path.resolve(this.basePath, this.$get('dest'));\n }\n }\n\n public get destinationFiles(): DestinationFiles {\n let primaryDestPath = this.destinationPath;\n let secondaryDir = '';\n\n if (this.secondaryData) {\n primaryDestPath = this.secondaryData.primaryDestinationPath;\n secondaryDir = path.relative(primaryDestPath, this.secondaryData.destinationPath);\n }\n\n const flatModuleFile = this.flatModuleFile;\n const pathJoinWithDest = (...paths: string[]) => path.join(primaryDestPath, ...paths);\n\n return {\n directory: ensureUnixPath(secondaryDir) ?? '',\n declarations: pathJoinWithDest(secondaryDir, 'index.d.ts'),\n esm2020: pathJoinWithDest('esm2020', secondaryDir, `${flatModuleFile}.mjs`),\n fesm2020: pathJoinWithDest('fesm2020', `${flatModuleFile}.mjs`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.mjs`),\n fesm2020Dir: pathJoinWithDest('fesm2020'),\n fesm2015Dir: pathJoinWithDest('fesm2015'),\n };\n }\n\n public $get(key: string): any {\n const parts = key.split('.');\n let value = this.ngPackageJson as unknown;\n for (const key of parts) {\n if (typeof value === 'object' && key in value) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n // `./index.ts` -> `index.ts`\n return path.posix.normalize(this.$get('lib.entryFile'));\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get flatModuleFile(): string {\n return this.$get('lib.flatModuleFile') || this.flattenModuleId('-');\n }\n\n public get styleIncludePaths(): string[] {\n const includePaths = this.$get('lib.styleIncludePaths') || [];\n\n return includePaths.map(includePath =>\n path.isAbsolute(includePath) ? includePath : path.resolve(this.basePath, includePath),\n );\n }\n\n /**\n * The module ID is an \"identifier of a module used in the import statements, e.g.\n * '@angular/core'. The ID often maps directly to a path on the filesystem, but this\n * is not always the case due to various module resolution strategies.\"\n */\n public get moduleId(): string {\n if (this.secondaryData) {\n return this.secondaryData.moduleId;\n } else {\n return this.packageJson['name'];\n }\n }\n\n private flattenModuleId(separator = '.') {\n if (this.moduleId.startsWith('@')) {\n return this.moduleId.substring(1).split('/').join(separator);\n } else {\n return this.moduleId.split('/').join(separator);\n }\n }\n}\n"]}
|
|
@@ -107,7 +107,7 @@ async function copyAssets(graph, entryPointNode, ngPackageNode) {
|
|
|
107
107
|
const defaultAssets = [
|
|
108
108
|
{ glob: 'LICENSE', input: '/', output: '/' },
|
|
109
109
|
...graph.filter(nodes_1.isEntryPoint).map(({ data }) => {
|
|
110
|
-
const subpath = data.entryPoint.destinationFiles.directory;
|
|
110
|
+
const subpath = data.entryPoint.destinationFiles.directory || '/';
|
|
111
111
|
return {
|
|
112
112
|
glob: 'README.md',
|
|
113
113
|
input: 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;AAG7B,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAoF;AACpF,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,CAAC;IACzD,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACrC,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IAE7C,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE;QACvC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAChC,IAAI;YACF,MAAM,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;SACpD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,KAAK,CAAC;SACb;QACD,OAAO,CAAC,OAAO,EAAE,CAAC;KACnB;IAED,wBAAwB;IACxB,8DAA8D;IAC9D,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE;QACvC,IAAI;YACF,OAAO,CAAC,KAAK,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,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAEtE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAC,CAAC;IAC/C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;QAC/E,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,SAAS,EAAE,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;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,OAAO,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, exists, readFile, 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\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n // As of APF 14 only the primary entrypoint has a package.json\n if (!ngEntryPoint.isSecondaryEntryPoint) {\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: 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 } else if (options.watch) {\n // update the watch version of the primary entry point `package.json` file.\n // this is needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/ng-packagr/ng-packagr/issues/2069\n const primary = ngPackageNode.data.primary;\n const packageJsonPath = path.join(primary.destinationPath, 'package.json');\n\n if (await exists(packageJsonPath)) {\n const packageJson = JSON.parse(await readFile(packageJsonPath, { encoding: 'utf8' }));\n packageJson.version = generateWatchVersion();\n await writeFile(path.join(primary.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n }\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...graph.filter(isEntryPoint).map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory;\n\n return {\n glob: 'README.md',\n input: subpath,\n output: subpath,\n };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(path.join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = {\n glob: path.basename(assetPath),\n input: path.dirname(assetPath),\n output: path.dirname(assetPath),\n };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = path.join(ngPackage.src, asset.input);\n asset.output = path.join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => path.relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await globFiles(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n follow: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = path.join(asset.input, filePath);\n const fileDestFullPath = path.join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\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 (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\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 // 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 (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\n/**\n * Generates a new version for the package `package.json` when runing in watch mode.\n */\nfunction generateWatchVersion() {\n return `0.0.0-watch+${Date.now()}`;\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;AAG7B,2CAAwC;AACxC,qDAA6D;AAC7D,6CAA2C;AAC3C,uCAAoF;AACpF,2CAA6C;AAC7C,qDAAuC;AACvC,2CAAkD;AAClD,oCAAiH;AAO1G,MAAM,q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BAAqB,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,SAAS,EAAE,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;AAED;;GAEG;AACH,SAAS,oBAAoB;IAC3B,OAAO,eAAe,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AACrC,CAAC","sourcesContent":["import ora from 'ora';\nimport * as path from 'path';\nimport { AssetPattern } from '../../../ng-package.schema';\nimport { BuildGraph } from '../../graph/build-graph';\nimport { Node } from '../../graph/node';\nimport { transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { copyFile, exists, readFile, 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\n if (!ngEntryPoint.isSecondaryEntryPoint) {\n spinner.start('Copying assets');\n try {\n await copyAssets(graph, entryPoint, ngPackageNode);\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n // As of APF 14 only the primary entrypoint has a package.json\n if (!ngEntryPoint.isSecondaryEntryPoint) {\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: 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 } else if (options.watch) {\n // update the watch version of the primary entry point `package.json` file.\n // this is needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/ng-packagr/ng-packagr/issues/2069\n const primary = ngPackageNode.data.primary;\n const packageJsonPath = path.join(primary.destinationPath, 'package.json');\n\n if (await exists(packageJsonPath)) {\n const packageJson = JSON.parse(await readFile(packageJsonPath, { encoding: 'utf8' }));\n packageJson.version = generateWatchVersion();\n await writeFile(path.join(primary.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n }\n }\n\n spinner.succeed(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n });\n\ntype AssetEntry = Exclude<AssetPattern, string>;\n\nasync function copyAssets(\n graph: BuildGraph,\n entryPointNode: EntryPointNode,\n ngPackageNode: PackageNode,\n): Promise<void> {\n const ngPackage = ngPackageNode.data;\n\n const globsForceIgnored: string[] = ['.gitkeep', '**/.DS_Store', '**/Thumbs.db', `${ngPackage.dest}/**`];\n const defaultAssets: AssetEntry[] = [\n { glob: 'LICENSE', input: '/', output: '/' },\n ...graph.filter(isEntryPoint).map(({ data }) => {\n const subpath = data.entryPoint.destinationFiles.directory || '/';\n\n return {\n glob: 'README.md',\n input: subpath,\n output: subpath,\n };\n }),\n ];\n\n const assets: AssetEntry[] = [];\n\n for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {\n let asset: AssetEntry;\n if (typeof assetPath === 'object') {\n asset = { ...assetPath };\n } else {\n const [isDir, isFile] = await stat(path.join(ngPackage.src, assetPath))\n .then(stats => [stats.isDirectory(), stats.isFile()])\n .catch(() => [false, false]);\n if (isDir) {\n asset = { glob: '**/*', input: assetPath, output: assetPath };\n } else if (isFile) {\n // filenames are their own glob\n asset = {\n glob: path.basename(assetPath),\n input: path.dirname(assetPath),\n output: path.dirname(assetPath),\n };\n } else {\n asset = { glob: assetPath, input: '/', output: '/' };\n }\n }\n\n asset.input = path.join(ngPackage.src, asset.input);\n asset.output = path.join(ngPackage.dest, asset.output);\n\n const isAncestorPath = (target: string, datum: string) => path.relative(datum, target).startsWith('..');\n if (isAncestorPath(asset.input, ngPackage.src)) {\n throw new Error('Cannot read assets from a location outside of the project root.');\n }\n if (isAncestorPath(asset.output, ngPackage.dest)) {\n throw new Error('Cannot write assets to a location outside of the output path.');\n }\n\n assets.push(asset);\n }\n\n for (const asset of assets) {\n const filePaths = await globFiles(asset.glob, {\n cwd: asset.input,\n ignore: [...(asset.ignore ?? []), ...globsForceIgnored],\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n follow: asset.followSymlinks,\n });\n for (const filePath of filePaths) {\n const fileSrcFullPath = path.join(asset.input, filePath);\n const fileDestFullPath = path.join(asset.output, filePath);\n const nodeUri = fileUrl(ensureUnixPath(fileSrcFullPath));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n entryPointNode.dependsOn(node);\n await copyFile(fileSrcFullPath, fileDestFullPath);\n }\n }\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 (isWatchMode) {\n // Needed because of Webpack's 5 `cachemanagedpaths`\n // https://github.com/angular/angular-cli/issues/20962\n packageJson.version = generateWatchVersion();\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 // 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 (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\n/**\n * Generates a new version for the package `package.json` when runing in watch mode.\n */\nfunction generateWatchVersion() {\n return `0.0.0-watch+${Date.now()}`;\n}\n"]}
|