bootstrap.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.dev/license
  7. */
  8. /**
  9. * @fileoverview
  10. *
  11. * This file is used to bootstrap the CLI process by dynamically importing the main initialization code.
  12. * This is done to allow the main bin file (`ng`) to remain CommonJS so that older versions of Node.js
  13. * can be checked and validated prior to the execution of the CLI. This separate bootstrap file is
  14. * needed to allow the use of a dynamic import expression without crashing older versions of Node.js that
  15. * do not support dynamic import expressions and would otherwise throw a syntax error. This bootstrap file
  16. * is required from the main bin file only after the Node.js version is determined to be in the supported
  17. * range.
  18. */
  19. // Enable on-disk code caching if available (Node.js 22.8+)
  20. // Skip if running inside Bazel via a RUNFILES environment variable check. The cache does not work
  21. // well with Bazel's hermeticity requirements.
  22. if (!process.env['RUNFILES']) {
  23. try {
  24. const { enableCompileCache } = require('node:module');
  25. enableCompileCache?.();
  26. } catch {}
  27. }
  28. // Initialize the Angular CLI
  29. void import('../lib/init.js');