ng-packagr 10.0.4 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
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.0](https://github.com/ng-packagr/ng-packagr/compare/v10.0.4...v10.1.0) (2020-08-27)
6
+
7
+
8
+ ### Features
9
+
10
+ * add support for TypeScript 4 ([eb8b0c2](https://github.com/ng-packagr/ng-packagr/commit/eb8b0c2553aa1847f4ab42f29a1a25e67f644d29))
11
+ * show warning on deprecated option usage ([551a4d9](https://github.com/ng-packagr/ng-packagr/commit/551a4d9a866a8c337189f807d755856b995ffc9b))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * update commander to version ^6.0.0 ([ec736e5](https://github.com/ng-packagr/ng-packagr/commit/ec736e5df6978be79dca236683936941f349a8e5))
17
+
18
+
19
+ ### Performance
20
+
21
+ * cache normalized paths ([92f68e3](https://github.com/ng-packagr/ng-packagr/commit/92f68e3f09f66c990413e09cda5d742ad00c5b7f))
22
+
5
23
  ### [10.0.4](https://github.com/ng-packagr/ng-packagr/compare/v10.0.3...v10.0.4) (2020-08-13)
6
24
 
7
25
 
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,kDAAkD;AAClD,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,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;AAC7C,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAEjC,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 updateNotifier from 'update-notifier';\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 .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;\nupdateNotifier({ pkg }).notify();\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 }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,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"]}
@@ -68,8 +68,19 @@ function resolveUserPackage(folderPathOrFilePath, isSecondary = false) {
68
68
  const _ajv = ajv({
69
69
  schemaId: 'auto',
70
70
  useDefaults: true,
71
+ jsonPointers: true,
71
72
  });
72
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
+ });
73
84
  const isValid = validate(ngPackageJson);
74
85
  if (!isValid) {
75
86
  throw new Error(`Configuration doesn\'t match the required schema.\n${formatSchemaValidationErrors(validate.errors)}`);
@@ -1 +1 @@
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;AAWpE,SAAS,4BAA4B,CAAC,MAAyB;IAC7D,OAAO,MAAM;SACV,GAAG,CAAC,GAAG,CAAC,EAAE;QACT,IAAI,OAAO,GAAG,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACzE,IAAI,GAAG,CAAC,OAAO,KAAK,sBAAsB,EAAE;YAC1C,OAAO,IAAI,KAAM,GAAG,CAAC,MAAc,CAAC,kBAAkB,GAAG,CAAC;SAC3D;QAED,OAAO,OAAO,GAAG,GAAG,CAAC;IACvB,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAe,kBAAkB,CAAC,oBAA4B,EAAE,WAAW,GAAG,KAAK;;QACjF,MAAM,cAAc,GAAG,CAAO,QAAgB,EAAE,EAAE,gDAAC,OAAA,CAAC,yBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,sCAAQ,QAAQ,GAAE,CAAC,CAAC,SAAS,CAAC,CAAA,GAAA,CAAC;QAC7G,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,MAAM,gBAAK,C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AAE,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 });\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: 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(\n primary: NgEntryPoint,\n userPackage: UserPackage,\n): 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"]}
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;AAWpE,SAAS,4BAA4B,CAAC,MAAyB;IAC7D,OAAO,MAAM;SACV,GAAG,CAAC,GAAG,CAAC,EAAE;QACT,IAAI,OAAO,GAAG,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QACzE,IAAI,GAAG,CAAC,OAAO,KAAK,sBAAsB,EAAE;YAC1C,OAAO,IAAI,KAAM,GAAG,CAAC,MAAc,CAAC,kBAAkB,GAAG,CAAC;SAC3D;QAED,OAAO,OAAO,GAAG,GAAG,CAAC;IACvB,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAe,kBAAkB,CAAC,oBAA4B,EAAE,WAAW,GAAG,KAAK;;QACjF,MAAM,cAAc,GAAG,CAAO,QAAgB,EAAE,EAAE,gDAAC,OAAA,CAAC,yBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,sCAAQ,QAAQ,GAAE,CAAC,CAA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A;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"]}
@@ -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, ESM5, UMD, and minified UMD.
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, ESM5, UMD, and minified UMD.
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, ESM5, 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"]}
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"]}
package/lib/utils/path.js CHANGED
@@ -2,13 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureUnixPath = void 0;
4
4
  const nodePath = require("path");
5
+ const PATH_REGEXP = new RegExp('\\' + nodePath.win32.sep, 'g');
6
+ const ensureUnixPathCache = new Map();
5
7
  exports.ensureUnixPath = (path) => {
6
8
  if (!path) {
7
9
  return null;
8
10
  }
11
+ const cachePath = ensureUnixPathCache.get(path);
12
+ if (cachePath) {
13
+ return cachePath;
14
+ }
9
15
  // we use a regex instead of the character literal due to a bug in some versions of node.js
10
16
  // the path separator needs to be preceded by an escape character
11
- const regex = new RegExp('\\' + nodePath.win32.sep, 'g');
12
- return path.replace(regex, nodePath.posix.sep);
17
+ const normalizedPath = path.replace(PATH_REGEXP, nodePath.posix.sep);
18
+ ensureUnixPathCache.set(path, normalizedPath);
19
+ return normalizedPath;
13
20
  };
14
21
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/lib/utils/path.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEpB,QAAA,cAAc,GAAG,CAAC,IAAa,EAAiB,EAAE;IAC7D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,2FAA2F;IAC3F,iEAAiE;IACjE,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import * as nodePath from 'path';\n\nexport const ensureUnixPath = (path?: string): string | null => {\n if (!path) {\n return null;\n }\n\n // we use a regex instead of the character literal due to a bug in some versions of node.js\n // the path separator needs to be preceded by an escape character\n const regex = new RegExp('\\\\' + nodePath.win32.sep, 'g');\n return path.replace(regex, nodePath.posix.sep);\n};\n"]}
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/lib/utils/path.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAEjC,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC/D,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEzC,QAAA,cAAc,GAAG,CAAC,IAAa,EAAiB,EAAE;IAC7D,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,MAAM,SAAS,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,SAAS,EAAE;QACb,OAAO,SAAS,CAAC;KAClB;IAED,2FAA2F;IAC3F,iEAAiE;IACjE,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrE,mBAAmB,CAAC,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC9C,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import * as nodePath from 'path';\n\nconst PATH_REGEXP = new RegExp('\\\\' + nodePath.win32.sep, 'g');\nconst ensureUnixPathCache = new Map<string, string>();\n\nexport const ensureUnixPath = (path?: string): string | null => {\n if (!path) {\n return null;\n }\n\n const cachePath = ensureUnixPathCache.get(path);\n if (cachePath) {\n return cachePath;\n }\n\n // we use a regex instead of the character literal due to a bug in some versions of node.js\n // the path separator needs to be preceded by an escape character\n const normalizedPath = path.replace(PATH_REGEXP, nodePath.posix.sep);\n ensureUnixPathCache.set(path, normalizedPath);\n return normalizedPath;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-packagr",
3
- "version": "10.0.4",
3
+ "version": "10.1.0",
4
4
  "description": "Compile and package a TypeScript library to Angular Package Format",
5
5
  "keywords": [
6
6
  "angular",
@@ -35,7 +35,7 @@
35
35
  "browserslist": "^4.7.0",
36
36
  "chalk": "^4.0.0",
37
37
  "chokidar": "^3.2.1",
38
- "commander": "^5.0.0",
38
+ "commander": "^6.0.0",
39
39
  "cssnano-preset-default": "^4.0.7",
40
40
  "fs-extra": "^9.0.0",
41
41
  "glob": "^7.1.2",
@@ -51,14 +51,13 @@
51
51
  "rxjs": "^6.5.0",
52
52
  "sass": "^1.23.0",
53
53
  "stylus": "^0.54.7",
54
- "terser": "^5.0.0",
55
- "update-notifier": "^4.0.0"
54
+ "terser": "^5.0.0"
56
55
  },
57
56
  "peerDependencies": {
58
- "@angular/compiler": "^10.0.0-rc.3",
59
- "@angular/compiler-cli": "^10.0.0-rc.3",
57
+ "@angular/compiler": "^10.0.0",
58
+ "@angular/compiler-cli": "^10.0.0",
60
59
  "tslib": "^2.0.0",
61
- "typescript": ">=3.9 < 3.10"
60
+ "typescript": ">=3.9 < 4.1"
62
61
  },
63
62
  "husky": {
64
63
  "hooks": {
package/public_api.js CHANGED
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  /**