ng-packagr 15.0.0 → 15.0.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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ npm install -D ng-packagr
20
20
  ## Usage Example
21
21
 
22
22
  Let's walk through a _getting started_ that'll build an Angular library from TypeScript sources and create a distribution-ready npm package:
23
- create a `ng-package.json` file and run `ng-packagr -p package.json`
23
+ create a `ng-package.json` file and run `ng-packagr -p ng-package.json`
24
24
  – Here we go:
25
25
 
26
26
  ```json
@@ -57,12 +57,12 @@ Create one `package.json` per npm package, run _ng-packagr_ for each!
57
57
 
58
58
  * :gift: Implements [Angular Package Format](https://angular.io/guide/angular-package-format)
59
59
  * :checkered_flag: Bundles your library in FESM2020
60
- * :school_satchel: npm package can be consumed by [Angular CLI](https://github.com/angular/angular-cli), [Webpack](https://github.com/webpack/webpack), or [SystemJS](https://github.com/systemjs/systemjs)
60
+ * :school_satchel: npm package can be consumed by [Angular CLI](https://github.com/angular/angular-cli), [Webpack](https://github.com/webpack/webpack), or ESM Bundlers
61
61
  * :dancer: Creates type definitions (`.d.ts`)
62
62
  * :mag_right: Creates [scoped and non-scoped packages](https://docs.npmjs.com/misc/scope) for publishing to npm registry
63
63
  * :surfer: Inlines Templates and Stylesheets
64
64
  * :sparkles: CSS Features
65
- * :camel: Runs [SCSS](http://sass-lang.com/guide) preprocessor, supporting the [relative `~` import syntax](https://github.com/webpack-contrib/sass-loader#imports) and custom include paths
65
+ * :camel: Runs [SCSS](http://sass-lang.com/guide) preprocessor, supporting custom include paths
66
66
  * :monkey: Adds vendor-specific prefixes w/ [autoprefixer](https://github.com/postcss/autoprefixer#autoprefixer-) and [browserslist](https://github.com/ai/browserslist#queries) — just tell your desired `.browserslistrc`
67
67
  * :tiger: Embed assets data w/ [postcss-url](https://github.com/postcss/postcss-url#inline)
68
68
 
@@ -1,5 +1,5 @@
1
- import { TransformResult } from 'rollup';
1
+ import { Plugin } from 'rollup';
2
2
  /**
3
3
  * Downlevels a .js file from `ES2015` to `ES2015`. Internally, uses `tsc`.
4
4
  */
5
- export declare function downlevelCodeWithTsc(code: string, filePath: string): TransformResult;
5
+ export declare function downlevelCodeWithTscPlugin(): Plugin;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.downlevelCodeWithTsc = void 0;
26
+ exports.downlevelCodeWithTscPlugin = void 0;
27
27
  const path = __importStar(require("path"));
28
28
  const typescript_1 = require("typescript");
29
29
  const log = __importStar(require("../utils/log"));
@@ -42,19 +42,24 @@ const COMPILER_OPTIONS = {
42
42
  /**
43
43
  * Downlevels a .js file from `ES2015` to `ES2015`. Internally, uses `tsc`.
44
44
  */
45
- function downlevelCodeWithTsc(code, filePath) {
46
- log.debug(`tsc ${filePath}`);
47
- const compilerOptions = {
48
- ...COMPILER_OPTIONS,
49
- mapRoot: path.dirname(filePath),
50
- };
51
- const { outputText, sourceMapText } = (0, typescript_1.transpileModule)(code, {
52
- compilerOptions,
53
- });
45
+ function downlevelCodeWithTscPlugin() {
54
46
  return {
55
- code: outputText,
56
- map: JSON.parse(sourceMapText),
47
+ name: 'downlevel-ts',
48
+ transform: function (code, id) {
49
+ log.debug(`tsc ${id}`);
50
+ const compilerOptions = {
51
+ ...COMPILER_OPTIONS,
52
+ mapRoot: path.dirname(id),
53
+ };
54
+ const { outputText, sourceMapText } = (0, typescript_1.transpileModule)(code, {
55
+ compilerOptions,
56
+ });
57
+ return {
58
+ code: outputText,
59
+ map: JSON.parse(sourceMapText),
60
+ };
61
+ },
57
62
  };
58
63
  }
59
- exports.downlevelCodeWithTsc = downlevelCodeWithTsc;
64
+ exports.downlevelCodeWithTscPlugin = downlevelCodeWithTscPlugin;
60
65
  //# sourceMappingURL=downlevel-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"downlevel-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/downlevel-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,2CAA8G;AAE9G,kDAAoC;AAEpC;;GAEG;AACH,MAAM,gBAAgB,GAAoB;IACxC,MAAM,EAAE,yBAAY,CAAC,MAAM;IAC3B,MAAM,EAAE,uBAAU,CAAC,MAAM;IACzB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,iCAAoB,CAAC,OAAO;CAC/C,CAAC;AAEF;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAY,EAAE,QAAgB;IACjE,GAAG,CAAC,KAAK,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC;IAC7B,MAAM,eAAe,GAAoB;QACvC,GAAG,gBAAgB;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;KAChC,CAAC;IAEF,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,IAAA,4BAAe,EAAC,IAAI,EAAE;QAC1D,eAAe;KAChB,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;KAC/B,CAAC;AACJ,CAAC;AAfD,oDAeC","sourcesContent":["import * as path from 'path';\nimport { TransformResult } from 'rollup';\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget, transpileModule } from 'typescript';\n\nimport * as log from '../utils/log';\n\n/**\n * Base `tsc` `CompilerOptions` shared among various downleveling methods.\n */\nconst COMPILER_OPTIONS: CompilerOptions = {\n target: ScriptTarget.ES2015,\n module: ModuleKind.ESNext,\n allowJs: true,\n sourceMap: true,\n importHelpers: true,\n downlevelIteration: true,\n moduleResolution: ModuleResolutionKind.Classic,\n};\n\n/**\n * Downlevels a .js file from `ES2015` to `ES2015`. Internally, uses `tsc`.\n */\nexport function downlevelCodeWithTsc(code: string, filePath: string): TransformResult {\n log.debug(`tsc ${filePath}`);\n const compilerOptions: CompilerOptions = {\n ...COMPILER_OPTIONS,\n mapRoot: path.dirname(filePath),\n };\n\n const { outputText, sourceMapText } = transpileModule(code, {\n compilerOptions,\n });\n\n return {\n code: outputText,\n map: JSON.parse(sourceMapText),\n };\n}\n"]}
1
+ {"version":3,"file":"downlevel-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/downlevel-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,2CAA8G;AAE9G,kDAAoC;AAEpC;;GAEG;AACH,MAAM,gBAAgB,GAAoB;IACxC,MAAM,EAAE,yBAAY,CAAC,MAAM;IAC3B,MAAM,EAAE,uBAAU,CAAC,MAAM;IACzB,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,IAAI;IACnB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,iCAAoB,CAAC,OAAO;CAC/C,CAAC;AAEF;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,SAAS,EAAE,UAAU,IAAI,EAAE,EAAE;YAC3B,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACvB,MAAM,eAAe,GAAoB;gBACvC,GAAG,gBAAgB;gBACnB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;aAC1B,CAAC;YAEF,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,IAAA,4BAAe,EAAC,IAAI,EAAE;gBAC1D,eAAe;aAChB,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;aAC/B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AApBD,gEAoBC","sourcesContent":["import * as path from 'path';\nimport { Plugin } from 'rollup';\nimport { CompilerOptions, ModuleKind, ModuleResolutionKind, ScriptTarget, transpileModule } from 'typescript';\n\nimport * as log from '../utils/log';\n\n/**\n * Base `tsc` `CompilerOptions` shared among various downleveling methods.\n */\nconst COMPILER_OPTIONS: CompilerOptions = {\n target: ScriptTarget.ES2015,\n module: ModuleKind.ESNext,\n allowJs: true,\n sourceMap: true,\n importHelpers: true,\n downlevelIteration: true,\n moduleResolution: ModuleResolutionKind.Classic,\n};\n\n/**\n * Downlevels a .js file from `ES2015` to `ES2015`. Internally, uses `tsc`.\n */\nexport function downlevelCodeWithTscPlugin(): Plugin {\n return {\n name: 'downlevel-ts',\n transform: function (code, id) {\n log.debug(`tsc ${id}`);\n const compilerOptions: CompilerOptions = {\n ...COMPILER_OPTIONS,\n mapRoot: path.dirname(id),\n };\n\n const { outputText, sourceMapText } = transpileModule(code, {\n compilerOptions,\n });\n\n return {\n code: outputText,\n map: JSON.parse(sourceMapText),\n };\n },\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { Plugin } from 'rollup';
2
+ import { OutputFileCache } from '../ng-package/nodes';
3
+ /**
4
+ * Loads a file and it's map.
5
+ */
6
+ export declare function fileLoaderPlugin(fileCache: OutputFileCache): Plugin;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.fileLoaderPlugin = void 0;
27
+ const log = __importStar(require("../utils/log"));
28
+ const path_1 = require("../utils/path");
29
+ /**
30
+ * Loads a file and it's map.
31
+ */
32
+ function fileLoaderPlugin(fileCache) {
33
+ return {
34
+ name: 'file-loader',
35
+ load: function (id) {
36
+ log.debug(`file-loader ${id}`);
37
+ const data = fileCache.get((0, path_1.ensureUnixPath)(id));
38
+ if (!data) {
39
+ throw new Error(`Could not load '${id}' from memory.`);
40
+ }
41
+ return {
42
+ code: data.content,
43
+ map: data.map,
44
+ };
45
+ },
46
+ };
47
+ }
48
+ exports.fileLoaderPlugin = fileLoaderPlugin;
49
+ //# sourceMappingURL=file-loader-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-loader-plugin.js","sourceRoot":"","sources":["../../../src/lib/flatten/file-loader-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,kDAAoC;AACpC,wCAA+C;AAE/C;;GAEG;AACH,SAAgB,gBAAgB,CAAC,SAA0B;IACzD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,UAAU,EAAE;YAChB,GAAG,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;YAE/B,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAA,qBAAc,EAAC,EAAE,CAAC,CAAC,CAAC;YAC/C,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;aACxD;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,OAAO;gBAClB,GAAG,EAAE,IAAI,CAAC,GAAG;aACd,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAjBD,4CAiBC","sourcesContent":["import { Plugin } from 'rollup';\nimport { OutputFileCache } from '../ng-package/nodes';\n\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\n\n/**\n * Loads a file and it's map.\n */\nexport function fileLoaderPlugin(fileCache: OutputFileCache): Plugin {\n return {\n name: 'file-loader',\n load: function (id) {\n log.debug(`file-loader ${id}`);\n\n const data = fileCache.get(ensureUnixPath(id));\n if (!data) {\n throw new Error(`Could not load '${id}' from memory.`);\n }\n\n return {\n code: data.content,\n map: data.map,\n };\n },\n };\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  import * as rollup from 'rollup';
2
- import { TransformHook } from 'rollup';
3
2
  import { OutputFileCache } from '../ng-package/nodes';
4
3
  /**
5
4
  * Options used in `ng-packagr` for writing flat bundle files.
@@ -11,7 +10,7 @@ export interface RollupOptions {
11
10
  entry: string;
12
11
  dest: string;
13
12
  sourceRoot: string;
14
- transform?: TransformHook;
13
+ downlevel?: boolean;
15
14
  cache?: rollup.RollupCache;
16
15
  cacheDirectory?: string | false;
17
16
  fileCache: OutputFileCache;
@@ -31,10 +31,10 @@ const plugin_json_1 = __importDefault(require("@rollup/plugin-json"));
31
31
  const plugin_node_resolve_1 = __importDefault(require("@rollup/plugin-node-resolve"));
32
32
  const path = __importStar(require("path"));
33
33
  const rollup = __importStar(require("rollup"));
34
- const rollup_plugin_sourcemaps_1 = __importDefault(require("rollup-plugin-sourcemaps"));
35
34
  const cache_1 = require("../utils/cache");
36
35
  const log = __importStar(require("../utils/log"));
37
- const path_1 = require("../utils/path");
36
+ const downlevel_plugin_1 = require("./downlevel-plugin");
37
+ const file_loader_plugin_1 = require("./file-loader-plugin");
38
38
  /** Runs rollup over the given entry file, writes a bundle file. */
39
39
  async function rollupBundleFile(opts) {
40
40
  var _a;
@@ -49,14 +49,9 @@ async function rollupBundleFile(opts) {
49
49
  input: opts.entry,
50
50
  plugins: [
51
51
  (0, plugin_node_resolve_1.default)(),
52
- (0, rollup_plugin_sourcemaps_1.default)({
53
- readFile: (path, callback) => {
54
- const fileData = opts.fileCache.get((0, path_1.ensureUnixPath)(path));
55
- callback(fileData ? null : new Error(`Could not load '${path}' from memory.`), fileData === null || fileData === void 0 ? void 0 : fileData.content);
56
- },
57
- }),
58
52
  (0, plugin_json_1.default)(),
59
- opts.transform ? { transform: opts.transform, name: 'downlevel-ts' } : undefined,
53
+ (0, file_loader_plugin_1.fileLoaderPlugin)(opts.fileCache),
54
+ opts.downlevel ? (0, downlevel_plugin_1.downlevelCodeWithTscPlugin)() : undefined,
60
55
  ],
61
56
  onwarn: warning => {
62
57
  switch (warning.code) {
@@ -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,CAA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AE,IAAI;QACZ,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACnF;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEvC,gFAAgF;IAChF,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IAErB,OAAO;QACL,IAAI,EAAE,IAAI,GAAG,mBAAmB,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;QAC1E,GAAG;QACH,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;AACJ,CAAC;AAlED,4CAkEC;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 'CIRCULAR_DEPENDENCY':\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 // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\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"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sEAA6C;AAC7C,sFAAsD;AACtD,2CAA6B;AAC7B,+CAAiC;AAEjC,0CAAgE;AAChE,kDAAoC;AACpC,yDAAgE;AAChE,6DAAwD;AAmBxD,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,qBAAU,GAAE;YACZ,IAAA,qCAAgB,EAAC,IAAI,CAAC,SAAS,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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 { OutputFileCache } from '../ng-package/nodes';\nimport { readCacheEntry, saveCacheEntry } from '../utils/cache';\nimport * as log from '../utils/log';\nimport { downlevelCodeWithTscPlugin } from './downlevel-plugin';\nimport { fileLoaderPlugin } from './file-loader-plugin';\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 downlevel?: boolean;\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 rollupJson(),\n fileLoaderPlugin(opts.fileCache),\n opts.downlevel ? downlevelCodeWithTscPlugin() : undefined,\n ],\n onwarn: warning => {\n switch (warning.code) {\n case 'CIRCULAR_DEPENDENCY':\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 // Close the bundle to let plugins clean up their external processes or services\n await bundle.close();\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"]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeBundlesTransform = void 0;
7
7
  const ora_1 = __importDefault(require("ora"));
8
8
  const path_1 = require("path");
9
- const downlevel_plugin_1 = require("../../flatten/downlevel-plugin");
10
9
  const rollup_1 = require("../../flatten/rollup");
11
10
  const transform_1 = require("../../graph/transform");
12
11
  const cache_1 = require("../../utils/cache");
@@ -83,7 +82,7 @@ const writeBundlesTransform = (options) => (0, transform_1.transformFromPromise)
83
82
  entry: esm2020,
84
83
  moduleName: ngEntryPoint.moduleId,
85
84
  dest: fesm2015,
86
- transform: downlevel_plugin_1.downlevelCodeWithTsc,
85
+ downlevel: true,
87
86
  cache: cache.rollupFESM2015Cache,
88
87
  cacheDirectory,
89
88
  fileCache: cache.outputCache,
@@ -1 +1 @@
1
- {"version":3,"file":"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AS,CAAC,QAAQ,GAAG;YACnB,IAAI;YACJ,GAAG;SACJ,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,KAAK,CAAC,mBAAmB,GAAG,eAAe,CAAC;SAC7C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;KACb;IAED,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;KACtE;AACH,CAAC,CAAC,CAAC;AAnHQ,QAAA,qBAAqB,yBAmH7B","sourcesContent":["import ora from 'ora';\nimport { dirname } from 'path';\nimport { SourceMap } from 'rollup';\nimport { downlevelCodeWithTsc } from '../../flatten/downlevel-plugin';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { mkdir, writeFile } from '../../utils/fs';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2020: {\n code: string;\n map: SourceMap;\n };\n fesm2015: {\n code: string;\n map: SourceMap;\n };\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2020, fesm2015, esm2020 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const key = await generateKey(ngEntryPoint.moduleId, esm2020, 'fesm-bundles', tsConfig.options.compilationMode);\n const hash = await generateKey(...[...cache.outputCache.values()].map(({ version }) => version));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, key);\n\n if (cacheResult?.hash === hash) {\n try {\n spinner.start('Writing FESM bundles');\n await Promise.all([\n mkdir(dirname(fesm2020), { recursive: true }),\n mkdir(dirname(fesm2015), { recursive: true }),\n ]);\n\n await Promise.all([\n writeFile(fesm2020, cacheResult.fesm2020.code),\n writeFile(`${fesm2020}.map`, JSON.stringify(cacheResult.fesm2020.map)),\n writeFile(fesm2015, cacheResult.fesm2015.code),\n writeFile(`${fesm2015}.map`, JSON.stringify(cacheResult.fesm2015.map)),\n ]);\n\n spinner.succeed('Writing FESM bundles');\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n return;\n }\n }\n\n const fesmCache: Partial<BundlesCache> = {\n hash,\n };\n\n try {\n spinner.start('Generating FESM2020');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2020,\n cache: cache.rollupFESM2020Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2020, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2020 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2020Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n try {\n spinner.start('Generating FESM2015');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2015,\n transform: downlevelCodeWithTsc,\n cache: cache.rollupFESM2015Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2015, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2015 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2015Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, key, JSON.stringify(fesmCache));\n }\n });\n"]}
1
+ {"version":3,"file":"write-bundles.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-bundles.transform.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,+BAA+B;AAE/B,iDAAwD;AACxD,qDAA6D;AAC7D,6CAAgF;AAChF,uCAAkD;AAClD,oCAAkE;AAe3D,MAAM,qBAAqB,GAAG,CAAC,OAAyB,EAAE,EAAE,CACjE,IAAA,gCAAoB,EAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjC,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,IAAA,8BAAsB,GAAE,CAAC,CAAC;IACxE,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IACjF,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAC/B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC;IAEzD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAW,EAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAChH,MAAM,IAAI,GAAG,MAAM,IAAA,mBAAW,EAAC,GAAG,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,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KAAK,CAAC,WAAW;YAC5B,QAAQ,EAAE,MAAM,IAAA,mBAAW,EAAC,OAAO,EAAE,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;SACxG,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,GAAG;YACnB,IAAI;YACJ,GAAG;SACJ,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,KAAK,EAAE;YACjB,KAAK,CAAC,mBAAmB,GAAG,eAAe,CAAC;SAC7C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,KAAK,CAAC;KACb;IAED,IAAI,cAAc,EAAE;QAClB,MAAM,IAAA,sBAAc,EAAC,cAAc,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;KACtE;AACH,CAAC,CAAC,CAAC;AAnHQ,QAAA,qBAAqB,yBAmH7B","sourcesContent":["import ora from 'ora';\nimport { dirname } from 'path';\nimport { SourceMap } from 'rollup';\nimport { rollupBundleFile } from '../../flatten/rollup';\nimport { transformFromPromise } from '../../graph/transform';\nimport { generateKey, readCacheEntry, saveCacheEntry } from '../../utils/cache';\nimport { mkdir, writeFile } from '../../utils/fs';\nimport { EntryPointNode, isEntryPointInProgress } from '../nodes';\nimport { NgPackagrOptions } from '../options.di';\n\ninterface BundlesCache {\n hash: string;\n fesm2020: {\n code: string;\n map: SourceMap;\n };\n fesm2015: {\n code: string;\n map: SourceMap;\n };\n}\n\nexport const writeBundlesTransform = (options: NgPackagrOptions) =>\n transformFromPromise(async graph => {\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const { destinationFiles, entryPoint: ngEntryPoint, tsConfig } = entryPoint.data;\n const cache = entryPoint.cache;\n const { fesm2020, fesm2015, esm2020 } = destinationFiles;\n\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n\n const key = await generateKey(ngEntryPoint.moduleId, esm2020, 'fesm-bundles', tsConfig.options.compilationMode);\n const hash = await generateKey(...[...cache.outputCache.values()].map(({ version }) => version));\n const cacheDirectory = options.cacheEnabled && options.cacheDirectory;\n if (cacheDirectory) {\n const cacheResult: BundlesCache = await readCacheEntry(options.cacheDirectory, key);\n\n if (cacheResult?.hash === hash) {\n try {\n spinner.start('Writing FESM bundles');\n await Promise.all([\n mkdir(dirname(fesm2020), { recursive: true }),\n mkdir(dirname(fesm2015), { recursive: true }),\n ]);\n\n await Promise.all([\n writeFile(fesm2020, cacheResult.fesm2020.code),\n writeFile(`${fesm2020}.map`, JSON.stringify(cacheResult.fesm2020.map)),\n writeFile(fesm2015, cacheResult.fesm2015.code),\n writeFile(`${fesm2015}.map`, JSON.stringify(cacheResult.fesm2015.map)),\n ]);\n\n spinner.succeed('Writing FESM bundles');\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n return;\n }\n }\n\n const fesmCache: Partial<BundlesCache> = {\n hash,\n };\n\n try {\n spinner.start('Generating FESM2020');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2020,\n cache: cache.rollupFESM2020Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2020, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2020 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2020Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n try {\n spinner.start('Generating FESM2015');\n const {\n cache: rollupFESMCache,\n code,\n map,\n } = await rollupBundleFile({\n sourceRoot: tsConfig.options.sourceRoot,\n entry: esm2020,\n moduleName: ngEntryPoint.moduleId,\n dest: fesm2015,\n downlevel: true,\n cache: cache.rollupFESM2015Cache,\n cacheDirectory,\n fileCache: cache.outputCache,\n cacheKey: await generateKey(esm2020, ngEntryPoint.moduleId, fesm2015, tsConfig.options.compilationMode),\n });\n\n fesmCache.fesm2015 = {\n code,\n map,\n };\n\n spinner.succeed();\n\n if (options.watch) {\n cache.rollupFESM2015Cache = rollupFESMCache;\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n\n if (cacheDirectory) {\n await saveCacheEntry(cacheDirectory, key, JSON.stringify(fesmCache));\n }\n });\n"]}
@@ -112,7 +112,7 @@ async function copyAssets(graph, entryPointNode, ngPackageNode) {
112
112
  for (const assetPath of [...ngPackage.assets, ...defaultAssets]) {
113
113
  let asset;
114
114
  if (typeof assetPath === 'object') {
115
- asset = assetPath;
115
+ asset = { ...assetPath };
116
116
  }
117
117
  else {
118
118
  const [isDir, isFile] = await (0, fs_1.stat)(path.join(ngPackage.src, assetPath))
@@ -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,CA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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 { glob: '**/README.md', input: '/', output: '/', ignore: ['**/node_modules/**'] },\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,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,KAA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AAM,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 { glob: '**/README.md', input: '/', output: '/', ignore: ['**/node_modules/**'] },\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"]}
@@ -27,6 +27,7 @@ export declare function ngUrl(path: string): string;
27
27
  export declare type OutputFileCache = Map<string, {
28
28
  version: string;
29
29
  content: string;
30
+ map?: any;
30
31
  }>;
31
32
  export declare class EntryPointNode extends Node {
32
33
  readonly url: string;
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA4D;AAG5D,6CAAmD;AAGtC,QAAA,eAAe,GAAG,wBAAwB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,4BAA4B,CAAC;AAIhE,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,kCAAkC;AACrB,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,SAAgB,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AAG,2BAAmB,CAAC;QAUlC,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,mBAAmB;YACnB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CAqBF;AAvCD,wCAuCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;QAGhC,UAAK,GAAG;YACN,SAAS,EAAE,EAAe;YAC1B,gBAAgB,EAAE,IAAI,sBAAS,EAAE;YACjC,mBAAmB,EAAE,IAAI,gCAAmB,EAAE;YAC9C,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7E,CAAC;IACJ,CAAC;CAAA;AAVD,kCAUC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';\nimport { RollupCache } from 'rollup';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isDirty, isInProgress } from '../graph/select';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgccProcessingCache } from './ngcc-cache';\nimport { NgPackage } from './package';\n\nexport const TYPE_NG_PACKAGE = 'application/ng-package';\nexport const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\nexport type GlobCache = Record<string, boolean | 'DIR' | 'FILE' | string[]>;\n\n/** A node that can be read through the `fs` api. */\nexport const URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nexport const URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isInProgress);\n}\n\nexport function isEntryPointDirty(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isDirty);\n}\n\nexport function isFileUrl(value: string): boolean {\n return value.startsWith(URL_PROTOCOL_FILE);\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string {\n if (url.startsWith(URL_PROTOCOL_FILE)) {\n return url.substring(URL_PROTOCOL_FILE.length);\n }\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version: string; content: string }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n ngccProcessingCache: NgccProcessingCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n ngccProcessingCache,\n analysesSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n };\n }\n\n cache: {\n outputCache: OutputFileCache;\n oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;\n sourcesFileCache: FileCache;\n ngccProcessingCache: NgccProcessingCache;\n analysesSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n rollupFESM2020Cache?: RollupCache;\n rollupFESM2015Cache?: RollupCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n };\n\n data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n data: NgPackage;\n\n cache = {\n globCache: {} as GlobCache,\n sourcesFileCache: new FileCache(),\n ngccProcessingCache: new NgccProcessingCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
1
+ {"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/lib/ng-package/nodes.ts"],"names":[],"mappings":";;;;;;AAEA,4DAA4B;AAC5B,0DAAsD;AAEtD,wCAAqC;AACrC,4CAA4D;AAG5D,6CAAmD;AAGtC,QAAA,eAAe,GAAG,wBAAwB,CAAC;AAC3C,QAAA,mBAAmB,GAAG,4BAA4B,CAAC;AAIhE,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,kCAAkC;AACrB,QAAA,eAAe,GAAG,OAAO,CAAC;AAEvC,SAAgB,YAAY,CAAC,IAAU;IACrC,OAAO,IAAI,CAAC,IAAI,KAAK,2BAAmB,CAAC;AAC3C,CAAC;AAFD,oCAEC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,uBAAe,CAAC;AACvC,CAAC;AAFD,8BAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAA,WAAE,EAAC,YAAY,CAAC,CAAC;AAC1B,CAAC;AAFD,oCAEC;AAED,SAAgB,sBAAsB;IACpC,OAAO,IAAA,WAAE,EAAC,YAAY,CAAC,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC;AAC5C,CAAC;AAFD,wDAEC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,IAAA,WAAE,EAAC,YAAY,CAAC,CAAC,GAAG,CAAC,gBAAO,CAAC,CAAC;AACvC,CAAC;AAFD,8CAEC;AAED,SAAgB,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,UAAU,CAAC,yBAAiB,CAAC,CAAC;AAC7C,CAAC;AAFD,8BAEC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,OAAO,GAAG,yBAAiB,GAAG,IAAI,EAAE,CAAC;AACvC,CAAC;AAFD,0BAEC;AAED,SAAgB,WAAW,CAAC,GAAW;IACrC,IAAI,GAAG,CAAC,UAAU,CAAC,yBAAiB,CAAC,EAAE;QACrC,OAAO,GAAG,CAAC,SAAS,CAAC,yBAAiB,CAAC,MAAM,CAAC,CAAC;KAChD;AACH,CAAC;AAJD,kCAIC;AAED,SAAgB,KAAK,CAAC,IAAY;IAChC,OAAO,GAAG,uBAAe,GAAG,IAAI,EAAE,CAAC;AACrC,CAAC;AAFD,sBAEC;AAID,MAAa,cAAe,SAAQ,WAAI;IAGtC,YACkB,GAAW,EAC3B,gBAA2B,EAC3B,mBAAwC,EACxC,qBAA+C;QAE/C,KAAK,CAAC,GAAG,CAAC,CAAC;QALK,QAAG,GAAH,GAAG,CAAQ;QAHpB,SAAI,GAAG,2BAAmB,CAAC;QAUlC,IAAI,CAAC,KAAK,GAAG;YACX,gBAAgB;YAChB,mBAAmB;YACnB,wBAAwB,EAAE,IAAI,sBAAS,EAAE;YACzC,qBAAqB;YACrB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CAqBF;AAvCD,wCAuCC;AAED,MAAa,WAAY,SAAQ,WAAI;IAArC;;QACW,SAAI,GAAG,uBAAe,CAAC;QAGhC,UAAK,GAAG;YACN,SAAS,EAAE,EAAe;YAC1B,gBAAgB,EAAE,IAAI,sBAAS,EAAE;YACjC,mBAAmB,EAAE,IAAI,gCAAmB,EAAE;YAC9C,qBAAqB,EAAE,oBAAE,CAAC,2BAA2B,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SAC7E,CAAC;IACJ,CAAC;CAAA;AAVD,kCAUC","sourcesContent":["import type { NgtscProgram, ParsedConfiguration, Program } from '@angular/compiler-cli';\nimport { RollupCache } from 'rollup';\nimport ts from 'typescript';\nimport { FileCache } from '../file-system/file-cache';\nimport { ComplexPredicate } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { by, isDirty, isInProgress } from '../graph/select';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { DestinationFiles, NgEntryPoint } from './entry-point/entry-point';\nimport { NgccProcessingCache } from './ngcc-cache';\nimport { NgPackage } from './package';\n\nexport const TYPE_NG_PACKAGE = 'application/ng-package';\nexport const TYPE_NG_ENTRY_POINT = 'application/ng-entry-point';\n\nexport type GlobCache = Record<string, boolean | 'DIR' | 'FILE' | string[]>;\n\n/** A node that can be read through the `fs` api. */\nexport const URL_PROTOCOL_FILE = 'file://';\n\n/** A node specific to angular. */\nexport const URL_PROTOCOL_NG = 'ng://';\n\nexport function isEntryPoint(node: Node): node is EntryPointNode {\n return node.type === TYPE_NG_ENTRY_POINT;\n}\n\nexport function isPackage(node: Node): node is PackageNode {\n return node.type === TYPE_NG_PACKAGE;\n}\n\nexport function byEntryPoint(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint);\n}\n\nexport function isEntryPointInProgress(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isInProgress);\n}\n\nexport function isEntryPointDirty(): ComplexPredicate<EntryPointNode> {\n return by(isEntryPoint).and(isDirty);\n}\n\nexport function isFileUrl(value: string): boolean {\n return value.startsWith(URL_PROTOCOL_FILE);\n}\n\nexport function fileUrl(path: string): string {\n return `${URL_PROTOCOL_FILE}${path}`;\n}\n\nexport function fileUrlPath(url: string): string {\n if (url.startsWith(URL_PROTOCOL_FILE)) {\n return url.substring(URL_PROTOCOL_FILE.length);\n }\n}\n\nexport function ngUrl(path: string): string {\n return `${URL_PROTOCOL_NG}${path}`;\n}\n\nexport type OutputFileCache = Map<string, { version: string; content: string; map?: any }>;\n\nexport class EntryPointNode extends Node {\n readonly type = TYPE_NG_ENTRY_POINT;\n\n constructor(\n public readonly url: string,\n sourcesFileCache: FileCache,\n ngccProcessingCache: NgccProcessingCache,\n moduleResolutionCache: ts.ModuleResolutionCache,\n ) {\n super(url);\n\n this.cache = {\n sourcesFileCache,\n ngccProcessingCache,\n analysesSourcesFileCache: new FileCache(),\n moduleResolutionCache,\n outputCache: new Map(),\n };\n }\n\n cache: {\n outputCache: OutputFileCache;\n oldPrograms?: Record<ts.ScriptTarget | 'analysis', Program | ts.Program>;\n sourcesFileCache: FileCache;\n ngccProcessingCache: NgccProcessingCache;\n analysesSourcesFileCache: FileCache;\n moduleResolutionCache: ts.ModuleResolutionCache;\n rollupFESM2020Cache?: RollupCache;\n rollupFESM2015Cache?: RollupCache;\n stylesheetProcessor?: StylesheetProcessor;\n oldNgtscProgram?: NgtscProgram;\n oldBuilder?: ts.EmitAndSemanticDiagnosticsBuilderProgram;\n };\n\n data: {\n destinationFiles: DestinationFiles;\n entryPoint: NgEntryPoint;\n tsConfig?: ParsedConfiguration;\n };\n}\n\nexport class PackageNode extends Node {\n readonly type = TYPE_NG_PACKAGE;\n data: NgPackage;\n\n cache = {\n globCache: {} as GlobCache,\n sourcesFileCache: new FileCache(),\n ngccProcessingCache: new NgccProcessingCache(),\n moduleResolutionCache: ts.createModuleResolutionCache(process.cwd(), s => s),\n };\n}\n"]}
@@ -27,6 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.augmentProgramWithVersioning = exports.cacheCompilerHost = void 0;
30
+ const convert_source_map_1 = __importDefault(require("convert-source-map"));
30
31
  const crypto_1 = require("crypto");
31
32
  const path = __importStar(require("path"));
32
33
  const typescript_1 = __importDefault(require("typescript"));
@@ -94,9 +95,17 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
94
95
  else {
95
96
  fileName = fileName.replace(/\.js(\.map)?$/, '.mjs$1');
96
97
  const outputCache = entryPoint.cache.outputCache;
98
+ // Extract inline sourcemap which will later be used by rolluo.
99
+ const version = (0, crypto_1.createHash)('sha256').update(data).digest('hex');
100
+ let map = undefined;
101
+ if (fileName.endsWith('.mjs')) {
102
+ const cachedData = outputCache.get(fileName);
103
+ map = (cachedData === null || cachedData === void 0 ? void 0 : cachedData.version) === version ? cachedData.map : convert_source_map_1.default.fromComment(data).toJSON();
104
+ }
97
105
  outputCache.set(fileName, {
98
106
  content: data,
99
- version: (0, crypto_1.createHash)('sha256').update(data).digest('hex'),
107
+ version,
108
+ map,
100
109
  });
101
110
  }
102
111
  compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);
@@ -1 +1 @@
1
- {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,mCAAoC;AACpC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,CAAC;YACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/B,UA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CAAC,QAAQ,CAAC,CAAC;oBAC1C,MAAM,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBAC3D,eAAe,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;iBAC/C;gBAED,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;gBAEpB,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;aACnC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AArLD,8CAqLC;AAED,SAAgB,4BAA4B,CAAC,OAAmB;IAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;IAClD,OAAO,CAAC,cAAc,GAAG,UAAU,GAAG,UAAU;QAC9C,MAAM,KAAK,GAAsD,kBAAkB,CAAC,GAAG,UAAU,CAAC,CAAC;QAEnG,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC9B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACrE;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\n\nimport { createHash } from 'crypto';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;\n const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;\n const flatModuleFileDtsPath = ensureUnixPath(path.join(destinationPath, flatModuleFileDtsFilename));\n const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.endsWith('.d.ts')) {\n if (fileName === flatModuleFileDtsPath) {\n if (hasIndexEntryFile) {\n // In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.\n // Because it will cause a conflict.\n return;\n } else {\n // Rename file to index.d.ts so that TypeScript can resolve types without\n // them needing to be referenced in the package.json manifest.\n fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');\n }\n }\n\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n const outputCache = entryPoint.cache.outputCache;\n\n outputCache.set(fileName, {\n content: data,\n version: createHash('sha256').update(data).digest('hex'),\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: compilerHost.readFile.call(this, fileName),\n });\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n if (context.resourceFile || context.type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const key = createHash('sha1').update(data).digest('hex');\n const fileName = `${context.containingFile}-${key}.${inlineStyleLanguage}`;\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: data,\n });\n\n const virtualFileNode = getNode(fileName);\n const containingFileNode = getNode(context.containingFile);\n virtualFileNode.dependsOn(containingFileNode);\n }\n\n cache.exists = true;\n\n return { content: cache.content };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
1
+ {"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAkD;AAElD,mCAAoC;AACpC,2CAA6B;AAC7B,4DAA4B;AAI5B,wCAAqC;AACrC,+CAA8D;AAE9D,wCAA+C;AAE/C,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAgC,EAChC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA4D,EAC5D,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB;IAE/D,MAAM,YAAY,GAAG,oBAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;IAEvE,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,IAAA,eAAO,EAAC,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAA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I,KAAK,EAAE;YACxB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE;gBAC9B,IAAI,CAAC,OAAO,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACrE;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAbD,oEAaC","sourcesContent":["import type { CompilerHost, CompilerOptions } from '@angular/compiler-cli';\nimport convertSourceMap from 'convert-source-map';\n\nimport { createHash } from 'crypto';\nimport * as path from 'path';\nimport ts from 'typescript';\nimport { NgPackageConfig } from '../../ng-package.schema';\nimport { FileCache } from '../file-system/file-cache';\nimport { BuildGraph } from '../graph/build-graph';\nimport { Node } from '../graph/node';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { ensureUnixPath } from '../utils/path';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n inlineStyleLanguage?: NgPackageConfig['inlineStyleLanguage'],\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n): CompilerHost {\n const compilerHost = ts.createIncrementalCompilerHost(compilerOptions);\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n const { flatModuleFile, destinationPath, entryFile } = entryPoint.data.entryPoint;\n const flatModuleFileDtsFilename = `${flatModuleFile}.d.ts`;\n const flatModuleFileDtsPath = ensureUnixPath(path.join(destinationPath, flatModuleFileDtsFilename));\n const hasIndexEntryFile = path.basename(entryFile.toLowerCase()) === 'index.ts';\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.endsWith('.d.ts')) {\n if (fileName === flatModuleFileDtsPath) {\n if (hasIndexEntryFile) {\n // In case the entry file is index.ts, we should not emit the `d.ts` which are a re-export of the `index.ts`.\n // Because it will cause a conflict.\n return;\n } else {\n // Rename file to index.d.ts so that TypeScript can resolve types without\n // them needing to be referenced in the package.json manifest.\n fileName = fileName.replace(flatModuleFileDtsFilename, 'index.d.ts');\n }\n }\n\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n } else {\n fileName = fileName.replace(/\\.js(\\.map)?$/, '.mjs$1');\n const outputCache = entryPoint.cache.outputCache;\n\n // Extract inline sourcemap which will later be used by rolluo.\n const version = createHash('sha256').update(data).digest('hex');\n let map = undefined;\n if (fileName.endsWith('.mjs')) {\n const cachedData = outputCache.get(fileName);\n map = cachedData?.version === version ? cachedData.map : convertSourceMap.fromComment(data).toJSON();\n }\n\n outputCache.set(fileName, {\n content: data,\n version,\n map,\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n\n return cache.content;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: async (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (!compilerHost.fileExists(fileName)) {\n throw new Error(`Cannot read file ${fileName}.`);\n }\n\n if (/(?:html?|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: compilerHost.readFile.call(this, fileName),\n });\n }\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n transformResource: async (data, context) => {\n if (context.resourceFile || context.type !== 'style') {\n return null;\n }\n\n if (inlineStyleLanguage) {\n const key = createHash('sha1').update(data).digest('hex');\n const fileName = `${context.containingFile}-${key}.${inlineStyleLanguage}`;\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = await stylesheetProcessor.process({\n filePath: fileName,\n content: data,\n });\n\n const virtualFileNode = getNode(fileName);\n const containingFileNode = getNode(context.containingFile);\n virtualFileNode.dependsOn(containingFileNode);\n }\n\n cache.exists = true;\n\n return { content: cache.content };\n }\n\n return null;\n },\n };\n}\n\nexport function augmentProgramWithVersioning(program: ts.Program): void {\n const baseGetSourceFiles = program.getSourceFiles;\n program.getSourceFiles = function (...parameters) {\n const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);\n\n for (const file of files) {\n if (file.version === undefined) {\n file.version = createHash('sha256').update(file.text).digest('hex');\n }\n }\n\n return files;\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "15.0.0",
3
+ "version": "15.0.2",
4
4
  "description": "Compile and package Angular libraries in Angular Package Format (APF)",
5
5
  "keywords": [
6
6
  "apf",
@@ -41,8 +41,9 @@
41
41
  "cacache": "^17.0.0",
42
42
  "chokidar": "^3.5.3",
43
43
  "commander": "^9.4.0",
44
+ "convert-source-map": "^2.0.0",
44
45
  "dependency-graph": "^0.11.0",
45
- "esbuild-wasm": "^0.15.9",
46
+ "esbuild-wasm": "^0.16.0",
46
47
  "find-cache-dir": "^3.3.2",
47
48
  "glob": "^8.0.3",
48
49
  "injection-js": "^2.4.0",
@@ -52,12 +53,11 @@
52
53
  "postcss": "^8.4.16",
53
54
  "postcss-url": "^10.1.3",
54
55
  "rollup": "^3.0.0",
55
- "rollup-plugin-sourcemaps": "^0.6.3",
56
56
  "rxjs": "^7.5.6",
57
57
  "sass": "^1.55.0"
58
58
  },
59
59
  "optionalDependencies": {
60
- "esbuild": "^0.15.9"
60
+ "esbuild": "^0.16.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@angular/compiler-cli": "^15.0.0-next",