feat(ivy): ngcc - compile only specified package.json format properties (#29092)
You can now specify a list of properties in the package.json that should be considered (in order) to find the path to the format to compile. The build marker system has been updated to store the markers in the package.json rather than an additional external file. Also instead of tracking the underlying bundle format that was compiled, it now tracks the package.json property. BREAKING CHANGE: The `proertiesToConsider` option replaces the previous `formats` option, which specified the final bundle format, rather than the property in the package.json. If you were using this option to compile only specific bundle formats, you must now modify your usage to pass in the properties in the package.json that map to the format that you wish to compile. In the CLI, the `--formats` is no longer available. Instead use the `--properties` option. FW-1120 PR Close #29092
This commit is contained in:

committed by
Matias Niemelä

parent
4bb0259bc0
commit
cd449021c1
@ -12,80 +12,36 @@ const EXAMPLES_BASE_PATH = path.resolve(__dirname, '../../content/examples');
|
||||
|
||||
const BOILERPLATE_PATHS = {
|
||||
cli: [
|
||||
'src/environments/environment.prod.ts',
|
||||
'src/environments/environment.ts',
|
||||
'src/assets/.gitkeep',
|
||||
'src/browserslist',
|
||||
'src/favicon.ico',
|
||||
'src/karma.conf.js',
|
||||
'src/polyfills.ts',
|
||||
'src/test.ts',
|
||||
'src/tsconfig.app.json',
|
||||
'src/tsconfig.spec.json',
|
||||
'src/tslint.json',
|
||||
'e2e/src/app.po.ts',
|
||||
'e2e/protractor.conf.js',
|
||||
'e2e/tsconfig.e2e.json',
|
||||
'.editorconfig',
|
||||
'angular.json',
|
||||
'package.json',
|
||||
'tsconfig.json',
|
||||
'tslint.json'
|
||||
'src/environments/environment.prod.ts', 'src/environments/environment.ts',
|
||||
'src/assets/.gitkeep', 'src/browserslist', 'src/favicon.ico', 'src/karma.conf.js',
|
||||
'src/polyfills.ts', 'src/test.ts', 'src/tsconfig.app.json', 'src/tsconfig.spec.json',
|
||||
'src/tslint.json', 'e2e/src/app.po.ts', 'e2e/protractor.conf.js', 'e2e/tsconfig.e2e.json',
|
||||
'.editorconfig', 'angular.json', 'package.json', 'tsconfig.json', 'tslint.json'
|
||||
],
|
||||
systemjs: [
|
||||
'src/systemjs-angular-loader.js',
|
||||
'src/systemjs.config.js',
|
||||
'src/tsconfig.json',
|
||||
'bs-config.json',
|
||||
'bs-config.e2e.json',
|
||||
'package.json',
|
||||
'tslint.json'
|
||||
'src/systemjs-angular-loader.js', 'src/systemjs.config.js', 'src/tsconfig.json',
|
||||
'bs-config.json', 'bs-config.e2e.json', 'package.json', 'tslint.json'
|
||||
],
|
||||
common: [
|
||||
'src/styles.css'
|
||||
]
|
||||
common: ['src/styles.css']
|
||||
};
|
||||
|
||||
// All paths in this tool are relative to the current boilerplate folder, i.e boilerplate/i18n
|
||||
// This maps the CLI files that exists in a parent folder
|
||||
const cliRelativePath = BOILERPLATE_PATHS.cli.map(file => `../cli/${file}`);
|
||||
|
||||
BOILERPLATE_PATHS.elements = [
|
||||
...cliRelativePath,
|
||||
'tsconfig.json'
|
||||
];
|
||||
BOILERPLATE_PATHS.elements = [...cliRelativePath, 'tsconfig.json'];
|
||||
|
||||
BOILERPLATE_PATHS.i18n = [
|
||||
...cliRelativePath,
|
||||
'angular.json',
|
||||
'package.json'
|
||||
];
|
||||
BOILERPLATE_PATHS.i18n = [...cliRelativePath, 'angular.json', 'package.json'];
|
||||
|
||||
BOILERPLATE_PATHS['service-worker'] = [
|
||||
...cliRelativePath,
|
||||
'angular.json',
|
||||
'package.json'
|
||||
];
|
||||
BOILERPLATE_PATHS['service-worker'] = [...cliRelativePath, 'angular.json', 'package.json'];
|
||||
|
||||
BOILERPLATE_PATHS.testing = [
|
||||
...cliRelativePath,
|
||||
'angular.json'
|
||||
];
|
||||
BOILERPLATE_PATHS.testing = [...cliRelativePath, 'angular.json'];
|
||||
|
||||
BOILERPLATE_PATHS.universal = [
|
||||
...cliRelativePath,
|
||||
'angular.json',
|
||||
'package.json'
|
||||
];
|
||||
BOILERPLATE_PATHS.universal = [...cliRelativePath, 'angular.json', 'package.json'];
|
||||
|
||||
BOILERPLATE_PATHS.ivy = {
|
||||
systemjs: [
|
||||
'rollup-config.js',
|
||||
'tsconfig-aot.json'
|
||||
],
|
||||
cli: [
|
||||
'src/tsconfig.app.json'
|
||||
]
|
||||
systemjs: ['rollup-config.js', 'tsconfig-aot.json'],
|
||||
cli: ['src/tsconfig.app.json']
|
||||
};
|
||||
|
||||
BOILERPLATE_PATHS.schematics = [
|
||||
@ -101,11 +57,13 @@ class ExampleBoilerPlate {
|
||||
*/
|
||||
add(ivy = false) {
|
||||
// Get all the examples folders, indicated by those that contain a `example-config.json` file
|
||||
const exampleFolders = this.getFoldersContaining(EXAMPLES_BASE_PATH, EXAMPLE_CONFIG_FILENAME, 'node_modules');
|
||||
const exampleFolders =
|
||||
this.getFoldersContaining(EXAMPLES_BASE_PATH, EXAMPLE_CONFIG_FILENAME, 'node_modules');
|
||||
|
||||
if (!fs.existsSync(SHARED_NODE_MODULES_PATH)) {
|
||||
throw new Error(`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
|
||||
`Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
|
||||
throw new Error(
|
||||
`The shared node_modules folder for the examples (${SHARED_NODE_MODULES_PATH}) is missing.\n` +
|
||||
`Perhaps you need to run "yarn example-use-npm" or "yarn example-use-local" to install the dependencies?`);
|
||||
}
|
||||
|
||||
if (ivy) {
|
||||
@ -114,7 +72,7 @@ class ExampleBoilerPlate {
|
||||
// the module typings if we specified an "es2015" format. This means that
|
||||
// we also need to build with "fesm2015" in order to get updated typings
|
||||
// which are needed for compilation.
|
||||
shelljs.exec(`yarn --cwd ${SHARED_PATH} ivy-ngcc --formats fesm2015 fesm5`);
|
||||
shelljs.exec(`yarn --cwd ${SHARED_PATH} ivy-ngcc`);
|
||||
}
|
||||
|
||||
exampleFolders.forEach(exampleFolder => {
|
||||
@ -128,16 +86,20 @@ class ExampleBoilerPlate {
|
||||
const boilerPlateBasePath = path.resolve(BOILERPLATE_BASE_PATH, boilerPlateType);
|
||||
|
||||
// Copy the boilerplate specific files
|
||||
BOILERPLATE_PATHS[boilerPlateType].forEach(filePath => this.copyFile(boilerPlateBasePath, exampleFolder, filePath));
|
||||
BOILERPLATE_PATHS[boilerPlateType].forEach(
|
||||
filePath => this.copyFile(boilerPlateBasePath, exampleFolder, filePath));
|
||||
|
||||
// Copy the boilerplate common files
|
||||
BOILERPLATE_PATHS.common.forEach(filePath => this.copyFile(BOILERPLATE_COMMON_BASE_PATH, exampleFolder, filePath));
|
||||
BOILERPLATE_PATHS.common.forEach(
|
||||
filePath => this.copyFile(BOILERPLATE_COMMON_BASE_PATH, exampleFolder, filePath));
|
||||
|
||||
// Copy Ivy specific files
|
||||
if (ivy) {
|
||||
const ivyBoilerPlateType = boilerPlateType === 'systemjs' ? 'systemjs' : 'cli';
|
||||
const ivyBoilerPlateBasePath = path.resolve(BOILERPLATE_BASE_PATH, 'ivy', ivyBoilerPlateType);
|
||||
BOILERPLATE_PATHS.ivy[ivyBoilerPlateType].forEach(filePath => this.copyFile(ivyBoilerPlateBasePath, exampleFolder, filePath));
|
||||
const ivyBoilerPlateBasePath =
|
||||
path.resolve(BOILERPLATE_BASE_PATH, 'ivy', ivyBoilerPlateType);
|
||||
BOILERPLATE_PATHS.ivy[ivyBoilerPlateType].forEach(
|
||||
filePath => this.copyFile(ivyBoilerPlateBasePath, exampleFolder, filePath));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -145,23 +107,20 @@ class ExampleBoilerPlate {
|
||||
/**
|
||||
* Remove all the boilerplate files from all the examples
|
||||
*/
|
||||
remove() {
|
||||
shelljs.exec('git clean -xdfq', { cwd: EXAMPLES_BASE_PATH });
|
||||
}
|
||||
remove() { shelljs.exec('git clean -xdfq', {cwd: EXAMPLES_BASE_PATH}); }
|
||||
|
||||
main() {
|
||||
yargs
|
||||
.usage('$0 <cmd> [args]')
|
||||
.command('add', 'add the boilerplate to each example', (yrgs) => this.add(yrgs.argv.ivy))
|
||||
.command('remove', 'remove the boilerplate from each example', () => this.remove())
|
||||
.demandCommand(1, 'Please supply a command from the list above')
|
||||
.argv;
|
||||
yargs.usage('$0 <cmd> [args]')
|
||||
.command('add', 'add the boilerplate to each example', (yrgs) => this.add(yrgs.argv.ivy))
|
||||
.command('remove', 'remove the boilerplate from each example', () => this.remove())
|
||||
.demandCommand(1, 'Please supply a command from the list above')
|
||||
.argv;
|
||||
}
|
||||
|
||||
getFoldersContaining(basePath, filename, ignore) {
|
||||
const pattern = path.resolve(basePath, '**', filename);
|
||||
const ignorePattern = path.resolve(basePath, '**', ignore, '**');
|
||||
return glob.sync(pattern, { ignore: [ignorePattern] }).map(file => path.dirname(file));
|
||||
return glob.sync(pattern, {ignore: [ignorePattern]}).map(file => path.dirname(file));
|
||||
}
|
||||
|
||||
copyFile(sourceFolder, destinationFolder, filePath) {
|
||||
@ -171,13 +130,11 @@ class ExampleBoilerPlate {
|
||||
filePath = this.normalizePath(filePath);
|
||||
|
||||
const destinationPath = path.resolve(destinationFolder, filePath);
|
||||
fs.copySync(sourcePath, destinationPath, { overwrite: true });
|
||||
fs.copySync(sourcePath, destinationPath, {overwrite: true});
|
||||
fs.chmodSync(destinationPath, 444);
|
||||
}
|
||||
|
||||
loadJsonFile(filePath) {
|
||||
return fs.readJsonSync(filePath, { throws: false }) || {};
|
||||
}
|
||||
loadJsonFile(filePath) { return fs.readJsonSync(filePath, {throws: false}) || {}; }
|
||||
|
||||
normalizePath(filePath) {
|
||||
// transform for example ../cli/src/tsconfig.app.json to src/tsconfig.app.json
|
||||
|
Reference in New Issue
Block a user