mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
This wires up the `@angular/localize/tools` entry-point. For context: This entry-point is being created to avoid deep imports into `@angular/localize/src/tools/<..>` like the CLI relies on. Deep imports do not play well with strict ESM, and now that all APF packages are strict ESM, the tool code needs to be either strict ESM as well. We use ESBuild to create individual bundles for the CLI entry-points, and the actual tool entry-point. We use a bundler because this enables the localize code be ESM compatible. Without a bundler, all relative imports within the `tools` entry-point would need to explicitly have the `.js` extension. This would be cumbersome and hard to maintain/enforce or validate. One might wonder why this is not a standard APF entry-point then. The answer is that the APF entry-points do not support exposing the CLI binaries (like `yarn localize-translate`). This could be done through tertiary entry-points, but using ESBuild directly gives us more control for now. We might want to revisit this in the future again. PR Close #43431
21 lines
668 B
JavaScript
21 lines
668 B
JavaScript
/**
|
|
* @license
|
|
* Copyright Google LLC 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
|
|
*/
|
|
|
|
module.exports = {
|
|
resolveExtensions: ['.mjs'],
|
|
// Note: `@bazel/esbuild` has a bug and does not pass-through the format from Starlark.
|
|
format: 'esm',
|
|
banner: {
|
|
// Workaround for: https://github.com/evanw/esbuild/issues/946
|
|
// TODO: Remove this workaround in the future once devmode is ESM as well.
|
|
js: `
|
|
import {createRequire as __cjsCompatRequire} from 'module';
|
|
const require = __cjsCompatRequire(import.meta.url);
|
|
`,
|
|
},
|
|
};
|