ng-packagr 11.2.0 → 11.2.4
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/cli/main.js +1 -4
- package/cli/main.js.map +1 -1
- package/lib/commands/version.command.js +2 -9
- package/lib/commands/version.command.js.map +1 -1
- package/lib/ng-package/entry-point/write-package.transform.js +6 -6
- package/lib/ng-package/entry-point/write-package.transform.js.map +1 -1
- package/lib/ng-package/package.d.ts +4 -0
- package/lib/ng-package/package.js +20 -5
- package/lib/ng-package/package.js.map +1 -1
- package/lib/styles/stylesheet-processor-worker.d.ts +4 -1
- package/lib/styles/stylesheet-processor-worker.js +6 -14
- package/lib/styles/stylesheet-processor-worker.js.map +1 -1
- package/lib/styles/stylesheet-processor.d.ts +2 -2
- package/lib/styles/stylesheet-processor.js +4 -6
- package/lib/styles/stylesheet-processor.js.map +1 -1
- package/lib/ts/cache-compiler-host.js +4 -0
- package/lib/ts/cache-compiler-host.js.map +1 -1
- package/ng-package.schema.d.ts +4 -0
- package/ng-package.schema.js.map +1 -1
- package/ng-package.schema.json +10 -2
- package/package.json +2 -2
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 readPkgUp = require("read-pkg-up");
|
|
7
6
|
const public_api_1 = require("../public_api");
|
|
8
7
|
const DEFAULT_PROJECT_PATH = path.resolve(process.cwd(), 'ng-package.json');
|
|
9
8
|
function parseProjectPath(parsed) {
|
|
@@ -16,10 +15,8 @@ program
|
|
|
16
15
|
.option('-w, --watch', 'Watch for file changes')
|
|
17
16
|
.option('-p, --project [path]', "Path to the 'ng-package.json' or 'package.json' file.", parseProjectPath, DEFAULT_PROJECT_PATH)
|
|
18
17
|
.option('-c, --config [config]', 'Path to a tsconfig file.', (value) => value ? path.resolve(value) : undefined);
|
|
19
|
-
const dir = path.dirname(module.filename);
|
|
20
|
-
const pkg = readPkgUp.sync({ cwd: dir }).pkg;
|
|
21
18
|
program.on('option:version', () => {
|
|
22
|
-
public_api_1.version(
|
|
19
|
+
public_api_1.version();
|
|
23
20
|
process.exit(0);
|
|
24
21
|
});
|
|
25
22
|
program.parse(process.argv);
|
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,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,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAChC,oBAAO,EAAE,CAAC;IACV,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 { build, execute, 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\nprogram.on('option:version', () => {\n version();\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"]}
|
|
@@ -9,17 +9,10 @@ const typescript_1 = require("typescript");
|
|
|
9
9
|
*
|
|
10
10
|
* @stable
|
|
11
11
|
*/
|
|
12
|
-
const version = (
|
|
13
|
-
|
|
14
|
-
try {
|
|
15
|
-
TSICKLE_VERSION = require('tsickle/package.json').version;
|
|
16
|
-
}
|
|
17
|
-
catch (_a) { }
|
|
18
|
-
const NG_PACKAGR_VERSION = pkg ? pkg.version : 'unknown';
|
|
19
|
-
console.log(`ng-packagr: ` + NG_PACKAGR_VERSION);
|
|
12
|
+
const version = () => {
|
|
13
|
+
console.log(`ng-packagr: ` + require('../../package.json').version);
|
|
20
14
|
console.log(`@angular/compiler: ` + compiler_1.VERSION.full);
|
|
21
15
|
console.log(`rollup: ` + rollup_1.VERSION);
|
|
22
|
-
console.log(`tsickle: ` + TSICKLE_VERSION);
|
|
23
16
|
console.log(`typescript: ` + typescript_1.version);
|
|
24
17
|
};
|
|
25
18
|
exports.version = version;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../../src/lib/commands/version.command.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AACnD,gDAAgE;AAChE,2CAAmD;AAGnD;;;;GAIG;AACI,MAAM,OAAO,GAAuB,
|
|
1
|
+
{"version":3,"file":"version.command.js","sourceRoot":"","sources":["../../../src/lib/commands/version.command.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AACnD,gDAAgE;AAChE,2CAAmD;AAGnD;;;;GAIG;AACI,MAAM,OAAO,GAAuB,GAAG,EAAE;IAC9C,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,kBAAgB,CAAC,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,gBAAc,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,yBAAyB,GAAG,oBAAU,CAAC,CAAC;AACtD,CAAC,CAAC;AALW,QAAA,OAAO,WAKlB","sourcesContent":["import { VERSION as ROLLUP_VERSION } from 'rollup';\nimport { VERSION as COMPILER_VERSION } from '@angular/compiler';\nimport { version as TS_VERSION } from 'typescript';\nimport { Command } from './command';\n\n/**\n * Prints version information.\n *\n * @stable\n */\nexport const version: Command<any, void> = () => {\n console.log(`ng-packagr: ` + require('../../package.json').version);\n console.log(`@angular/compiler: ` + COMPILER_VERSION.full);\n console.log(`rollup: ` + ROLLUP_VERSION);\n console.log(`typescript: ` + TS_VERSION);\n};\n"]}
|
|
@@ -146,9 +146,9 @@ async function writePackageJson(entryPoint, pkg, additionalProperties, isIvy, sp
|
|
|
146
146
|
}
|
|
147
147
|
// Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts
|
|
148
148
|
// in the node_modules folder of an application
|
|
149
|
-
const
|
|
149
|
+
const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));
|
|
150
150
|
try {
|
|
151
|
-
checkNonPeerDependencies(packageJson, 'dependencies',
|
|
151
|
+
checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);
|
|
152
152
|
}
|
|
153
153
|
catch (e) {
|
|
154
154
|
await fs_1.rimraf(entryPoint.destinationPath);
|
|
@@ -194,17 +194,17 @@ async function writePackageJson(entryPoint, pkg, additionalProperties, isIvy, sp
|
|
|
194
194
|
packageJson.name = entryPoint.moduleId;
|
|
195
195
|
await fs_1.writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));
|
|
196
196
|
}
|
|
197
|
-
function checkNonPeerDependencies(packageJson, property,
|
|
197
|
+
function checkNonPeerDependencies(packageJson, property, allowed, spinner) {
|
|
198
198
|
if (!packageJson[property]) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
for (const dep of Object.keys(packageJson[property])) {
|
|
202
|
-
if (
|
|
203
|
-
log.debug(`Dependency ${dep} is
|
|
202
|
+
if (allowed.some(regex => regex.test(dep))) {
|
|
203
|
+
log.debug(`Dependency ${dep} is allowed in '${property}'`);
|
|
204
204
|
}
|
|
205
205
|
else {
|
|
206
206
|
spinner.warn(color_1.colors.yellow(`Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} to 'peerDependencies' or remove it from '${property}'.`));
|
|
207
|
-
throw new Error(`Dependency ${dep} must be explicitly
|
|
207
|
+
throw new Error(`Dependency ${dep} must be explicitly allowed using the "allowedNonPeerDependencies" option.`);
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,2BAA2B;AAC3B,qDAAwE;AACxE,6CAA2C;AAG3C,2CAAkD;AAClD,uCAA2E;AAC3E,uCAAuC;AACvC,2CAA6C;AAC7C,oCAAmG;AACnG,2CAAwC;AAE3B,QAAA,qBAAqB,GAAc,gCAAoB,CAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjF,MAAM,OAAO,GAAG,GAAG,CAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAC,CAAC;IACxE,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC;IACrC,MAAM,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC;IAC7C,MAAM,WAAW,GAAa;QAC5B,UAAU;QACV,cAAc;QACd,cAAc;QACd,oBAAoB;QACpB,GAAG,SAAS,CAAC,IAAI,KAAK;KACvB,CAAC;IAEF,IAAI,SAAS,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE;QAClE,MAAM,UAAU,GAAa,EAAE,CAAC;QAEhC,kCAAkC;QAClC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAEhC,IAAI;YACF,KAAK,IAAI,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE;gBAClC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,G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AI,IAAI,6BAA6B,EAAE;QAChD,IAAI,IAAI,IAAI,WAAW,EAAE;YACvB,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,YAAY,IAAI,2BAA2B,CAAC,CAAC;SAC3D;KACF;IAED,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;IACvC,MAAM,cAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,wBAAwB,CAC/B,WAAoC,EACpC,QAAgB,EAChB,SAAmB,EACnB,OAAgB;IAEhB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO;KACR;IAED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE;QACpD,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE;YAC5C,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,uBAAuB,QAAQ,GAAG,CAAC,CAAC;SAChE;aAAM;YACL,OAAO,CAAC,IAAI,CACV,cAAM,CAAC,MAAM,CACX,mCAAmC,QAAQ,gDAAgD,GAAG,6CAA6C,QAAQ,IAAI,CACxJ,CACF,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,kCAAkC,CAAC,CAAC;SACtE;KACF;AACH,CAAC","sourcesContent":["import * as path from 'path';\nimport * as ora from 'ora';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { NgEntryPoint } from './entry-point';\nimport { NgPackage } from '../package';\nimport { ensureUnixPath } from '../../utils/path';\nimport { copyFile, exists, stat, rimraf, writeFile } from '../../utils/fs';\nimport * as log from '../../utils/log';\nimport { globFiles } from '../../utils/glob';\nimport { EntryPointNode, isEntryPointInProgress, isPackage, PackageNode, fileUrl } from '../nodes';\nimport { Node } from '../../graph/node';\n\nexport const writePackageTransform: Transform = transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n if (ngPackage.assets.length && !ngEntryPoint.isSecondaryEntryPoint) {\n const assetFiles: string[] = [];\n\n // COPY ASSET FILES TO DESTINATION\n spinner.start('Copying assets');\n\n try {\n for (let asset of ngPackage.assets) {\n asset = path.join(ngPackage.src, asset);\n\n if (await exists(asset)) {\n const stats = await stat(asset);\n if (stats.isFile()) {\n assetFiles.push(asset);\n continue;\n }\n\n if (stats.isDirectory()) {\n asset = path.join(asset, '**/*');\n }\n }\n\n const files = await globFiles(asset, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n });\n\n if (files.length) {\n assetFiles.push(...files);\n }\n }\n\n for (const file of assetFiles) {\n const relativePath = path.relative(ngPackage.src, file);\n const destination = path.resolve(ngPackage.dest, relativePath);\n const nodeUri = fileUrl(ensureUnixPath(file));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n entryPoint.dependsOn(node);\n await copyFile(file, destination);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n try {\n spinner.start('Writing package metadata');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const isIvy = !!entryPoint.data.tsConfig.options.enableIvy;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n main: relativeUnixFromDestPath(destinationFiles.umd),\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n esm2015: relativeUnixFromDestPath(destinationFiles.esm2015),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n // Ivy doesn't generate metadata files\n metadata: isIvy ? undefined : relativeUnixFromDestPath(destinationFiles.metadata),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.sideEffects,\n },\n isIvy,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n spinner.info(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n});\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] },\n isIvy: boolean,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n\n delete packageJson.peerDependencies.tslib;\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const whitelist = pkg.whitelistedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', whitelist, spinner);\n } catch (e) {\n await rimraf(entryPoint.destinationPath);\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (isIvy && !entryPoint.isSecondaryEntryPoint) {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n whitelist: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (whitelist.find(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is whitelisted in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly whitelisted.`);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write-package.transform.js","sourceRoot":"","sources":["../../../../src/lib/ng-package/entry-point/write-package.transform.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,2BAA2B;AAC3B,qDAAwE;AACxE,6CAA2C;AAG3C,2CAAkD;AAClD,uCAA2E;AAC3E,uCAAuC;AACvC,2CAA6C;AAC7C,oCAAmG;AACnG,2CAAwC;AAE3B,QAAA,qBAAqB,GAAc,gCAAoB,CAAC,KAAK,EAAC,KAAK,EAAC,EAAE;IACjF,MAAM,OAAO,GAAG,GAAG,CAAC;QAClB,UAAU,EAAE,KAAK;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,MAAM,UAAU,GAAmB,KAAK,CAAC,IAAI,CAAC,8BAAsB,EAAE,CAAC,CAAC;IACxE,MAAM,YAAY,GAAiB,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;IAC9D,MAAM,aAAa,GAAgB,KAAK,CAAC,IAAI,CAAC,iBAAS,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,aAAa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AAG,CAAC,CAAC,EAAE;YAC1C,GAAG,CAAC,KAAK,CAAC,cAAc,GAAG,mBAAmB,QAAQ,GAAG,CAAC,CAAC;SAC5D;aAAM;YACL,OAAO,CAAC,IAAI,CACV,cAAM,CAAC,MAAM,CACX,mCAAmC,QAAQ,gDAAgD,GAAG,6CAA6C,QAAQ,IAAI,CACxJ,CACF,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,4EAA4E,CAAC,CAAC;SAChH;KACF;AACH,CAAC","sourcesContent":["import * as path from 'path';\nimport * as ora from 'ora';\nimport { Transform, transformFromPromise } from '../../graph/transform';\nimport { colors } from '../../utils/color';\nimport { NgEntryPoint } from './entry-point';\nimport { NgPackage } from '../package';\nimport { ensureUnixPath } from '../../utils/path';\nimport { copyFile, exists, stat, rimraf, writeFile } from '../../utils/fs';\nimport * as log from '../../utils/log';\nimport { globFiles } from '../../utils/glob';\nimport { EntryPointNode, isEntryPointInProgress, isPackage, PackageNode, fileUrl } from '../nodes';\nimport { Node } from '../../graph/node';\n\nexport const writePackageTransform: Transform = transformFromPromise(async graph => {\n const spinner = ora({\n hideCursor: false,\n discardStdin: false,\n });\n const entryPoint: EntryPointNode = graph.find(isEntryPointInProgress());\n const ngEntryPoint: NgEntryPoint = entryPoint.data.entryPoint;\n const ngPackageNode: PackageNode = graph.find(isPackage);\n const ngPackage = ngPackageNode.data;\n const { destinationFiles } = entryPoint.data;\n const ignorePaths: string[] = [\n '.gitkeep',\n '**/.DS_Store',\n '**/Thumbs.db',\n '**/node_modules/**',\n `${ngPackage.dest}/**`,\n ];\n\n if (ngPackage.assets.length && !ngEntryPoint.isSecondaryEntryPoint) {\n const assetFiles: string[] = [];\n\n // COPY ASSET FILES TO DESTINATION\n spinner.start('Copying assets');\n\n try {\n for (let asset of ngPackage.assets) {\n asset = path.join(ngPackage.src, asset);\n\n if (await exists(asset)) {\n const stats = await stat(asset);\n if (stats.isFile()) {\n assetFiles.push(asset);\n continue;\n }\n\n if (stats.isDirectory()) {\n asset = path.join(asset, '**/*');\n }\n }\n\n const files = await globFiles(asset, {\n ignore: ignorePaths,\n cache: ngPackageNode.cache.globCache,\n dot: true,\n nodir: true,\n });\n\n if (files.length) {\n assetFiles.push(...files);\n }\n }\n\n for (const file of assetFiles) {\n const relativePath = path.relative(ngPackage.src, file);\n const destination = path.resolve(ngPackage.dest, relativePath);\n const nodeUri = fileUrl(ensureUnixPath(file));\n let node = graph.get(nodeUri);\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n entryPoint.dependsOn(node);\n await copyFile(file, destination);\n }\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n }\n\n // 6. WRITE PACKAGE.JSON\n try {\n spinner.start('Writing package metadata');\n const relativeUnixFromDestPath = (filePath: string) =>\n ensureUnixPath(path.relative(ngEntryPoint.destinationPath, filePath));\n\n const isIvy = !!entryPoint.data.tsConfig.options.enableIvy;\n\n await writePackageJson(\n ngEntryPoint,\n ngPackage,\n {\n main: relativeUnixFromDestPath(destinationFiles.umd),\n module: relativeUnixFromDestPath(destinationFiles.fesm2015),\n es2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n esm2015: relativeUnixFromDestPath(destinationFiles.esm2015),\n fesm2015: relativeUnixFromDestPath(destinationFiles.fesm2015),\n typings: relativeUnixFromDestPath(destinationFiles.declarations),\n // Ivy doesn't generate metadata files\n metadata: isIvy ? undefined : relativeUnixFromDestPath(destinationFiles.metadata),\n // webpack v4+ specific flag to enable advanced optimizations and code splitting\n sideEffects: ngEntryPoint.sideEffects,\n },\n isIvy,\n spinner,\n );\n } catch (error) {\n spinner.fail();\n throw error;\n }\n spinner.succeed();\n spinner.info(`Built ${ngEntryPoint.moduleId}`);\n\n return graph;\n});\n\n/**\n * Creates and writes a `package.json` file of the entry point used by the `node_module`\n * resolution strategies.\n *\n * #### Example\n *\n * A consumer of the entry point depends on it by `import {..} from '@my/module/id';`.\n * The module id `@my/module/id` will be resolved to the `package.json` file that is written by\n * this build step.\n * The properties `main`, `module`, `typings` (and so on) in the `package.json` point to the\n * flattened JavaScript bundles, type definitions, (...).\n *\n * @param entryPoint An entry point of an Angular package / library\n * @param additionalProperties Additional properties, e.g. binary artefacts (bundle files), to merge into `package.json`\n */\nasync function writePackageJson(\n entryPoint: NgEntryPoint,\n pkg: NgPackage,\n additionalProperties: { [key: string]: string | boolean | string[] },\n isIvy: boolean,\n spinner: ora.Ora,\n): Promise<void> {\n log.debug('Writing package.json');\n\n // set additional properties\n const packageJson = { ...entryPoint.packageJson, ...additionalProperties };\n\n // read tslib version from `@angular/compiler` so that our tslib\n // version at least matches that of angular if we use require('tslib').version\n // it will get what installed and not the minimum version nor if it is a `~` or `^`\n // this is only required for primary\n if (!entryPoint.isSecondaryEntryPoint) {\n if (!packageJson.peerDependencies?.tslib && !packageJson.dependencies?.tslib) {\n const {\n peerDependencies: angularPeerDependencies = {},\n dependencies: angularDependencies = {},\n } = require('@angular/compiler/package.json');\n const tsLibVersion = angularPeerDependencies.tslib || angularDependencies.tslib;\n\n if (tsLibVersion) {\n packageJson.dependencies = {\n ...packageJson.dependencies,\n tslib: tsLibVersion,\n };\n }\n } else if (packageJson.peerDependencies?.tslib) {\n spinner.warn(\n colors.yellow(\n `'tslib' is no longer recommended to be used as a 'peerDependencies'. Moving it to 'dependencies'.`,\n ),\n );\n packageJson.dependencies = {\n ...(packageJson.dependencies || {}),\n tslib: packageJson.peerDependencies.tslib,\n };\n\n delete packageJson.peerDependencies.tslib;\n }\n }\n\n // Verify non-peerDependencies as they can easily lead to duplicate installs or version conflicts\n // in the node_modules folder of an application\n const allowedList = pkg.allowedNonPeerDependencies.map(value => new RegExp(value));\n try {\n checkNonPeerDependencies(packageJson, 'dependencies', allowedList, spinner);\n } catch (e) {\n await rimraf(entryPoint.destinationPath);\n throw e;\n }\n\n // Removes scripts from package.json after build\n if (packageJson.scripts) {\n if (pkg.keepLifecycleScripts !== true) {\n spinner.info(`Removing scripts section in package.json as it's considered a potential security vulnerability.`);\n delete packageJson.scripts;\n } else {\n spinner.warn(\n colors.yellow(\n `You enabled keepLifecycleScripts explicitly. The scripts section in package.json will be published to npm.`,\n ),\n );\n }\n }\n\n if (isIvy && !entryPoint.isSecondaryEntryPoint) {\n const scripts = packageJson.scripts || (packageJson.scripts = {});\n scripts.prepublishOnly =\n 'node --eval \"console.error(\\'' +\n 'ERROR: Trying to publish a package that has been compiled by Ivy. This is not allowed.\\\\n' +\n 'Please delete and rebuild the package, without compiling with Ivy, before attempting to publish.\\\\n' +\n '\\')\" ' +\n '&& exit 1';\n }\n\n // keep the dist package.json clean\n // this will not throw if ngPackage field does not exist\n delete packageJson.ngPackage;\n\n const packageJsonPropertiesToDelete = [\n 'stylelint',\n 'prettier',\n 'browserslist',\n 'devDependencies',\n 'jest',\n 'workspaces',\n 'husky',\n ];\n\n for (const prop of packageJsonPropertiesToDelete) {\n if (prop in packageJson) {\n delete packageJson[prop];\n spinner.info(`Removing ${prop} section in package.json.`);\n }\n }\n\n packageJson.name = entryPoint.moduleId;\n await writeFile(path.join(entryPoint.destinationPath, 'package.json'), JSON.stringify(packageJson, undefined, 2));\n}\n\nfunction checkNonPeerDependencies(\n packageJson: Record<string, unknown>,\n property: string,\n allowed: RegExp[],\n spinner: ora.Ora,\n) {\n if (!packageJson[property]) {\n return;\n }\n\n for (const dep of Object.keys(packageJson[property])) {\n if (allowed.some(regex => regex.test(dep))) {\n log.debug(`Dependency ${dep} is allowed in '${property}'`);\n } else {\n spinner.warn(\n colors.yellow(\n `Distributing npm packages with '${property}' is not recommended. Please consider adding ${dep} to 'peerDependencies' or remove it from '${property}'.`,\n ),\n );\n throw new Error(`Dependency ${dep} must be explicitly allowed using the \"allowedNonPeerDependencies\" option.`);\n }\n }\n}\n"]}
|
|
@@ -57,7 +57,11 @@ export declare class NgPackage {
|
|
|
57
57
|
get dest(): string;
|
|
58
58
|
get keepLifecycleScripts(): boolean;
|
|
59
59
|
get assets(): string[];
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use allowedNonPeerDependencies instead.
|
|
62
|
+
*/
|
|
60
63
|
get whitelistedNonPeerDependencies(): string[];
|
|
64
|
+
get allowedNonPeerDependencies(): string[];
|
|
61
65
|
private absolutePathFromPrimary;
|
|
62
66
|
entryPoint(moduleId: string): NgEntryPoint;
|
|
63
67
|
}
|
|
@@ -65,12 +65,27 @@ class NgPackage {
|
|
|
65
65
|
get assets() {
|
|
66
66
|
return this.primary.$get('assets');
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use allowedNonPeerDependencies instead.
|
|
70
|
+
*/
|
|
68
71
|
get whitelistedNonPeerDependencies() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
return this.primary.$get('whitelistedNonPeerDependencies');
|
|
73
|
+
}
|
|
74
|
+
get allowedNonPeerDependencies() {
|
|
75
|
+
const alwaysInclude = ['tslib'];
|
|
76
|
+
// remove in the future, after deprecation phase
|
|
77
|
+
const deprecatedPropList = this.whitelistedNonPeerDependencies;
|
|
78
|
+
if (deprecatedPropList === null || deprecatedPropList === void 0 ? void 0 : deprecatedPropList.length) {
|
|
79
|
+
return Array.from(new Set([
|
|
80
|
+
...deprecatedPropList,
|
|
81
|
+
...alwaysInclude,
|
|
82
|
+
]));
|
|
83
|
+
}
|
|
84
|
+
const allowedNonPeerDependencies = this.primary.$get('allowedNonPeerDependencies');
|
|
85
|
+
return Array.from(new Set([
|
|
86
|
+
...allowedNonPeerDependencies,
|
|
87
|
+
...alwaysInclude,
|
|
88
|
+
]));
|
|
74
89
|
}
|
|
75
90
|
absolutePathFromPrimary(key) {
|
|
76
91
|
return path.resolve(this.basePath, this.primary.$get(key));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../../src/lib/ng-package/package.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;;;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,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAClG,CAAC;CACF;AA1ED,8BA0EC","sourcesContent":["import * as path from 'path';\nimport { NgEntryPoint } from './entry-point/entry-point';\n\n/**\n * A package being built. Quoting Angular Package Format, a package is:\n *\n * > the smallest set of files that are published to NPM and installed together, for example\n * > `@angular/core`. (..) The package is installed with `npm install @angular/core`.\n *\n * #### Package and Entry Points\n *\n * A package is composed of several (one or more) entry points.\n * A package must contain at least the primary entry point but can have many secondary entry\n * points.\n * The module ID of the primary entry point, e.g. `@angular/core`, matches the package name, e.g.\n * the package name is given to the command `npm install @angular/core`.\n * The source code files within a package are referenced by the entry points.\n *\n * #### Representation in the domain\n *\n * A _Package_ is reflected by `NgPackage`.\n * An _Entry Point_ is reflected by `NgEntryPoint`.\n * One `NgPackage` relates to one (or many) `NgEntryPoint`,\n * one `NgEntryPoint` relates to one `NgPackage`.\n *\n * #### Watch Out\n *\n * The user's configuration `ngPackage` suggests that it reflects a `NgPackage`.\n * However, the values given in the `lib` property reflect an `NgEntryPoint`.\n * In case the package contains only one entry point, `ngPackage.lib` reflects the primary entry\n * point.\n *\n * @link https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/edit#\n */\nexport class NgPackage {\n constructor(\n private readonly basePath: string,\n /**\n * A reference to the primary entry point.\n */\n public readonly primary: NgEntryPoint,\n /**\n * An array of secondary entry points.\n */\n public readonly secondaries: NgEntryPoint[] = [],\n ) {}\n\n /** Absolute path of the package's source folder, derived from the user's (primary) package location. */\n public get src(): string {\n return this.basePath;\n }\n\n /** Delete output path before build */\n public get deleteDestPath(): boolean {\n return this.primary.$get('deleteDestPath');\n }\n\n /** Absolute path of the package's destination directory. */\n public get dest(): string {\n return this.absolutePathFromPrimary('dest');\n }\n\n public get keepLifecycleScripts(): boolean {\n return this.primary.$get('keepLifecycleScripts') === true;\n }\n public get assets(): string[] {\n return this.primary.$get('assets');\n }\n\n /**\n * @deprecated Use allowedNonPeerDependencies instead.\n */\n public get whitelistedNonPeerDependencies(): string[] {\n return this.primary.$get('whitelistedNonPeerDependencies') as string[];\n }\n\n public get allowedNonPeerDependencies(): string[] {\n const alwaysInclude = ['tslib'];\n\n // remove in the future, after deprecation phase\n const deprecatedPropList = this.whitelistedNonPeerDependencies;\n\n if(deprecatedPropList?.length) {\n return Array.from(\n new Set([\n ...deprecatedPropList,\n ...alwaysInclude,\n ])\n );\n }\n\n const allowedNonPeerDependencies = this.primary.$get('allowedNonPeerDependencies') as string[];\n \n return Array.from(\n new Set([\n ...allowedNonPeerDependencies,\n ...alwaysInclude,\n ])\n );\n }\n\n private absolutePathFromPrimary(key: string) {\n return path.resolve(this.basePath, this.primary.$get(key));\n }\n\n public entryPoint(moduleId: string): NgEntryPoint {\n return [this.primary, ...this.secondaries].find(entryPoint => entryPoint.moduleId === moduleId);\n }\n}\n"]}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { WorkerOptions, WorkerResult } from './stylesheet-processor';
|
|
2
|
+
declare function processCss({ filePath, browserslistData, cssUrl, styleIncludePaths, basePath }: WorkerOptions): Promise<WorkerResult>;
|
|
3
|
+
declare const _default: () => typeof processCss;
|
|
4
|
+
export default _default;
|
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const autoprefixer = require("autoprefixer");
|
|
5
|
-
const nodeSassTildeImporter = require("node-sass-tilde-importer");
|
|
6
5
|
const postcss_1 = require("postcss");
|
|
7
6
|
const postcssUrl = require("postcss-url");
|
|
8
7
|
const cssnano = require("cssnano");
|
|
9
8
|
const stylesheet_processor_1 = require("./stylesheet-processor");
|
|
10
9
|
const fs_1 = require("../utils/fs");
|
|
11
|
-
async function processCss() {
|
|
12
|
-
const { filePath, browserslistData, cssUrl, styleIncludePaths, basePath } = JSON.parse(process.argv[2]);
|
|
10
|
+
async function processCss({ filePath, browserslistData, cssUrl, styleIncludePaths, basePath }) {
|
|
13
11
|
// Render pre-processor language (sass, styl, less)
|
|
14
12
|
const renderedCss = await renderCss(filePath, basePath, styleIncludePaths);
|
|
15
13
|
// Render postcss (autoprefixing and friends)
|
|
16
14
|
const result = await optimizeCss(filePath, renderedCss, browserslistData, cssUrl);
|
|
17
|
-
return
|
|
15
|
+
return {
|
|
18
16
|
css: result.css,
|
|
19
17
|
warnings: result.warnings().map(w => w.toString()),
|
|
20
|
-
}
|
|
18
|
+
};
|
|
21
19
|
}
|
|
22
20
|
async function renderCss(filePath, basePath, styleIncludePaths) {
|
|
23
21
|
const ext = path.extname(filePath);
|
|
@@ -46,7 +44,7 @@ async function renderCss(filePath, basePath, styleIncludePaths) {
|
|
|
46
44
|
file: filePath,
|
|
47
45
|
data: content,
|
|
48
46
|
indentedSyntax: '.sass' === ext,
|
|
49
|
-
importer:
|
|
47
|
+
importer: await Promise.resolve().then(() => require('node-sass-tilde-importer')),
|
|
50
48
|
includePaths: styleIncludePaths,
|
|
51
49
|
})
|
|
52
50
|
.css.toString();
|
|
@@ -100,12 +98,6 @@ function optimizeCss(filePath, css, browsers, cssUrl) {
|
|
|
100
98
|
to: filePath.replace(path.extname(filePath), '.css'),
|
|
101
99
|
});
|
|
102
100
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.then(result => process.stdout.write(result))
|
|
106
|
-
.catch(e => {
|
|
107
|
-
process.stderr.write(`${e}`);
|
|
108
|
-
process.exitCode = 1;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
101
|
+
// default export for sync-rpc to recognize the function https://github.com/ForbesLindesay/sync-rpc#workerjs
|
|
102
|
+
exports.default = () => processCss;
|
|
111
103
|
//# sourceMappingURL=stylesheet-processor-worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,6CAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"stylesheet-processor-worker.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor-worker.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,6CAA6C;AAC7C,qCAA8C;AAC9C,0CAA0C;AAC1C,mCAAmC;AAEnC,iEAA6E;AAC7E,oCAAuC;AAEvC,KAAK,UAAU,UAAU,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAiB;IAC1G,mDAAmD;IACnD,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAE3E,6CAA6C;IAC7C,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAElF,OAAO;QACL,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,QAAQ,EAAE,iBAA4B;IAC/E,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM,aAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEjD,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,OAAO,CAAC,CAAC;YACZ;;;;;;;;eAQG;YACH,IAAI,YAA6B,CAAC;YAClC,IAAI;gBACF,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,C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MAAM,cAAc,GAAG,EAAE,CAAC;IAE1B,IAAI,MAAM,KAAK,6BAAM,CAAC,IAAI,EAAE;QAC1B,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;KAClD;IAED,6DAA6D;IAC7D,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE5C,cAAc,CAAC,IAAI,CACjB,OAAO,CAAC;QACN,MAAM,EAAE;YACN,SAAS;YACT;gBACE,uGAAuG;gBACvG,IAAI,EAAE,KAAK;gBACX,8EAA8E;gBAC9E,IAAI,EAAE,KAAK;aACZ;SACF;KACF,CAAC,CACH,CAAC;IAEF,OAAO,iBAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,IAAI,EAAE,QAAQ;QACd,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrD,CAAC,CAAC;AACL,CAAC;AAED,4GAA4G;AAC5G,kBAAe,GAAG,EAAE,CAAC,UAAU,CAAA","sourcesContent":["import * as path from 'path';\nimport * as autoprefixer from 'autoprefixer';\nimport postcss, { LazyResult } from 'postcss';\nimport * as postcssUrl from 'postcss-url';\nimport * as cssnano from 'cssnano';\n\nimport { CssUrl, WorkerOptions, WorkerResult } from './stylesheet-processor';\nimport { readFile } from '../utils/fs';\n\nasync function processCss({ filePath, browserslistData, cssUrl, styleIncludePaths, basePath }: WorkerOptions): Promise<WorkerResult> {\n // Render pre-processor language (sass, styl, less)\n const renderedCss = await renderCss(filePath, basePath, styleIncludePaths);\n\n // Render postcss (autoprefixing and friends)\n const result = await optimizeCss(filePath, renderedCss, browserslistData, cssUrl);\n\n return {\n css: result.css,\n warnings: result.warnings().map(w => w.toString()),\n };\n}\n\nasync function renderCss(filePath: string, basePath, styleIncludePaths?: string[]): Promise<string> {\n const ext = path.extname(filePath);\n const content = await readFile(filePath, 'utf8');\n\n switch (ext) {\n case '.sass':\n case '.scss': {\n /*\n * Please be aware of the few differences in behaviour https://github.com/sass/dart-sass/blob/master/README.md#behavioral-differences-from-ruby-sass\n * By default `npm install` will install sass.\n * To use node-sass you need to use:\n * Npm:\n * `npm install node-sass --save-dev`\n * Yarn:\n * `yarn add node-sass --dev`\n */\n let sassCompiler: any | undefined;\n try {\n sassCompiler = require('node-sass'); // Check if node-sass is explicitly included.\n } catch {\n sassCompiler = await import('sass');\n }\n\n return sassCompiler\n .renderSync({\n file: filePath,\n data: content,\n indentedSyntax: '.sass' === ext,\n importer: await import('node-sass-tilde-importer'),\n includePaths: styleIncludePaths,\n })\n .css.toString();\n }\n case '.less': {\n const { css } = await (await import('less')).render(content, {\n filename: filePath,\n javascriptEnabled: true,\n paths: styleIncludePaths,\n });\n\n return css;\n }\n case '.styl':\n case '.stylus': {\n const stylus = await import('stylus');\n\n return (\n stylus(content)\n // add paths for resolve\n .set('paths', [basePath, '.', ...styleIncludePaths, 'node_modules'])\n // add support for resolving plugins from node_modules\n .set('filename', filePath)\n // turn on url resolver in stylus, same as flag --resolve-url\n .set('resolve url', true)\n .define('url', stylus.resolver(undefined))\n .render()\n );\n }\n case '.css':\n default:\n return content;\n }\n}\n\nfunction optimizeCss(filePath: string, css: string, browsers: string[], cssUrl?: CssUrl): LazyResult {\n const postCssPlugins = [];\n\n if (cssUrl !== CssUrl.none) {\n postCssPlugins.push(postcssUrl({ url: cssUrl }));\n }\n\n // this is important to be executed post running `postcssUrl`\n postCssPlugins.push(autoprefixer(browsers));\n\n postCssPlugins.push(\n cssnano({\n preset: [\n 'default',\n {\n // Disable SVG optimizations, as this can cause optimizations which are not compatible in all browsers.\n svgo: false,\n // Disable `calc` optimizations, due to several issues. #16910, #16875, #17890\n calc: false,\n },\n ],\n }),\n );\n\n return postcss(postCssPlugins).process(css, {\n from: filePath,\n to: filePath.replace(path.extname(filePath), '.css'),\n });\n}\n\n// default export for sync-rpc to recognize the function https://github.com/ForbesLindesay/sync-rpc#workerjs\nexport default () => processCss"]}
|
|
@@ -11,14 +11,14 @@ export interface WorkerOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export interface WorkerResult {
|
|
13
13
|
css: string;
|
|
14
|
-
warnings: [];
|
|
14
|
+
warnings: string[];
|
|
15
15
|
}
|
|
16
16
|
export declare class StylesheetProcessor {
|
|
17
17
|
readonly basePath: string;
|
|
18
18
|
readonly cssUrl?: CssUrl;
|
|
19
19
|
readonly styleIncludePaths?: string[];
|
|
20
20
|
private readonly browserslistData;
|
|
21
|
-
private readonly
|
|
21
|
+
private readonly styleSheetProcessorWorker;
|
|
22
22
|
constructor(basePath: string, cssUrl?: CssUrl, styleIncludePaths?: string[]);
|
|
23
23
|
process(filePath: string): string;
|
|
24
24
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StylesheetProcessor = exports.CssUrl = void 0;
|
|
4
|
-
const child_process_1 = require("child_process");
|
|
5
4
|
const browserslist = require("browserslist");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const rpc = require("sync-rpc");
|
|
6
7
|
const log = require("../utils/log");
|
|
7
8
|
var CssUrl;
|
|
8
9
|
(function (CssUrl) {
|
|
@@ -14,7 +15,7 @@ class StylesheetProcessor {
|
|
|
14
15
|
this.basePath = basePath;
|
|
15
16
|
this.cssUrl = cssUrl;
|
|
16
17
|
this.styleIncludePaths = styleIncludePaths;
|
|
17
|
-
this.
|
|
18
|
+
this.styleSheetProcessorWorker = rpc(path_1.join(__dirname, './stylesheet-processor-worker.js'), StylesheetProcessor.name);
|
|
18
19
|
log.debug(`determine browserslist for ${basePath}`);
|
|
19
20
|
this.browserslistData = browserslist(undefined, { path: basePath });
|
|
20
21
|
}
|
|
@@ -26,10 +27,7 @@ class StylesheetProcessor {
|
|
|
26
27
|
styleIncludePaths: this.styleIncludePaths,
|
|
27
28
|
browserslistData: this.browserslistData,
|
|
28
29
|
};
|
|
29
|
-
const
|
|
30
|
-
windowsHide: true,
|
|
31
|
-
});
|
|
32
|
-
const { css, warnings } = JSON.parse(stdout.toString());
|
|
30
|
+
const { css, warnings } = this.styleSheetProcessorWorker(workerOptions);
|
|
33
31
|
warnings.forEach(msg => log.warn(msg));
|
|
34
32
|
return css;
|
|
35
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,+BAA4B;AAC5B,gCAAgC;AAEhC,oCAAoC;AAEpC,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB;AAcD,MAAa,mBAAmB;IAO9B,YAAqB,QAAgB,EAAW,MAAe,EAAW,iBAA4B;QAAjF,aAAQ,GAAR,QAAQ,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAS;QAAW,sBAAiB,GAAjB,iBAAiB,CAAW;QALrF,8BAAyB,GAA6C,GAAG,CACxF,WAAI,CAAC,SAAS,EAAE,kCAAkC,CAAC,EACnD,mBAAmB,CAAC,IAAI,CACzB,CAAC;QAGA,GAAG,CAAC,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,CAAC,QAAgB;QACtB,MAAM,aAAa,GAAkB;YACnC,QAAQ;YACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;SACxC,CAAC;QAEF,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC;QAExE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA3BD,kDA2BC","sourcesContent":["import * as browserslist from 'browserslist';\nimport { join } from 'path';\nimport * as rpc from 'sync-rpc';\n\nimport * as log from '../utils/log';\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\nexport interface WorkerOptions {\n filePath: string;\n basePath: string;\n browserslistData: string[];\n cssUrl?: CssUrl;\n styleIncludePaths?: string[];\n}\n\nexport interface WorkerResult {\n css: string;\n warnings: string[];\n}\n\nexport class StylesheetProcessor {\n private readonly browserslistData: string[];\n private readonly styleSheetProcessorWorker: (options: WorkerOptions) => WorkerResult = rpc(\n join(__dirname, './stylesheet-processor-worker.js'),\n StylesheetProcessor.name\n );\n\n constructor(readonly basePath: string, readonly cssUrl?: CssUrl, readonly styleIncludePaths?: string[]) {\n log.debug(`determine browserslist for ${basePath}`);\n this.browserslistData = browserslist(undefined, { path: basePath });\n }\n\n process(filePath: string) {\n const workerOptions: WorkerOptions = {\n filePath,\n basePath: this.basePath,\n cssUrl: this.cssUrl,\n styleIncludePaths: this.styleIncludePaths,\n browserslistData: this.browserslistData,\n };\n\n const { css, warnings } = this.styleSheetProcessorWorker(workerOptions);\n\n warnings.forEach(msg => log.warn(msg));\n\n return css;\n }\n}\n"]}
|
|
@@ -90,6 +90,10 @@ function cacheCompilerHost(graph, entryPoint, compilerOptions, moduleResolutionC
|
|
|
90
90
|
// stylesheet
|
|
91
91
|
cache.content = stylesheetProcessor.process(fileName);
|
|
92
92
|
}
|
|
93
|
+
if (cache.content === undefined) {
|
|
94
|
+
throw new Error(`Cannot read file ${fileName}.`);
|
|
95
|
+
}
|
|
96
|
+
;
|
|
93
97
|
cache.exists = true;
|
|
94
98
|
}
|
|
95
99
|
return cache.content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-compiler-host.js","sourceRoot":"","sources":["../../../src/lib/ts/cache-compiler-host.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,4CAA4C;AAC5C,6BAA6B;AAC7B,wCAA+C;AAE/C,+CAA8D;AAG9D,wCAAqC;AAErC,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,UAA0B,EAC1B,eAAmC,EACnC,qBAA+C,EAC/C,mBAAyC,EACzC,mBAA8B,UAAU,CAAC,KAAK,CAAC,gBAAgB,EAC/D,cAAc,GAAG,IAAI;IAErB,MAAM,MAAM,GAAG,EAAE,CAAC,kBAAkB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACtE,MAAM,YAAY,GAAG,EAAE,CAAC,kBAAkB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC;IAEjF,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,EAAE;QACnC,MAAM,OAAO,GAAG,eAAO,CAAC,qBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClD,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,GAAG,IAAI,WAAI,CAAC,OAAO,CAAC,CAAC;YACzB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/B,UAA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I,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;iBAC5D;qBAAM;oBACL,aAAa;oBACb,KAAK,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;iBACvD;gBAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,GAAG,CAAC,CAAC;iBAClD;gBAAA,CAAC;gBAEF,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;aACrB;YAED,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AA1ID,8CA0IC","sourcesContent":["import * as ts from 'typescript';\nimport * as ng from '@angular/compiler-cli';\nimport * as path from 'path';\nimport { ensureUnixPath } from '../utils/path';\nimport { StylesheetProcessor } from '../styles/stylesheet-processor';\nimport { EntryPointNode, fileUrl } from '../ng-package/nodes';\nimport { BuildGraph } from '../graph/build-graph';\nimport { FileCache } from '../file-system/file-cache';\nimport { Node } from '../graph/node';\n\nexport function cacheCompilerHost(\n graph: BuildGraph,\n entryPoint: EntryPointNode,\n compilerOptions: ng.CompilerOptions,\n moduleResolutionCache: ts.ModuleResolutionCache,\n stylesheetProcessor?: StylesheetProcessor,\n sourcesFileCache: FileCache = entryPoint.cache.sourcesFileCache,\n setParentNodes = true,\n): ng.CompilerHost {\n const tsHost = ts.createCompilerHost(compilerOptions, setParentNodes);\n const compilerHost = ng.createCompilerHost({ options: compilerOptions, tsHost });\n\n const getNode = (fileName: string) => {\n const nodeUri = fileUrl(ensureUnixPath(fileName));\n let node = graph.get(nodeUri);\n\n if (!node) {\n node = new Node(nodeUri);\n graph.put(node);\n }\n\n return node;\n };\n\n const addDependee = (fileName: string) => {\n const node = getNode(fileName);\n entryPoint.dependsOn(node);\n };\n\n return {\n ...compilerHost,\n\n // ts specific\n fileExists: (fileName: string) => {\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.exists === undefined) {\n cache.exists = compilerHost.fileExists.call(this, fileName);\n }\n return cache.exists;\n },\n\n getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget) => {\n addDependee(fileName);\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (!cache.sourceFile) {\n cache.sourceFile = compilerHost.getSourceFile.call(this, fileName, languageVersion);\n }\n return cache.sourceFile;\n },\n\n writeFile: (\n fileName: string,\n data: string,\n writeByteOrderMark: boolean,\n onError?: (message: string) => void,\n sourceFiles?: ReadonlyArray<ts.SourceFile>,\n ) => {\n if (fileName.endsWith('.d.ts')) {\n sourceFiles.forEach(source => {\n const cache = sourcesFileCache.getOrCreate(source.fileName);\n if (!cache.declarationFileName) {\n cache.declarationFileName = ensureUnixPath(fileName);\n }\n });\n }\n\n compilerHost.writeFile.call(this, fileName, data, writeByteOrderMark, onError, sourceFiles);\n },\n\n readFile: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n cache.content = compilerHost.readFile.call(this, fileName);\n }\n return cache.content;\n },\n\n // ng specific\n moduleNameToFileName: (moduleName: string, containingFile: string) => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule && resolvedModule.resolvedFileName;\n },\n\n resolveModuleNames: (moduleNames: string[], containingFile: string) => {\n return moduleNames.map(moduleName => {\n const { resolvedModule } = ts.resolveModuleName(\n moduleName,\n ensureUnixPath(containingFile),\n compilerOptions,\n compilerHost,\n moduleResolutionCache,\n );\n\n return resolvedModule;\n });\n },\n\n resourceNameToFileName: (resourceName: string, containingFilePath: string) => {\n const resourcePath = path.resolve(path.dirname(containingFilePath), resourceName);\n const containingNode = getNode(containingFilePath);\n const resourceNode = getNode(resourcePath);\n containingNode.dependsOn(resourceNode);\n\n return resourcePath;\n },\n\n readResource: (fileName: string) => {\n addDependee(fileName);\n\n const cache = sourcesFileCache.getOrCreate(fileName);\n if (cache.content === undefined) {\n if (/(html|htm|svg)$/.test(path.extname(fileName))) {\n // template\n cache.content = compilerHost.readFile.call(this, fileName);\n } else {\n // stylesheet\n cache.content = stylesheetProcessor.process(fileName);\n }\n\n if (cache.content === undefined) {\n throw new Error(`Cannot read file ${fileName}.`);\n };\n\n cache.exists = true;\n }\n\n return cache.content;\n },\n };\n}\n"]}
|
package/ng-package.schema.d.ts
CHANGED
|
@@ -20,6 +20,10 @@ export interface NgPackageConfig {
|
|
|
20
20
|
* Enable this to keep the 'scripts' section in package.json. Read the NPM Blog on 'Package install scripts vulnerability' – http://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability
|
|
21
21
|
*/
|
|
22
22
|
keepLifecycleScripts?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.
|
|
25
|
+
*/
|
|
26
|
+
allowedNonPeerDependencies?: string[];
|
|
23
27
|
/**
|
|
24
28
|
* A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.
|
|
25
29
|
*/
|
package/ng-package.schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-package.schema.js","sourceRoot":"","sources":["../src/ng-package.schema.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB;;;;GAIG","sourcesContent":["/* tslint:disable */\n/**\n * This file was automatically generated by json-schema-to-typescript.\n * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,\n * and run json-schema-to-typescript to regenerate this file.\n */\n\n/**\n * JSON Schema for `ng-package.json` description file\n */\nexport interface NgPackageConfig {\n $schema?: string;\n /**\n * Delete output path before build.\n */\n deleteDestPath?: boolean;\n /**\n * Destination folder where distributable binaries of the Angular library are written (default: `dist`).\n */\n dest?: string;\n /**\n * Enable this to keep the 'scripts' section in package.json. Read the NPM Blog on 'Package install scripts vulnerability' – http://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability\n */\n keepLifecycleScripts?: boolean;\n /**\n * A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.\n */\n whitelistedNonPeerDependencies?: string[];\n /**\n * A list of files which are simply copied into the package.\n */\n assets?: string[];\n /**\n * Description of the library's entry point.\n */\n lib?: {\n /**\n * Entry file to the public API (default: `src/public_api.ts`).\n */\n entryFile?: string;\n /**\n * Filename of the auto-generated flat module file (if empty, defaults to the package name as given in `package.json`).\n */\n flatModuleFile?: string;\n /**\n * A map of external dependencies and their correspondent UMD module identifiers. Map keys are TypeScript / EcmaScript module identifiers. Map values are UMD module ids. The purpose of this map is to correctly bundle an UMD module file (with `rollup`). By default, `rxjs`, `tslib` and `@angular/*` dependency symbols are supported.\n */\n umdModuleIds?: {\n [k: string]: unknown;\n };\n /**\n * Embed assets in css file using data URIs - see https://css-tricks.com/data-uris\n */\n cssUrl?: \"none\" | \"inline\";\n /**\n * Any additional paths that should be used to resolve style imports\n */\n styleIncludePaths?: string[];\n /**\n * ID for AMD module. By default, uses a value derived from the entry point's module ID (i.e., name property in package.json)\n */\n amdId?: string;\n /**\n * ID for the UMD bundle. By default, uses a value derived from the entry point's module ID (i.e., name property in package.json)\n */\n umdId?: string;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ng-package.schema.js","sourceRoot":"","sources":["../src/ng-package.schema.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB;;;;GAIG","sourcesContent":["/* tslint:disable */\n/**\n * This file was automatically generated by json-schema-to-typescript.\n * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,\n * and run json-schema-to-typescript to regenerate this file.\n */\n\n/**\n * JSON Schema for `ng-package.json` description file\n */\nexport interface NgPackageConfig {\n $schema?: string;\n /**\n * Delete output path before build.\n */\n deleteDestPath?: boolean;\n /**\n * Destination folder where distributable binaries of the Angular library are written (default: `dist`).\n */\n dest?: string;\n /**\n * Enable this to keep the 'scripts' section in package.json. Read the NPM Blog on 'Package install scripts vulnerability' – http://blog.npmjs.org/post/141702881055/package-install-scripts-vulnerability\n */\n keepLifecycleScripts?: boolean;\n /**\n * A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.\n */\n allowedNonPeerDependencies?: string[];\n /**\n * A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.\n */\n whitelistedNonPeerDependencies?: string[];\n /**\n * A list of files which are simply copied into the package.\n */\n assets?: string[];\n /**\n * Description of the library's entry point.\n */\n lib?: {\n /**\n * Entry file to the public API (default: `src/public_api.ts`).\n */\n entryFile?: string;\n /**\n * Filename of the auto-generated flat module file (if empty, defaults to the package name as given in `package.json`).\n */\n flatModuleFile?: string;\n /**\n * A map of external dependencies and their correspondent UMD module identifiers. Map keys are TypeScript / EcmaScript module identifiers. Map values are UMD module ids. The purpose of this map is to correctly bundle an UMD module file (with `rollup`). By default, `rxjs`, `tslib` and `@angular/*` dependency symbols are supported.\n */\n umdModuleIds?: {\n [k: string]: unknown;\n };\n /**\n * Embed assets in css file using data URIs - see https://css-tricks.com/data-uris\n */\n cssUrl?: \"none\" | \"inline\";\n /**\n * Any additional paths that should be used to resolve style imports\n */\n styleIncludePaths?: string[];\n /**\n * ID for AMD module. By default, uses a value derived from the entry point's module ID (i.e., name property in package.json)\n */\n amdId?: string;\n /**\n * ID for the UMD bundle. By default, uses a value derived from the entry point's module ID (i.e., name property in package.json)\n */\n umdId?: string;\n };\n}\n"]}
|
package/ng-package.schema.json
CHANGED
|
@@ -23,13 +23,21 @@
|
|
|
23
23
|
"type": "boolean",
|
|
24
24
|
"default": false
|
|
25
25
|
},
|
|
26
|
-
"
|
|
26
|
+
"allowedNonPeerDependencies": {
|
|
27
27
|
"description": "A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.",
|
|
28
28
|
"type": "array",
|
|
29
29
|
"items": {
|
|
30
30
|
"type": "string"
|
|
31
31
|
},
|
|
32
|
-
"default": [
|
|
32
|
+
"default": []
|
|
33
|
+
},
|
|
34
|
+
"whitelistedNonPeerDependencies": {
|
|
35
|
+
"x-deprecated": "Use \"allowedNonPeerDependencies\" instead.",
|
|
36
|
+
"description": "A list of dependencies that are allowed in the 'dependencies' and 'devDependencies' section of package.json. Values in the list are regular expressions matched against npm package names.",
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": {
|
|
39
|
+
"type": "string"
|
|
40
|
+
}
|
|
33
41
|
},
|
|
34
42
|
"assets": {
|
|
35
43
|
"type": "array",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.4",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"ora": "^5.1.0",
|
|
44
44
|
"postcss": "^8.2.4",
|
|
45
45
|
"postcss-url": "^10.1.1",
|
|
46
|
-
"read-pkg-up": "^5.0.0",
|
|
47
46
|
"rimraf": "^3.0.0",
|
|
48
47
|
"rollup": "^2.37.0",
|
|
49
48
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
50
49
|
"rxjs": "^6.5.0",
|
|
51
50
|
"sass": "^1.32.5",
|
|
52
51
|
"stylus": "^0.54.8",
|
|
52
|
+
"sync-rpc": "^1.3.6",
|
|
53
53
|
"terser": "^5.5.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|