ng-packagr 10.0.2 → 10.1.1
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/CHANGELOG.md +41 -0
- package/cli/main.js +1 -2
- package/cli/main.js.map +1 -1
- package/lib/flatten/external-module-id-strategy.js +1 -1
- package/lib/flatten/external-module-id-strategy.js.map +1 -1
- package/lib/flatten/rollup.d.ts +2 -1
- package/lib/flatten/rollup.js +2 -0
- package/lib/flatten/rollup.js.map +1 -1
- package/lib/flatten/uglify.d.ts +1 -1
- package/lib/flatten/uglify.js +3 -12
- package/lib/flatten/uglify.js.map +1 -1
- package/lib/graph/transform.d.ts +1 -1
- package/lib/graph/transform.di.d.ts +1 -1
- package/lib/graph/transform.di.js +1 -1
- package/lib/graph/transform.di.js.map +1 -1
- package/lib/graph/transform.js.map +1 -1
- package/lib/ng-package/discover-packages.js +21 -6
- package/lib/ng-package/discover-packages.js.map +1 -1
- package/lib/ng-package/entry-point/entry-point.d.ts +5 -5
- package/lib/ng-package/entry-point/entry-point.js +1 -1
- package/lib/ng-package/entry-point/entry-point.js.map +1 -1
- package/lib/ng-package/entry-point/entry-point.transform.d.ts +1 -1
- package/lib/ng-package/entry-point/entry-point.transform.js +1 -1
- package/lib/ng-package/entry-point/entry-point.transform.js.map +1 -1
- package/lib/ng-package/entry-point/init-tsconfig.transform.js +2 -2
- package/lib/ng-package/entry-point/init-tsconfig.transform.js.map +1 -1
- package/lib/ng-package/entry-point/write-bundles.transform.js +6 -5
- package/lib/ng-package/entry-point/write-bundles.transform.js.map +1 -1
- package/lib/ng-package/entry-point/write-package.transform.js +1 -1
- package/lib/ng-package/entry-point/write-package.transform.js.map +1 -1
- package/lib/ng-package/nodes.d.ts +3 -0
- package/lib/ng-package/nodes.js.map +1 -1
- package/lib/ng-package/package.d.ts +3 -3
- package/lib/ng-package/package.js +2 -2
- package/lib/ng-package/package.js.map +1 -1
- package/lib/ngc/create-emit-callback.js +1 -1
- package/lib/ngc/create-emit-callback.js.map +1 -1
- package/lib/packagr.d.ts +1 -1
- package/lib/packagr.js +1 -1
- package/lib/packagr.js.map +1 -1
- package/lib/styles/stylesheet-processor.js +5 -5
- package/lib/styles/stylesheet-processor.js.map +1 -1
- package/lib/ts/tsconfig.js +1 -0
- package/lib/ts/tsconfig.js.map +1 -1
- package/lib/utils/color.d.ts +3 -0
- package/lib/utils/color.js +14 -0
- package/lib/utils/color.js.map +1 -0
- package/lib/utils/log.js +9 -9
- package/lib/utils/log.js.map +1 -1
- package/lib/utils/path.js +9 -2
- package/lib/utils/path.js.map +1 -1
- package/package.json +10 -11
- package/public_api.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [10.1.1](https://github.com/ng-packagr/ng-packagr/compare/v10.1.0...v10.1.1) (2020-09-25)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* add basePath as sourceRoot ([681fb1c](https://github.com/ng-packagr/ng-packagr/commit/681fb1c36b68efb3078dc3d846776e9e749ebf44))
|
|
11
|
+
* replace execFile with execFileSync to fix a potential malicious cmd injection ([bda0fff](https://github.com/ng-packagr/ng-packagr/commit/bda0fff3443301f252930a73fdc8fb9502de596d))
|
|
12
|
+
|
|
13
|
+
## [10.1.0](https://github.com/ng-packagr/ng-packagr/compare/v10.0.4...v10.1.0) (2020-08-27)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add support for TypeScript 4 ([eb8b0c2](https://github.com/ng-packagr/ng-packagr/commit/eb8b0c2553aa1847f4ab42f29a1a25e67f644d29))
|
|
19
|
+
* show warning on deprecated option usage ([551a4d9](https://github.com/ng-packagr/ng-packagr/commit/551a4d9a866a8c337189f807d755856b995ffc9b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* update commander to version ^6.0.0 ([ec736e5](https://github.com/ng-packagr/ng-packagr/commit/ec736e5df6978be79dca236683936941f349a8e5))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Performance
|
|
28
|
+
|
|
29
|
+
* cache normalized paths ([92f68e3](https://github.com/ng-packagr/ng-packagr/commit/92f68e3f09f66c990413e09cda5d742ad00c5b7f))
|
|
30
|
+
|
|
31
|
+
### [10.0.4](https://github.com/ng-packagr/ng-packagr/compare/v10.0.3...v10.0.4) (2020-08-13)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* update @rollup/plugin-commonjs to version ^15.0.0 ([cc3254a](https://github.com/ng-packagr/ng-packagr/commit/cc3254aa230e1c94991514e780facc2eb19b4546))
|
|
37
|
+
* update @rollup/plugin-node-resolve to version ^9.0.0 ([47606fd](https://github.com/ng-packagr/ng-packagr/commit/47606fd2ae254e024d9fdcac11489e114ced145a))
|
|
38
|
+
|
|
39
|
+
### [10.0.3](https://github.com/ng-packagr/ng-packagr/compare/v10.0.2...v10.0.3) (2020-07-22)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Performance
|
|
43
|
+
|
|
44
|
+
* implement rollup caching ([eb13316](https://github.com/ng-packagr/ng-packagr/commit/eb1331641b2828da0d188d5934f68f7307e6817b)), closes [#1580](https://github.com/ng-packagr/ng-packagr/issues/1580)
|
|
45
|
+
|
|
5
46
|
### [10.0.2](https://github.com/ng-packagr/ng-packagr/compare/v10.0.1...v10.0.2) (2020-07-16)
|
|
6
47
|
|
|
7
48
|
|
package/cli/main.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const program = require("commander");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const updateNotifier = require("update-notifier");
|
|
7
6
|
const readPkgUp = require("read-pkg-up");
|
|
8
7
|
const public_api_1 = require("../public_api");
|
|
9
8
|
const DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');
|
|
@@ -12,13 +11,13 @@ function parseProjectPath(parsed) {
|
|
|
12
11
|
}
|
|
13
12
|
program
|
|
14
13
|
.name('ng-packagr')
|
|
14
|
+
.storeOptionsAsProperties(false)
|
|
15
15
|
.option('-v, --version', 'Prints version info')
|
|
16
16
|
.option('-w, --watch', 'Watch for file changes')
|
|
17
17
|
.option('-p, --project [path]', "Path to the 'ng-package.json' or 'package.json' file.", parseProjectPath, DEFAULT_PROJECT_PATH)
|
|
18
18
|
.option('-c, --config [config]', 'Path to a tsconfig file.', (value) => value ? path.resolve(value) : undefined);
|
|
19
19
|
const dir = path.dirname(module.filename);
|
|
20
20
|
const pkg = readPkgUp.sync({ cwd: dir }).pkg;
|
|
21
|
-
updateNotifier({ pkg }).notify();
|
|
22
21
|
program.on('option:version', () => {
|
|
23
22
|
public_api_1.version(pkg);
|
|
24
23
|
process.exit(0);
|
package/cli/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";;;AAEA,qCAAqC;AACrC,6BAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";;;AAEA,qCAAqC;AACrC,6BAA6B;AAC7B,yCAAyC;AACzC,8CAAwD;AAExD,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAE5E,SAAS,gBAAgB,CAAC,MAAc;IACtC,OAAO,MAAM,IAAI,oBAAoB,CAAC;AACxC,CAAC;AAED,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,wBAAwB,CAAC,KAAK,CAAC;KAC/B,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;KAC9C,MAAM,CAAC,aAAa,EAAE,wBAAwB,CAAC;KAC/C,MAAM,CACL,sBAAsB,EACtB,uDAAuD,EACvD,gBAAgB,EAChB,oBAAoB,CACrB;KACA,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,EAAE,CAAC,KAAyB,EAAE,EAAE,CACzF,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CACxC,CAAC;AAEJ,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC;AAE7C,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAChC,oBAAO,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAClD,oBAAO,CAAC,kBAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport * as program from 'commander';\nimport * as path from 'path';\nimport * as readPkgUp from 'read-pkg-up';\nimport { execute, build, version } from '../public_api';\n\nconst DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');\n\nfunction parseProjectPath(parsed: string): string {\n return parsed || DEFAULT_PROJECT_PATH;\n}\n\nprogram\n .name('ng-packagr')\n .storeOptionsAsProperties(false)\n .option('-v, --version', 'Prints version info')\n .option('-w, --watch', 'Watch for file changes')\n .option(\n '-p, --project [path]',\n \"Path to the 'ng-package.json' or 'package.json' file.\",\n parseProjectPath,\n DEFAULT_PROJECT_PATH,\n )\n .option('-c, --config [config]', 'Path to a tsconfig file.', (value: string | undefined) =>\n value ? path.resolve(value) : undefined,\n );\n\nconst dir = path.dirname(module.filename);\nconst pkg = readPkgUp.sync({ cwd: dir }).pkg;\n\nprogram.on('option:version', () => {\n version(pkg);\n process.exit(0);\n});\n\nprogram.parse(process.argv);\n\nconst { config, project, watch } = program.opts();\nexecute(build, { config, project, watch: !!watch }).catch(() => process.exit(111));\n"]}
|
|
@@ -34,7 +34,7 @@ class ExternalModuleIdStrategy {
|
|
|
34
34
|
if (this.moduleFormat !== 'umd') {
|
|
35
35
|
return /./; // catch all as external
|
|
36
36
|
}
|
|
37
|
-
// tslib should always be
|
|
37
|
+
// tslib should always be embedded for umd modules
|
|
38
38
|
if (bundledDependencies.length === 0) {
|
|
39
39
|
return /^((?!tslib).)*$/;
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-module-id-strategy.js","sourceRoot":"","sources":["../../../src/lib/flatten/external-module-id-strategy.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAU7B,MAAa,wBAAwB;IACnC,YAAoB,YAAiC,EAAU,cAA8B;QAAzE,iBAAY,GAAZ,YAAY,CAAqB;QAAU,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEjG,8DAA8D;IAC9D,oBAAoB,CAAC,QAAgB;QACnC,oEAAoE;QACpE,yFAAyF;QACzF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACrF,yGAAyG;YACzG,OAAO,KAAK,CAAC;SACd;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACnD,IACE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACtB,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC7B;YACA,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,yBAAyB;QACvB,MAAM,EAAE,mBAAmB,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;QAE5E,qGAAqG;QACrG,qFAAqF;QACrF,qCAAqC;QACrC,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC/B,OAAO,GAAG,CAAC,CAAC,wBAAwB;SACrC;QAED,kDAAkD;QAClD,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE;YACpC,OAAO,iBAAiB,CAAC;SAC1B;QAED,wDAAwD;QACxD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;CACF;AA7CD,4DA6CC","sourcesContent":["import * as path from 'path';\nimport * as rollup from 'rollup';\n\nexport interface DependencyList {\n /** Direct dependencies including peerDependencies and other entry points. */\n dependencies?: string[];\n /** Direct bundled dependencies */\n bundledDependencies?: string[];\n}\n\nexport class ExternalModuleIdStrategy {\n constructor(private moduleFormat: rollup.ModuleFormat, private dependencyList: DependencyList) {}\n\n /** Return true when moduleId is to be treated as external */\n 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 (path.isAbsolute(moduleId) || moduleId.startsWith('.') || moduleId.startsWith('/')) {\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 const externals = this.getNonBundledDependencies();\n if (\n Array.isArray(externals)\n ? !externals.some(x => x === moduleId || moduleId.startsWith(`${x}/`))\n : !externals.test(moduleId)\n ) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Returns a array of strings or a RegExp of non-bundled dependencies.\n */\n getNonBundledDependencies(): string[] | RegExp {\n const { bundledDependencies = [], dependencies = [] } = this.dependencyList;\n\n // return catch all for when there are no 'bundledDependencies' is very important for secondary entry\n // as if this is not the case everything will be bundled in the secondary entry point\n // since no dependencies are defined.\n if (this.moduleFormat !== 'umd') {\n return /./; // catch all as external\n }\n\n // tslib should always be
|
|
1
|
+
{"version":3,"file":"external-module-id-strategy.js","sourceRoot":"","sources":["../../../src/lib/flatten/external-module-id-strategy.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAU7B,MAAa,wBAAwB;IACnC,YAAoB,YAAiC,EAAU,cAA8B;QAAzE,iBAAY,GAAZ,YAAY,CAAqB;QAAU,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEjG,8DAA8D;IAC9D,oBAAoB,CAAC,QAAgB;QACnC,oEAAoE;QACpE,yFAAyF;QACzF,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACrF,yGAAyG;YACzG,OAAO,KAAK,CAAC;SACd;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACnD,IACE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;YACtB,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC7B;YACA,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,yBAAyB;QACvB,MAAM,EAAE,mBAAmB,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;QAE5E,qGAAqG;QACrG,qFAAqF;QACrF,qCAAqC;QACrC,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC/B,OAAO,GAAG,CAAC,CAAC,wBAAwB;SACrC;QAED,kDAAkD;QAClD,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE;YACpC,OAAO,iBAAiB,CAAC;SAC1B;QAED,wDAAwD;QACxD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;CACF;AA7CD,4DA6CC","sourcesContent":["import * as path from 'path';\nimport * as rollup from 'rollup';\n\nexport interface DependencyList {\n /** Direct dependencies including peerDependencies and other entry points. */\n dependencies?: string[];\n /** Direct bundled dependencies */\n bundledDependencies?: string[];\n}\n\nexport class ExternalModuleIdStrategy {\n constructor(private moduleFormat: rollup.ModuleFormat, private dependencyList: DependencyList) {}\n\n /** Return true when moduleId is to be treated as external */\n 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 (path.isAbsolute(moduleId) || moduleId.startsWith('.') || moduleId.startsWith('/')) {\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 const externals = this.getNonBundledDependencies();\n if (\n Array.isArray(externals)\n ? !externals.some(x => x === moduleId || moduleId.startsWith(`${x}/`))\n : !externals.test(moduleId)\n ) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Returns a array of strings or a RegExp of non-bundled dependencies.\n */\n getNonBundledDependencies(): string[] | RegExp {\n const { bundledDependencies = [], dependencies = [] } = this.dependencyList;\n\n // return catch all for when there are no 'bundledDependencies' is very important for secondary entry\n // as if this is not the case everything will be bundled in the secondary entry point\n // since no dependencies are defined.\n if (this.moduleFormat !== 'umd') {\n return /./; // catch all as external\n }\n\n // tslib should always be embedded for umd modules\n if (bundledDependencies.length === 0) {\n return /^((?!tslib).)*$/;\n }\n\n // filter out dependencies that are meant to be external\n return dependencies.filter(x => bundledDependencies.indexOf(x) < 0);\n }\n}\n"]}
|
package/lib/flatten/rollup.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface RollupOptions {
|
|
|
20
20
|
};
|
|
21
21
|
transform?: TransformHook;
|
|
22
22
|
dependencyList?: DependencyList;
|
|
23
|
+
cache?: rollup.RollupCache;
|
|
23
24
|
}
|
|
24
25
|
/** Runs rollup over the given entry file, writes a bundle file. */
|
|
25
|
-
export declare function rollupBundleFile(opts: RollupOptions): Promise<
|
|
26
|
+
export declare function rollupBundleFile(opts: RollupOptions): Promise<rollup.RollupCache>;
|
package/lib/flatten/rollup.js
CHANGED
|
@@ -28,6 +28,7 @@ function rollupBundleFile(opts) {
|
|
|
28
28
|
context: 'this',
|
|
29
29
|
external: moduleId => externalModuleIdStrategy.isExternalDependency(moduleId),
|
|
30
30
|
inlineDynamicImports: false,
|
|
31
|
+
cache: opts.cache,
|
|
31
32
|
input: opts.entry,
|
|
32
33
|
plugins: [
|
|
33
34
|
// @ts-ignore
|
|
@@ -66,6 +67,7 @@ function rollupBundleFile(opts) {
|
|
|
66
67
|
globals: moduleId => umd_module_id_strategy_1.umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),
|
|
67
68
|
sourcemap: true,
|
|
68
69
|
});
|
|
70
|
+
return bundle.cache;
|
|
69
71
|
});
|
|
70
72
|
}
|
|
71
73
|
exports.rollupBundleFile = rollupBundleFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,qEAAsD;AACtD,uDAAuD;AACvD,oDAAoD;AACpD,kDAAkD;AAClD,oCAAoC;AACpC,+EAAyF;AACzF,qEAA+D;
|
|
1
|
+
{"version":3,"file":"rollup.js","sourceRoot":"","sources":["../../../src/lib/flatten/rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AACjC,qEAAsD;AACtD,uDAAuD;AACvD,oDAAoD;AACpD,kDAAkD;AAClD,oCAAoC;AACpC,+EAAyF;AACzF,qEAA+D;AAqB/D,mEAAmE;AACnE,SAAsB,gBAAgB,CAAC,IAAmB;;QACxD,GAAG,CAAC,KAAK,CAAC,YAAY,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAExF,MAAM,wBAAwB,GAAG,IAAI,sDAAwB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAEhG,oBAAoB;QACpB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC;YACjC,OAAO,EAAE,MAAM;YACf,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,QAAQ,CAAC;YAC7E,oBAAoB,EAAE,KAAK;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE;gBACP,aAAa;gBACb,UAAU,EAAE;gBACZ,aAAa;gBACb,6BAAW,EAAE;gBACb,aAAa;gBACb,QAAQ,EAAE;gBACV,aAAa;gBACb,UAAU,EAAE;gBACZ,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE;aAC9B;YACD,MAAM,EAAE,OAAO,CAAC,EAAE;gBAChB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;oBAC/B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACnB;qBAAM;oBACL,IAAI,OAAO,CAAC,IAAI,KAAK,mBAAmB,EAAE;wBACxC,OAAO;qBACR;oBAED,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;iBAC3B;YACH,CAAC;YACD,gBAAgB,EAAE,IAAI;YACtB,8CAA8C;YAC9C,qDAAqD;YACrD,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,MAAM,CAAC,KAAK,CAAC;YACjB,IAAI,EAAE,IAAI,CAAC,UAAU;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,4CAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;YAC3E,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;CAAA;AApDD,4CAoDC","sourcesContent":["import * as rollup from 'rollup';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as sourcemaps from 'rollup-plugin-sourcemaps';\nimport * as commonJs from '@rollup/plugin-commonjs';\nimport * as rollupJson from '@rollup/plugin-json';\nimport * as log from '../utils/log';\nimport { ExternalModuleIdStrategy, DependencyList } from './external-module-id-strategy';\nimport { umdModuleIdStrategy } from './umd-module-id-strategy';\nimport { TransformHook } from 'rollup';\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 format: rollup.ModuleFormat;\n dest: string;\n sourceRoot: string;\n umdModuleIds?: { [key: string]: string };\n amd?: { id: string };\n transform?: TransformHook;\n dependencyList?: DependencyList;\n cache?: rollup.RollupCache;\n}\n\n/** Runs rollup over the given entry file, writes a bundle file. */\nexport async function rollupBundleFile(opts: RollupOptions): Promise<rollup.RollupCache> {\n log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`);\n\n const externalModuleIdStrategy = new ExternalModuleIdStrategy(opts.format, opts.dependencyList);\n\n // Create the bundle\n const bundle = await rollup.rollup({\n context: 'this',\n external: moduleId => externalModuleIdStrategy.isExternalDependency(moduleId),\n inlineDynamicImports: false,\n cache: opts.cache,\n input: opts.entry,\n plugins: [\n // @ts-ignore\n rollupJson(),\n // @ts-ignore\n nodeResolve(),\n // @ts-ignore\n commonJs(),\n // @ts-ignore\n sourcemaps(),\n { transform: opts.transform },\n ],\n onwarn: warning => {\n if (typeof warning === 'string') {\n log.warn(warning);\n } else {\n if (warning.code === 'THIS_IS_UNDEFINED') {\n return;\n }\n\n log.warn(warning.message);\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 await bundle.write({\n name: opts.moduleName,\n format: opts.format,\n amd: opts.amd,\n file: opts.dest,\n banner: '',\n globals: moduleId => umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),\n sourcemap: true,\n });\n\n return bundle.cache;\n}\n"]}
|
package/lib/flatten/uglify.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function minifyJsFile(inputPath: string, outputPath?: string): Promise<
|
|
1
|
+
export declare function minifyJsFile(inputPath: string, outputPath?: string): Promise<void>;
|
package/lib/flatten/uglify.js
CHANGED
|
@@ -22,7 +22,7 @@ function minifyJsFile(inputPath, outputPath) {
|
|
|
22
22
|
fs_extra_1.readFile(inputPath),
|
|
23
23
|
fs_extra_1.readFile(`${inputPath}.map`),
|
|
24
24
|
]);
|
|
25
|
-
const result = terser_1.minify(inputFileBuffer.toString(), {
|
|
25
|
+
const result = yield terser_1.minify(inputFileBuffer.toString(), {
|
|
26
26
|
sourceMap: {
|
|
27
27
|
includeSources: true,
|
|
28
28
|
content: JSON.parse(inputSourceMapBuffer.toString()),
|
|
@@ -32,21 +32,12 @@ function minifyJsFile(inputPath, outputPath) {
|
|
|
32
32
|
ecma: 5,
|
|
33
33
|
bare_returns: true,
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
output: {
|
|
35
|
+
format: {
|
|
37
36
|
comments: 'some',
|
|
38
37
|
},
|
|
39
38
|
});
|
|
40
|
-
if (result.warnings) {
|
|
41
|
-
for (const warningMessage of result.warnings) {
|
|
42
|
-
log_1.warn(warningMessage);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (result.error) {
|
|
46
|
-
throw result.error;
|
|
47
|
-
}
|
|
48
39
|
yield Promise.all([fs_extra_1.writeFile(outputPath, result.code), fs_extra_1.writeFile(sourcemapOut, result.map)]);
|
|
49
|
-
return
|
|
40
|
+
return;
|
|
50
41
|
});
|
|
51
42
|
}
|
|
52
43
|
exports.minifyJsFile = minifyJsFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uglify.js","sourceRoot":"","sources":["../../../src/lib/flatten/uglify.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAgC;AAChC,uCAA+C;AAC/C,+BAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"uglify.js","sourceRoot":"","sources":["../../../src/lib/flatten/uglify.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAgC;AAChC,uCAA+C;AAC/C,+BAAgC;AAChC,sCAAqC;AAErC,SAAsB,YAAY,CAAC,SAAiB,EAAE,UAAmB;;QACvE,WAAK,CAAC,iBAAiB,SAAS,EAAE,CAAC,CAAC;QAEpC,MAAM,YAAY,GAAG,GAAG,UAAU,MAAM,CAAC;QACzC,MAAM,CAAC,eAAe,EAAE,oBAAoB,CAAC,GAAa,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1E,mBAAQ,CAAC,SAAS,CAAC;YACnB,mBAAQ,CAAC,GAAG,SAAS,MAAM,CAAC;SAC7B,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,MAAM,eAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE;YACtD,SAAS,EAAE;gBACT,cAAc,EAAE,IAAI;gBACpB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,QAAQ,EAAE,CAAC;gBACpD,GAAG,EAAE,eAAQ,CAAC,YAAY,CAAC;aAC5B;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,CAAC;gBACP,YAAY,EAAE,IAAI;aACnB;YACD,MAAM,EAAE;gBACN,QAAQ,EAAE,MAAM;aACjB;SACF,CAAC,CAAC;QAEH,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,oBAAS,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,oBAAS,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAE7F,OAAO;IACT,CAAC;CAAA;AA3BD,oCA2BC","sourcesContent":["import { minify } from 'terser';\nimport { writeFile, readFile } from 'fs-extra';\nimport { basename } from 'path';\nimport { debug } from '../utils/log';\n\nexport async function minifyJsFile(inputPath: string, outputPath?: string): Promise<void> {\n debug(`minifyJsFile: ${inputPath}`);\n\n const sourcemapOut = `${outputPath}.map`;\n const [inputFileBuffer, inputSourceMapBuffer]: Buffer[] = await Promise.all([\n readFile(inputPath),\n readFile(`${inputPath}.map`),\n ]);\n\n const result = await minify(inputFileBuffer.toString(), {\n sourceMap: {\n includeSources: true,\n content: JSON.parse(inputSourceMapBuffer.toString()),\n url: basename(sourcemapOut),\n },\n parse: {\n ecma: 5,\n bare_returns: true,\n },\n format: {\n comments: 'some',\n },\n });\n\n await Promise.all([writeFile(outputPath, result.code), writeFile(sourcemapOut, result.map)]);\n\n return;\n}\n"]}
|
package/lib/graph/transform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MonoTypeOperatorFunction, Observable } from 'rxjs';
|
|
2
2
|
import { BuildGraph } from './build-graph';
|
|
3
3
|
/**
|
|
4
|
-
* A
|
|
4
|
+
* A transformation applied over the build graph.
|
|
5
5
|
*
|
|
6
6
|
* By design, a pipeable operator over `BuildGraph`.
|
|
7
7
|
* - A transformation takes a `BuildGraph` as input (from previous transformations).
|
|
@@ -25,7 +25,7 @@ export interface TransformProvider extends FactoryProvider {
|
|
|
25
25
|
* ```ts
|
|
26
26
|
* const FOO_BAR_TOKEN = new InjectionToken<Transform>('fooBar');
|
|
27
27
|
*
|
|
28
|
-
* const FOO_BAR_TRANSFORM provideTransform({
|
|
28
|
+
* const FOO_BAR_TRANSFORM = provideTransform({
|
|
29
29
|
* provide: FOO_BAR_TOKEN,
|
|
30
30
|
* useFactory: (foo, bar) => {
|
|
31
31
|
* return pipe(foo, bar);
|
|
@@ -11,7 +11,7 @@ exports.provideTransform = void 0;
|
|
|
11
11
|
* ```ts
|
|
12
12
|
* const FOO_BAR_TOKEN = new InjectionToken<Transform>('fooBar');
|
|
13
13
|
*
|
|
14
|
-
* const FOO_BAR_TRANSFORM provideTransform({
|
|
14
|
+
* const FOO_BAR_TRANSFORM = provideTransform({
|
|
15
15
|
* provide: FOO_BAR_TOKEN,
|
|
16
16
|
* useFactory: (foo, bar) => {
|
|
17
17
|
* return pipe(foo, bar);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.di.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.di.ts"],"names":[],"mappings":";;;AAoBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,gBAAgB,CAAC,MAAyB;IACxD,uCACK,MAAM,KACT,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,IACvB;AACJ,CAAC;AALD,4CAKC","sourcesContent":["import { InjectionToken, FactoryProvider } from 'injection-js';\nimport { Transform } from './transform';\n\n/**\n * A specialized `FactoryProvider` for a `Transform`.\n */\nexport interface TransformProvider extends FactoryProvider {\n /**\n * An injection token for the `Transform` provided by this provider.\n */\n provide: InjectionToken<Transform>;\n\n /**\n * A function to invoke to create the `Transform`.\n *\n * The factory function is invoked with resolved values of tokens in the `deps` field.\n */\n useFactory: (...args: any[]) => Transform;\n}\n\n/**\n * Creates a provider for a `Transform`.\n *\n * #### Example\n *\n * Creating a transformation `fooBar` that is composed of `foo` and `bar` transforms:\n *\n * ```ts\n * const FOO_BAR_TOKEN = new InjectionToken<Transform>('fooBar');\n *\n * const FOO_BAR_TRANSFORM provideTransform({\n * provide: FOO_BAR_TOKEN,\n * useFactory: (foo, bar) => {\n * return pipe(foo, bar);\n * },\n * deps: [ FOO_TOKEN, BAR_TOKEN ]\n * });\n * ```\n *\n * @param module The provider for the transform\n * @return A (normalized) provider for the transform\n */\nexport function provideTransform(module: TransformProvider): TransformProvider {\n return {\n ...module,\n deps: module.deps || [],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transform.di.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.di.ts"],"names":[],"mappings":";;;AAoBA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,gBAAgB,CAAC,MAAyB;IACxD,uCACK,MAAM,KACT,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,IACvB;AACJ,CAAC;AALD,4CAKC","sourcesContent":["import { InjectionToken, FactoryProvider } from 'injection-js';\nimport { Transform } from './transform';\n\n/**\n * A specialized `FactoryProvider` for a `Transform`.\n */\nexport interface TransformProvider extends FactoryProvider {\n /**\n * An injection token for the `Transform` provided by this provider.\n */\n provide: InjectionToken<Transform>;\n\n /**\n * A function to invoke to create the `Transform`.\n *\n * The factory function is invoked with resolved values of tokens in the `deps` field.\n */\n useFactory: (...args: any[]) => Transform;\n}\n\n/**\n * Creates a provider for a `Transform`.\n *\n * #### Example\n *\n * Creating a transformation `fooBar` that is composed of `foo` and `bar` transforms:\n *\n * ```ts\n * const FOO_BAR_TOKEN = new InjectionToken<Transform>('fooBar');\n *\n * const FOO_BAR_TRANSFORM = provideTransform({\n * provide: FOO_BAR_TOKEN,\n * useFactory: (foo, bar) => {\n * return pipe(foo, bar);\n * },\n * deps: [ FOO_TOKEN, BAR_TOKEN ]\n * });\n * ```\n *\n * @param module The provider for the transform\n * @return A (normalized) provider for the transform\n */\nexport function provideTransform(module: TransformProvider): TransformProvider {\n return {\n ...module,\n deps: module.deps || [],\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.ts"],"names":[],"mappings":";;;AAAA,+BAA2G;AAC3G,8CAAgD;AAqBnC,QAAA,oBAAoB,GAAG,CAAC,WAAkC,EAAa,EAAE,CACpF,WAAI,CACF,qBAAS,CAAC,KAAK,CAAC,EAAE;IAChB,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,eAAe,YAAY,OAAO,EAAE;QACtC,OAAO,WAAW,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,eAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpF;SAAM;QACL,OAAO,SAAY,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAChE;AACH,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { MonoTypeOperatorFunction, Observable, from as fromPromise, of as observableOf, pipe } from 'rxjs';\nimport { map, switchMap } from 'rxjs/operators';\nimport { BuildGraph } from './build-graph';\n\n/**\n * A
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/lib/graph/transform.ts"],"names":[],"mappings":";;;AAAA,+BAA2G;AAC3G,8CAAgD;AAqBnC,QAAA,oBAAoB,GAAG,CAAC,WAAkC,EAAa,EAAE,CACpF,WAAI,CACF,qBAAS,CAAC,KAAK,CAAC,EAAE;IAChB,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,eAAe,YAAY,OAAO,EAAE;QACtC,OAAO,WAAW,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,eAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpF;SAAM;QACL,OAAO,SAAY,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAChE;AACH,CAAC,CAAC,CACH,CAAC","sourcesContent":["import { MonoTypeOperatorFunction, Observable, from as fromPromise, of as observableOf, pipe } from 'rxjs';\nimport { map, switchMap } from 'rxjs/operators';\nimport { BuildGraph } from './build-graph';\n\n/**\n * A transformation applied over the build graph.\n *\n * By design, a pipeable operator over `BuildGraph`.\n * - A transformation takes a `BuildGraph` as input (from previous transformations).\n * - A transformation performs some operations based on the graph's data, potentially modifying nodes in the graph.\n * - It returns a `BuildGraph` that will be passed to subsequent transformations.\n *\n * @link https://github.com/ReactiveX/rxjs/blob/master/doc/pipeable-operators.md#pipeable-operators\n */\nexport interface Transform extends MonoTypeOperatorFunction<BuildGraph> {\n (source$: Observable<BuildGraph>): Observable<BuildGraph>;\n}\n\nexport interface PromiseBasedTransform {\n (graph: BuildGraph): Promise<BuildGraph | void> | BuildGraph | void;\n}\n\nexport const transformFromPromise = (transformFn: PromiseBasedTransform): Transform =>\n pipe(\n switchMap(graph => {\n const transformResult = transformFn(graph);\n\n if (transformResult instanceof Promise) {\n return fromPromise(transformResult).pipe(map(result => (result ? result : graph)));\n } else {\n return observableOf(transformResult ? transformResult : graph);\n }\n }),\n );\n"]}
|
|
@@ -47,6 +47,9 @@ function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
47
47
|
if (!packageJson && !isSecondary) {
|
|
48
48
|
throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);
|
|
49
49
|
}
|
|
50
|
+
if (packageJson && typeof packageJson !== 'object') {
|
|
51
|
+
throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);
|
|
52
|
+
}
|
|
50
53
|
let ngPackageJson;
|
|
51
54
|
if (packageJson && packageJson['ngPackage']) {
|
|
52
55
|
// Read `ngPackage` from `package.json`
|
|
@@ -65,8 +68,19 @@ function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
65
68
|
const _ajv = ajv({
|
|
66
69
|
schemaId: 'auto',
|
|
67
70
|
useDefaults: true,
|
|
71
|
+
jsonPointers: true,
|
|
68
72
|
});
|
|
69
73
|
const validate = _ajv.compile(ngPackageSchemaJson);
|
|
74
|
+
// Add handler for x-deprecated fields
|
|
75
|
+
_ajv.addKeyword('x-deprecated', {
|
|
76
|
+
validate: (schema, _data, _parentSchema, _dataPath, _parentDataObject, propertyName) => {
|
|
77
|
+
if (schema) {
|
|
78
|
+
log.warn(`Option "${propertyName}" is deprecated${typeof schema == 'string' ? ': ' + schema : '.'}`);
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
},
|
|
82
|
+
errors: false,
|
|
83
|
+
});
|
|
70
84
|
const isValid = validate(ngPackageJson);
|
|
71
85
|
if (!isValid) {
|
|
72
86
|
throw new Error(`Configuration doesn\'t match the required schema.\n${formatSchemaValidationErrors(validate.errors)}`);
|
|
@@ -74,7 +88,7 @@ function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
|
|
|
74
88
|
return {
|
|
75
89
|
basePath,
|
|
76
90
|
packageJson: packageJson || {},
|
|
77
|
-
ngPackageJson,
|
|
91
|
+
ngPackageJson: ngPackageJson,
|
|
78
92
|
};
|
|
79
93
|
}
|
|
80
94
|
if (pathStats.isDirectory()) {
|
|
@@ -117,15 +131,16 @@ function findSecondaryPackagesPaths(directoryPath, excludeFolder) {
|
|
|
117
131
|
/**
|
|
118
132
|
* Reads a secondary entry point from it's package file.
|
|
119
133
|
*
|
|
120
|
-
* @param primaryDirectoryPath A path pointing to the directory of the primary entry point.
|
|
121
134
|
* @param primary The primary entry point.
|
|
135
|
+
* @param userPackage The user package for the secondary entry point.
|
|
122
136
|
*/
|
|
123
|
-
function secondaryEntryPoint(
|
|
124
|
-
|
|
137
|
+
function secondaryEntryPoint(primary, userPackage) {
|
|
138
|
+
const { packageJson, ngPackageJson, basePath } = userPackage;
|
|
139
|
+
if (path.resolve(basePath) === path.resolve(primary.basePath)) {
|
|
125
140
|
log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);
|
|
126
141
|
throw new Error(`Secondary entry point is already a primary.`);
|
|
127
142
|
}
|
|
128
|
-
const relativeSourcePath = path.relative(
|
|
143
|
+
const relativeSourcePath = path.relative(primary.basePath, basePath);
|
|
129
144
|
const secondaryModuleId = path_1.ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);
|
|
130
145
|
return new entry_point_1.NgEntryPoint(packageJson, ngPackageJson, basePath, {
|
|
131
146
|
moduleId: secondaryModuleId,
|
|
@@ -144,7 +159,7 @@ function discoverPackages({ project }) {
|
|
|
144
159
|
for (const folderPath of folderPaths) {
|
|
145
160
|
const secondaryPackage = yield resolveUserPackage(folderPath, true);
|
|
146
161
|
if (secondaryPackage) {
|
|
147
|
-
secondaries.push(secondaryEntryPoint(
|
|
162
|
+
secondaries.push(secondaryEntryPoint(primary, secondaryPackage));
|
|
148
163
|
}
|
|
149
164
|
}
|
|
150
165
|
if (secondaries.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA2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AAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC3F;QAED,OAAO,IAAI,mBAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACvD,CAAC;CAAA;AAtBD,4CAsBC","sourcesContent":["import * as ajv from 'ajv';\nimport { pathExistsSync, lstat } from 'fs-extra';\nimport * as path from 'path';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { globFiles } from '../utils/glob';\n\nconst ngPackageSchemaJson = require('../../ng-package.schema.json');\n\ninterface UserPackage {\n packageJson: object;\n ngPackageJson: object;\n basePath: string;\n}\n\nfunction formatSchemaValidationErrors(errors: ajv.ErrorObject[]): string {\n return errors\n .map(err => {\n let message = `Data path ${JSON.stringify(err.dataPath)} ${err.message}`;\n if (err.keyword === 'additionalProperties') {\n message += ` (${(err.params as any).additionalProperty})`;\n }\n\n return message + '.';\n })\n .join('\\n');\n}\n\n/**\n * Resolves a user's package by testing for 'package.json', 'ng-package.json', or 'ng-package.js'.\n *\n * @param folderPathOrFilePath A path pointing either to a file or a directory\n * @param isSecondary A boolean determining if this is a secondary package\n * @return The user's package\n */\nasync function resolveUserPackage(folderPathOrFilePath: string, isSecondary = false): Promise<UserPackage | undefined> {\n const readConfigFile = async (filePath: string) => (pathExistsSync(filePath) ? import(filePath) : undefined);\n const fullPath = path.resolve(folderPathOrFilePath);\n const pathStats = await lstat(fullPath);\n const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);\n const packageJson = await readConfigFile(path.join(basePath, 'package.json'));\n\n if (!packageJson && !isSecondary) {\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);\n }\n\n let ngPackageJson: undefined | object;\n if (packageJson && packageJson['ngPackage']) {\n // Read `ngPackage` from `package.json`\n ngPackageJson = { ...packageJson['ngPackage'] };\n } else if (pathStats.isDirectory()) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));\n if (!ngPackageJson) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));\n }\n } else {\n ngPackageJson = await readConfigFile(fullPath);\n }\n\n if (ngPackageJson) {\n const _ajv = ajv({\n schemaId: 'auto',\n useDefaults: true,\n });\n\n const validate = _ajv.compile(ngPackageSchemaJson);\n const isValid = validate(ngPackageJson);\n if (!isValid) {\n throw new Error(\n `Configuration doesn\\'t match the required schema.\\n${formatSchemaValidationErrors(validate.errors)}`,\n );\n }\n\n return {\n basePath,\n packageJson: packageJson || {},\n ngPackageJson,\n };\n }\n\n if (pathStats.isDirectory()) {\n // return even if it's undefined and use defaults when it's not a file\n return undefined;\n }\n\n if (pathStats.isFile()) {\n // a project file was specified but was in valid\n if (path.basename(folderPathOrFilePath) === 'package.json') {\n throw new Error(`Cannot read a package from 'package.json' without 'ngPackage' property.`);\n }\n\n throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);\n }\n\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);\n}\n\n/**\n * Scans `directoryPath` and sub-folders, looking for `package.json` files.\n * Similar to `find ${directoryPath} --name package.json --exec dirname {}`.\n *\n * @param directoryPath Path pointing to a directory\n * @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.\n */\nasync function findSecondaryPackagesPaths(directoryPath: string, excludeFolder: string): Promise<string[]> {\n const ignore = [\n '**/node_modules/**',\n '**/.git/**',\n `${path.resolve(directoryPath, excludeFolder)}/**`,\n `${directoryPath}/package.json`,\n `${directoryPath}/ng-package.json`,\n ];\n\n const filePaths = await globFiles(`${directoryPath}/**/{package,ng-package}.json`, {\n ignore,\n cwd: directoryPath,\n });\n\n return filePaths.map(path.dirname);\n}\n\n/**\n * Reads a secondary entry point from it's package file.\n *\n * @param primaryDirectoryPath A path pointing to the directory of the primary entry point.\n * @param primary The primary entry point.\n */\nfunction secondaryEntryPoint(\n primaryDirectoryPath: string,\n primary: NgEntryPoint,\n { packageJson, ngPackageJson, basePath }: UserPackage,\n): NgEntryPoint {\n if (path.resolve(basePath) === path.resolve(primaryDirectoryPath)) {\n log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);\n throw new Error(`Secondary entry point is already a primary.`);\n }\n\n const relativeSourcePath = path.relative(primaryDirectoryPath, basePath);\n const secondaryModuleId = ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);\n\n return new NgEntryPoint(packageJson, ngPackageJson, basePath, {\n moduleId: secondaryModuleId,\n primaryDestinationPath: primary.destinationPath,\n destinationPath: path.join(primary.destinationPath, relativeSourcePath),\n });\n}\n\nexport async function discoverPackages({ project }: { project: string }): Promise<NgPackage> {\n project = path.isAbsolute(project) ? project : path.resolve(project);\n\n const { packageJson, ngPackageJson, basePath } = await resolveUserPackage(project);\n const primary = new NgEntryPoint(packageJson, ngPackageJson, basePath);\n log.debug(`Found primary entry point: ${primary.moduleId}`);\n\n const folderPaths = await findSecondaryPackagesPaths(basePath, primary.$get('dest'));\n const secondaries: NgEntryPoint[] = [];\n\n for (const folderPath of folderPaths) {\n const secondaryPackage = await resolveUserPackage(folderPath, true);\n if (secondaryPackage) {\n secondaries.push(secondaryEntryPoint(basePath, primary, secondaryPackage));\n }\n }\n\n if (secondaries.length > 0) {\n log.debug(`Found secondary entry points: ${secondaries.map(e => e.moduleId).join(', ')}`);\n }\n\n return new NgPackage(basePath, primary, secondaries);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"discover-packages.js","sourceRoot":"","sources":["../../../src/lib/ng-package/discover-packages.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2BAA2B;AAC3B,uCAAiD;AACjD,6BAA6B;AAC7B,oCAAoC;AACpC,wCAA+C;AAC/C,2DAAyD;AACzD,uCAAsC;AACtC,wCAA0C;AAE1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAWp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,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACrF,MAAM,WAAW,GAAmB,EAAE,CAAC;QAEvC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;YACpC,MAAM,gBAAgB,GAAG,MAAM,kBAAkB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YACpE,IAAI,gBAAgB,EAAE;gBACpB,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC;aAClE;SACF;QAED,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,GAAG,CAAC,KAAK,CAAC,iCAAiC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAC3F;QAED,OAAO,IAAI,mBAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;IACvD,CAAC;CAAA;AAtBD,4CAsBC","sourcesContent":["import * as ajv from 'ajv';\nimport { pathExistsSync, lstat } from 'fs-extra';\nimport * as path from 'path';\nimport * as log from '../utils/log';\nimport { ensureUnixPath } from '../utils/path';\nimport { NgEntryPoint } from './entry-point/entry-point';\nimport { NgPackage } from './package';\nimport { globFiles } from '../utils/glob';\n\nconst ngPackageSchemaJson = require('../../ng-package.schema.json');\n\ninterface UserPackage {\n /** Values from the `package.json` file of this user package. */\n packageJson: Record<string, any>;\n /** NgPackageConfig for this user package. */\n ngPackageJson: Record<string, any>;\n /** Absolute directory path of this user package. */\n basePath: string;\n}\n\nfunction formatSchemaValidationErrors(errors: ajv.ErrorObject[]): string {\n return errors\n .map(err => {\n let message = `Data path ${JSON.stringify(err.dataPath)} ${err.message}`;\n if (err.keyword === 'additionalProperties') {\n message += ` (${(err.params as any).additionalProperty})`;\n }\n\n return message + '.';\n })\n .join('\\n');\n}\n\n/**\n * Resolves a user's package by testing for 'package.json', 'ng-package.json', or 'ng-package.js'.\n *\n * @param folderPathOrFilePath A path pointing either to a file or a directory\n * @param isSecondary A boolean determining if this is a secondary package\n * @return The user's package\n */\nasync function resolveUserPackage(folderPathOrFilePath: string, isSecondary = false): Promise<UserPackage | undefined> {\n const readConfigFile = async (filePath: string) => (pathExistsSync(filePath) ? import(filePath) : undefined);\n const fullPath = path.resolve(folderPathOrFilePath);\n const pathStats = await lstat(fullPath);\n const basePath = pathStats.isDirectory() ? fullPath : path.dirname(fullPath);\n const packageJson: unknown = await readConfigFile(path.join(basePath, 'package.json'));\n\n if (!packageJson && !isSecondary) {\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath} as 'package.json' was not found.`);\n }\n\n if (packageJson && typeof packageJson !== 'object') {\n throw new Error(`Invalid 'package.json' at ${folderPathOrFilePath}.`);\n }\n\n let ngPackageJson: unknown;\n if (packageJson && packageJson['ngPackage']) {\n // Read `ngPackage` from `package.json`\n ngPackageJson = { ...packageJson['ngPackage'] };\n } else if (pathStats.isDirectory()) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.json'));\n if (!ngPackageJson) {\n ngPackageJson = await readConfigFile(path.join(basePath, 'ng-package.js'));\n }\n } else {\n ngPackageJson = await readConfigFile(fullPath);\n }\n\n if (ngPackageJson) {\n const _ajv = ajv({\n schemaId: 'auto',\n useDefaults: true,\n jsonPointers: true,\n });\n\n const validate = _ajv.compile(ngPackageSchemaJson);\n // Add handler for x-deprecated fields\n _ajv.addKeyword('x-deprecated', {\n validate: (schema, _data, _parentSchema, _dataPath, _parentDataObject, propertyName) => {\n if (schema) {\n log.warn(`Option \"${propertyName}\" is deprecated${typeof schema == 'string' ? ': ' + schema : '.'}`);\n }\n\n return true;\n },\n errors: false,\n });\n\n const isValid = validate(ngPackageJson);\n if (!isValid) {\n throw new Error(\n `Configuration doesn\\'t match the required schema.\\n${formatSchemaValidationErrors(validate.errors)}`,\n );\n }\n\n return {\n basePath,\n packageJson: packageJson || {},\n ngPackageJson: ngPackageJson as Record<string, any>,\n };\n }\n\n if (pathStats.isDirectory()) {\n // return even if it's undefined and use defaults when it's not a file\n return undefined;\n }\n\n if (pathStats.isFile()) {\n // a project file was specified but was in valid\n if (path.basename(folderPathOrFilePath) === 'package.json') {\n throw new Error(`Cannot read a package from 'package.json' without 'ngPackage' property.`);\n }\n\n throw new Error(`Trying to read a package from unsupported file extension. Path: ${folderPathOrFilePath}`);\n }\n\n throw new Error(`Cannot discover package sources at ${folderPathOrFilePath}`);\n}\n\n/**\n * Scans `directoryPath` and sub-folders, looking for `package.json` files.\n * Similar to `find ${directoryPath} --name package.json --exec dirname {}`.\n *\n * @param directoryPath Path pointing to a directory\n * @param excludeFolder A sub-folder of `directoryPath` that is excluded from search results.\n */\nasync function findSecondaryPackagesPaths(directoryPath: string, excludeFolder: string): Promise<string[]> {\n const ignore = [\n '**/node_modules/**',\n '**/.git/**',\n `${path.resolve(directoryPath, excludeFolder)}/**`,\n `${directoryPath}/package.json`,\n `${directoryPath}/ng-package.json`,\n ];\n\n const filePaths = await globFiles(`${directoryPath}/**/{package,ng-package}.json`, {\n ignore,\n cwd: directoryPath,\n });\n\n return filePaths.map(path.dirname);\n}\n\n/**\n * Reads a secondary entry point from it's package file.\n *\n * @param primary The primary entry point.\n * @param userPackage The user package for the secondary entry point.\n */\nfunction secondaryEntryPoint(primary: NgEntryPoint, userPackage: UserPackage): NgEntryPoint {\n const { packageJson, ngPackageJson, basePath } = userPackage;\n if (path.resolve(basePath) === path.resolve(primary.basePath)) {\n log.error(`Cannot read secondary entry point. It's already a primary entry point. Path: ${basePath}`);\n throw new Error(`Secondary entry point is already a primary.`);\n }\n\n const relativeSourcePath = path.relative(primary.basePath, basePath);\n const secondaryModuleId = ensureUnixPath(`${primary.moduleId}/${relativeSourcePath}`);\n\n return new NgEntryPoint(packageJson, ngPackageJson, basePath, {\n moduleId: secondaryModuleId,\n primaryDestinationPath: primary.destinationPath,\n destinationPath: path.join(primary.destinationPath, relativeSourcePath),\n });\n}\n\nexport async function discoverPackages({ project }: { project: string }): Promise<NgPackage> {\n project = path.isAbsolute(project) ? project : path.resolve(project);\n\n const { packageJson, ngPackageJson, basePath } = await resolveUserPackage(project);\n const primary = new NgEntryPoint(packageJson, ngPackageJson, basePath);\n log.debug(`Found primary entry point: ${primary.moduleId}`);\n\n const folderPaths = await findSecondaryPackagesPaths(basePath, primary.$get('dest'));\n const secondaries: NgEntryPoint[] = [];\n\n for (const folderPath of folderPaths) {\n const secondaryPackage = await resolveUserPackage(folderPath, true);\n if (secondaryPackage) {\n secondaries.push(secondaryEntryPoint(primary, secondaryPackage));\n }\n }\n\n if (secondaries.length > 0) {\n log.debug(`Found secondary entry points: ${secondaries.map(e => e.moduleId).join(', ')}`);\n }\n\n return new NgPackage(basePath, primary, secondaries);\n}\n"]}
|
|
@@ -12,7 +12,7 @@ export interface DestinationFiles {
|
|
|
12
12
|
esm2015: string;
|
|
13
13
|
/** Absolute path of this entry point `UMD` bundle */
|
|
14
14
|
umd: string;
|
|
15
|
-
/** Absolute path of this entry point `UMD`
|
|
15
|
+
/** Absolute path of this entry point `UMD` minified bundle */
|
|
16
16
|
umdMinified: string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -46,21 +46,21 @@ export interface DestinationFiles {
|
|
|
46
46
|
*/
|
|
47
47
|
export declare class NgEntryPoint {
|
|
48
48
|
/** Values from the `package.json` file of this entry point. */
|
|
49
|
-
readonly packageJson: any
|
|
49
|
+
readonly packageJson: Record<string, any>;
|
|
50
50
|
/** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */
|
|
51
51
|
readonly ngPackageJson: NgPackageConfig;
|
|
52
52
|
/** Absolute directory path of this entry point's `package.json` location. */
|
|
53
53
|
readonly basePath: string;
|
|
54
|
-
/** XX: additional auto-configured data passed for
|
|
54
|
+
/** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */
|
|
55
55
|
private readonly secondaryData?;
|
|
56
56
|
constructor(
|
|
57
57
|
/** Values from the `package.json` file of this entry point. */
|
|
58
|
-
packageJson:
|
|
58
|
+
packageJson: Record<string, any>,
|
|
59
59
|
/** Values from either the `ngPackage` option (from `package.json`) or values from `ng-package.json`. */
|
|
60
60
|
ngPackageJson: NgPackageConfig,
|
|
61
61
|
/** Absolute directory path of this entry point's `package.json` location. */
|
|
62
62
|
basePath: string,
|
|
63
|
-
/** XX: additional auto-configured data passed for
|
|
63
|
+
/** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */
|
|
64
64
|
secondaryData?: {
|
|
65
65
|
[key: string]: any;
|
|
66
66
|
});
|
|
@@ -39,7 +39,7 @@ class NgEntryPoint {
|
|
|
39
39
|
ngPackageJson,
|
|
40
40
|
/** Absolute directory path of this entry point's `package.json` location. */
|
|
41
41
|
basePath,
|
|
42
|
-
/** XX: additional auto-configured data passed for
|
|
42
|
+
/** XX: additional auto-configured data passed for secondary entry point's. Needs better docs. */
|
|
43
43
|
secondaryData) {
|
|
44
44
|
this.packageJson = packageJson;
|
|
45
45
|
this.ngPackageJson = ngPackageJson;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAoB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,YAAY;IACvB;IACE,+DAA+D;IAC/C,WAAgB;IAChC,wGAAwG;IACxF,aAA8B;IAC9C,6EAA6E;IAC7D,QAAgB;IAChC,gGAAgG;IAC/E,aAAsC;QANvC,gBAAW,GAAX,WAAW,CAAK;QAEhB,kBAAa,GAAb,aAAa,CAAiB;QAE9B,aAAQ,GAAR,QAAQ,CAAQ;QAEf,kBAAa,GAAb,aAAa,CAAyB;IACtD,CAAC;IAEJ,sEAAsE;IACtE,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,C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,QAAQ;QACjB,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;SACpC;aAAM;YACL,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACjC;IACH,CAAC;IAED;;;;OAIG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC;IACjD,CAAC;IAEO,eAAe,CAAC,YAAoB,GAAG;QAC7C,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;IAED;;;;;;OAMG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC;IAClD,CAAC;CACF;AA1ID,oCA0IC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\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 `metadata` */\n metadata: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2015` module */\n esm2015: string;\n /** Absolute path of this entry point `UMD` bundle */\n umd: string;\n /** Absolute path of this entry point `UMD` Minifief bundle */\n umdMinified: 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: 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 scondary 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 metadata: pathJoinWithDest(secondaryDir, `${flatModuleFile}.metadata.json`),\n declarations: pathJoinWithDest(secondaryDir, `${flatModuleFile}.d.ts`),\n esm2015: pathJoinWithDest('esm2015', secondaryDir, `${flatModuleFile}.js`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.js`),\n umd: pathJoinWithDest('bundles', `${flatModuleFile}.umd.js`),\n umdMinified: pathJoinWithDest('bundles', `${flatModuleFile}.umd.min.js`),\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' && value.hasOwnProperty(key)) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n return this.$get('lib.entryFile');\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get umdModuleIds(): { [key: string]: string } {\n return this.$get('lib.umdModuleIds');\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 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 /**\n * The UMD module ID registers a module on the old-fashioned JavaScript global scope.\n * Used by UMD bundles only.\n * Example: `@my/foo/bar` registers as `global['my']['foo']['bar']`.\n */\n public get umdId(): string {\n return this.$get('lib.umdId') || this.flattenModuleId();\n }\n\n /**\n * The AMD ID reflects a named module that is distributed in the UMD bundles.\n * @link http://requirejs.org/docs/whyamd.html#namedmodules\n */\n public get amdId(): string {\n return this.$get('lib.amdId') || this.moduleId;\n }\n\n private flattenModuleId(separator: string = '.') {\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 /**\n * Enables the `\"sideEffects\": false` flag in `package.json`.\n * The flag is enabled and set to `false` by default which results in more aggressive optimizations applied by webpack v4 builds consuming the library.\n * To override the default behaviour, you need to set `\"sideEffects\": true` explicitly in your `package.json`.\n *\n * @link https://github.com/webpack/webpack/tree/master/examples/side-effects\n */\n public get sideEffects(): boolean | string[] {\n return this.packageJson['sideEffects'] || false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"entry-point.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAoB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAyB;IACtD,CAAC;IAEJ,sEAAsE;IACtE,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,iDAAi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ACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;SACpC;aAAM;YACL,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACjC;IACH,CAAC;IAED;;;;OAIG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC;IACjD,CAAC;IAEO,eAAe,CAAC,YAAoB,GAAG;QAC7C,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;IAED;;;;;;OAMG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC;IAClD,CAAC;CACF;AA1ID,oCA0IC","sourcesContent":["import * as path from 'path';\nimport { NgPackageConfig } from '../../../ng-package.schema';\nimport { CssUrl } from '../../styles/stylesheet-processor';\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 `metadata` */\n metadata: string;\n /** Absolute path of this entry point `FESM2015` module */\n fesm2015: string;\n /** Absolute path of this entry point `ESM2015` module */\n esm2015: string;\n /** Absolute path of this entry point `UMD` bundle */\n umd: string;\n /** Absolute path of this entry point `UMD` minified bundle */\n umdMinified: 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 metadata: pathJoinWithDest(secondaryDir, `${flatModuleFile}.metadata.json`),\n declarations: pathJoinWithDest(secondaryDir, `${flatModuleFile}.d.ts`),\n esm2015: pathJoinWithDest('esm2015', secondaryDir, `${flatModuleFile}.js`),\n fesm2015: pathJoinWithDest('fesm2015', `${flatModuleFile}.js`),\n umd: pathJoinWithDest('bundles', `${flatModuleFile}.umd.js`),\n umdMinified: pathJoinWithDest('bundles', `${flatModuleFile}.umd.min.js`),\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' && value.hasOwnProperty(key)) {\n value = value[key];\n } else {\n return undefined;\n }\n }\n\n return value;\n }\n\n public get entryFile(): string {\n return this.$get('lib.entryFile');\n }\n\n public get cssUrl(): CssUrl {\n return this.$get('lib.cssUrl');\n }\n\n public get umdModuleIds(): { [key: string]: string } {\n return this.$get('lib.umdModuleIds');\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 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 /**\n * The UMD module ID registers a module on the old-fashioned JavaScript global scope.\n * Used by UMD bundles only.\n * Example: `@my/foo/bar` registers as `global['my']['foo']['bar']`.\n */\n public get umdId(): string {\n return this.$get('lib.umdId') || this.flattenModuleId();\n }\n\n /**\n * The AMD ID reflects a named module that is distributed in the UMD bundles.\n * @link http://requirejs.org/docs/whyamd.html#namedmodules\n */\n public get amdId(): string {\n return this.$get('lib.amdId') || this.moduleId;\n }\n\n private flattenModuleId(separator: string = '.') {\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 /**\n * Enables the `\"sideEffects\": false` flag in `package.json`.\n * The flag is enabled and set to `false` by default which results in more aggressive optimizations applied by webpack v4 builds consuming the library.\n * To override the default behaviour, you need to set `\"sideEffects\": true` explicitly in your `package.json`.\n *\n * @link https://github.com/webpack/webpack/tree/master/examples/side-effects\n */\n public get sideEffects(): boolean | string[] {\n return this.packageJson['sideEffects'] || false;\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ import { Transform } from '../../graph/transform';
|
|
|
23
23
|
* Sub-transformations are passed to this factory function as arguments.
|
|
24
24
|
*
|
|
25
25
|
* @param compileTs Transformation compiling typescript sources to ES2015 modules.
|
|
26
|
-
* @param writeBundles Transformation flattening ES2015 modules to ESM2015,
|
|
26
|
+
* @param writeBundles Transformation flattening ES2015 modules to ESM2015, UMD, and minified UMD.
|
|
27
27
|
* @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).
|
|
28
28
|
*/
|
|
29
29
|
export declare const entryPointTransformFactory: (compileTs: Transform, writeBundles: Transform, writePackage: Transform) => Transform;
|
|
@@ -40,7 +40,7 @@ const nodes_1 = require("../nodes");
|
|
|
40
40
|
* Sub-transformations are passed to this factory function as arguments.
|
|
41
41
|
*
|
|
42
42
|
* @param compileTs Transformation compiling typescript sources to ES2015 modules.
|
|
43
|
-
* @param writeBundles Transformation flattening ES2015 modules to ESM2015,
|
|
43
|
+
* @param writeBundles Transformation flattening ES2015 modules to ESM2015, UMD, and minified UMD.
|
|
44
44
|
* @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).
|
|
45
45
|
*/
|
|
46
46
|
exports.entryPointTransformFactory = (compileTs, writeBundles, writePackage) => rxjs_1.pipe(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA4B;AAC5B,2CAA8C;AAC9C,+CAAkD;AAClD,qDAAwE;AACxE,uCAAuC;AACvC,oCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,WAAI;AACF,+DAA+D;AAE/D,gCAAoB,CAAC,CAAO,KAAK,EAAE,EAAE;IACnC,4CAA4C;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,GAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,GAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAA,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,gCAAoB,CAAC,CAAO,KAAK,EAAE,EAAE;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAA,CAAC,CAGH,CAAC","sourcesContent":["import { pipe } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { isInProgress } from '../../graph/select';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport * as log from '../../utils/log';\nimport { byEntryPoint } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - bundleToUmd\n * - bundleToUmdMin\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, metadata, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2015 modules.\n * @param writeBundles Transformation flattening ES2015 modules to ESM2015,
|
|
1
|
+
{"version":3,"file":"entry-point.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/entry-point.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA4B;AAC5B,2CAA8C;AAC9C,+CAAkD;AAClD,qDAAwE;AACxE,uCAAuC;AACvC,oCAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACU,QAAA,0BAA0B,GAAG,CACxC,SAAoB,EACpB,YAAuB,EACvB,YAAuB,EACZ,EAAE,CACb,WAAI;AACF,+DAA+D;AAE/D,gCAAoB,CAAC,CAAO,KAAK,EAAE,EAAE;IACnC,4CAA4C;IAC5C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,GAAG,CAAC,kFAAkF,CAAC,CAAC;IAC5F,GAAG,CAAC,GAAG,CAAC,yBAAyB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IACzE,GAAG,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAC;AAC5F,CAAC,CAAA,CAAC;AACF,iCAAiC;AACjC,SAAS;AACT,+CAA+C;AAC/C,YAAY,EACZ,YAAY,EACZ,gCAAoB,CAAC,CAAO,KAAK,EAAE,EAAE;IACnC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,oBAAY,EAAE,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,CAAC;IAChE,UAAU,CAAC,KAAK,GAAG,iBAAU,CAAC;AAChC,CAAC,CAAA,CAAC,CAGH,CAAC","sourcesContent":["import { pipe } from 'rxjs';\nimport { STATE_DONE } from '../../graph/node';\nimport { isInProgress } from '../../graph/select';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport * as log from '../../utils/log';\nimport { byEntryPoint } from '../nodes';\n\n/**\n * A re-write of the `transformSources()` script that transforms an entry point from sources to distributable format.\n *\n * Sources are TypeScript source files accompanied by HTML templates and xCSS stylesheets.\n * See the Angular Package Format for a detailed description of what the distributables include.\n *\n * The current transformation pipeline can be thought of as:\n *\n * - clean\n * - compileTs\n * - downlevelTs\n * - writeBundles\n * - bundleToFesm15\n * - bundleToUmd\n * - bundleToUmdMin\n * - relocateSourceMaps\n * - writePackage\n * - copyStagedFiles (bundles, esm, dts, metadata, sourcemaps)\n * - writePackageJson\n *\n * The transformation pipeline is pluggable through the dependency injection system.\n * Sub-transformations are passed to this factory function as arguments.\n *\n * @param compileTs Transformation compiling typescript sources to ES2015 modules.\n * @param writeBundles Transformation flattening ES2015 modules to ESM2015, UMD, and minified UMD.\n * @param writePackage Transformation writing a distribution-ready `package.json` (for publishing to npm registry).\n */\nexport const entryPointTransformFactory = (\n compileTs: Transform,\n writeBundles: Transform,\n writePackage: Transform,\n): Transform =>\n pipe(\n //tap(() => log.info(`Building from sources for entry point`)),\n\n transformFromPromise(async (graph) => {\n // Peek the first entry point from the graph\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n log.msg('\\n------------------------------------------------------------------------------');\n log.msg(`Building entry point '${entryPoint.data.entryPoint.moduleId}'`);\n log.msg('------------------------------------------------------------------------------');\n }),\n // TypeScript sources compilation\n compileTs,\n // After TypeScript: bundling and write package\n writeBundles,\n writePackage,\n transformFromPromise(async (graph) => {\n const entryPoint = graph.find(byEntryPoint().and(isInProgress));\n entryPoint.state = STATE_DONE;\n }),\n\n //tap(() => log.info(`Built.`))\n );\n"]}
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.initTsConfigTransformFactory = void 0;
|
|
13
|
-
const
|
|
13
|
+
const color_1 = require("../../utils/color");
|
|
14
14
|
const transform_1 = require("../../graph/transform");
|
|
15
15
|
const nodes_1 = require("../nodes");
|
|
16
16
|
const tsconfig_1 = require("../../ts/tsconfig");
|
|
@@ -24,7 +24,7 @@ exports.initTsConfigTransformFactory = (defaultTsConfig) => transform_1.transfor
|
|
|
24
24
|
'It is not recommended to publish Ivy libraries to NPM repositories.\n' +
|
|
25
25
|
'Read more here: https://v9.angular.io/guide/ivy#maintaining-library-compatibility\n' +
|
|
26
26
|
'******************************************************************************';
|
|
27
|
-
log_1.msg(
|
|
27
|
+
log_1.msg(color_1.colors.yellow(ivyMsg));
|
|
28
28
|
}
|
|
29
29
|
return graph;
|
|
30
30
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-tsconfig.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/init-tsconfig.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA
|
|
1
|
+
{"version":3,"file":"init-tsconfig.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/init-tsconfig.transform.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6CAA2C;AAC3C,qDAAwE;AACxE,oCAAwD;AACxD,gDAAuD;AACvD,yCAAsC;AAEzB,QAAA,4BAA4B,GAAG,CAAC,eAAoC,EAAa,EAAE,CAC9F,gCAAoB,CAAC,CAAM,KAAK,EAAC,EAAE;IACjC,2CAA2C;IAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAY,CAAqB,CAAC;IACnE,6BAAkB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAEjD,IAAI,eAAe,CAAC,OAAO,CAAC,SAAS,EAAE;QACrC,MAAM,MAAM,GACV,kFAAkF;YAClF,uEAAuE;YACvE,qFAAqF;YACrF,gFAAgF,CAAC;QAEnF,SAAG,CAAC,cAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;KAC5B;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC,CAAC","sourcesContent":["import { ParsedConfiguration } from '@angular/compiler-cli';\nimport { colors } from '../../utils/color';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { isEntryPoint, EntryPointNode } from '../nodes';\nimport { initializeTsConfig } from '../../ts/tsconfig';\nimport { msg } from '../../utils/log';\n\nexport const initTsConfigTransformFactory = (defaultTsConfig: ParsedConfiguration): Transform =>\n transformFromPromise(async graph => {\n // Initialize tsconfig for each entry point\n const entryPoints = graph.filter(isEntryPoint) as EntryPointNode[];\n initializeTsConfig(defaultTsConfig, entryPoints);\n\n if (defaultTsConfig.options.enableIvy) {\n const ivyMsg =\n '******************************************************************************\\n' +\n 'It is not recommended to publish Ivy libraries to NPM repositories.\\n' +\n 'Read more here: https://v9.angular.io/guide/ivy#maintaining-library-compatibility\\n' +\n '******************************************************************************';\n\n msg(colors.yellow(ivyMsg));\n }\n\n return graph;\n });\n"]}
|