2018-07-16 03:49:56 -04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
import {mainNgcc} from './src/main';
|
2020-04-13 08:25:49 -04:00
|
|
|
import {parseCommandLineOptions} from './src/command_line_options';
|
2018-07-16 03:49:56 -04:00
|
|
|
|
|
|
|
// CLI entry point
|
|
|
|
if (require.main === module) {
|
2020-04-06 04:43:47 -04:00
|
|
|
process.title = 'ngcc';
|
2019-08-29 11:51:02 -04:00
|
|
|
const startTime = Date.now();
|
2020-04-13 08:25:49 -04:00
|
|
|
const options = parseCommandLineOptions(process.argv.slice(2));
|
2020-04-06 03:30:08 -04:00
|
|
|
(async () => {
|
refactor(ngcc): add support for asynchronous execution (#32427)
Previously, `ngcc`'s programmatic API would run and complete
synchronously. This was necessary for specific usecases (such as how the
`@angular/cli` invokes `ngcc` as part of the TypeScript module
resolution process), but not for others (e.g. running `ivy-ngcc` as a
`postinstall` script).
This commit adds a new option (`async`) that enables turning on
asynchronous execution. I.e. it signals that the caller is OK with the
function call to complete asynchronously, which allows `ngcc` to
potentially run in a more efficient mode.
Currently, there is no difference in the way tasks are executed in sync
vs async mode, but this change sets the ground for adding new execution
options (that require asynchronous operation), such as processing tasks
in parallel on multiple processes.
NOTE:
When using the programmatic API, the default value for `async` is
`false`, thus retaining backwards compatibility.
When running `ngcc` from the command line (i.e. via the `ivy-ngcc`
script), it runs in async mode (to be able to take advantage of future
optimizations), but that is transparent to the caller.
PR Close #32427
2019-08-19 15:58:22 -04:00
|
|
|
try {
|
2020-04-13 08:25:49 -04:00
|
|
|
await mainNgcc(options);
|
|
|
|
if (options.logger) {
|
2019-08-29 11:51:02 -04:00
|
|
|
const duration = Math.round((Date.now() - startTime) / 1000);
|
2020-04-13 08:25:49 -04:00
|
|
|
options.logger.debug(`Run ngcc in ${duration}s.`);
|
2019-08-29 11:51:02 -04:00
|
|
|
}
|
refactor(ngcc): add support for asynchronous execution (#32427)
Previously, `ngcc`'s programmatic API would run and complete
synchronously. This was necessary for specific usecases (such as how the
`@angular/cli` invokes `ngcc` as part of the TypeScript module
resolution process), but not for others (e.g. running `ivy-ngcc` as a
`postinstall` script).
This commit adds a new option (`async`) that enables turning on
asynchronous execution. I.e. it signals that the caller is OK with the
function call to complete asynchronously, which allows `ngcc` to
potentially run in a more efficient mode.
Currently, there is no difference in the way tasks are executed in sync
vs async mode, but this change sets the ground for adding new execution
options (that require asynchronous operation), such as processing tasks
in parallel on multiple processes.
NOTE:
When using the programmatic API, the default value for `async` is
`false`, thus retaining backwards compatibility.
When running `ngcc` from the command line (i.e. via the `ivy-ngcc`
script), it runs in async mode (to be able to take advantage of future
optimizations), but that is transparent to the caller.
PR Close #32427
2019-08-19 15:58:22 -04:00
|
|
|
process.exitCode = 0;
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e.stack || e.message);
|
2020-04-28 07:11:18 -04:00
|
|
|
process.exit(typeof e.code === 'number' ? e.code : 1);
|
refactor(ngcc): add support for asynchronous execution (#32427)
Previously, `ngcc`'s programmatic API would run and complete
synchronously. This was necessary for specific usecases (such as how the
`@angular/cli` invokes `ngcc` as part of the TypeScript module
resolution process), but not for others (e.g. running `ivy-ngcc` as a
`postinstall` script).
This commit adds a new option (`async`) that enables turning on
asynchronous execution. I.e. it signals that the caller is OK with the
function call to complete asynchronously, which allows `ngcc` to
potentially run in a more efficient mode.
Currently, there is no difference in the way tasks are executed in sync
vs async mode, but this change sets the ground for adding new execution
options (that require asynchronous operation), such as processing tasks
in parallel on multiple processes.
NOTE:
When using the programmatic API, the default value for `async` is
`false`, thus retaining backwards compatibility.
When running `ngcc` from the command line (i.e. via the `ivy-ngcc`
script), it runs in async mode (to be able to take advantage of future
optimizations), but that is transparent to the caller.
PR Close #32427
2019-08-19 15:58:22 -04:00
|
|
|
}
|
|
|
|
})();
|
2018-07-16 03:49:56 -04:00
|
|
|
}
|