Commit graph

36 commits

Author SHA1 Message Date
Alan Agius
3c41e74fdd fix(localize): validate locale in getOutputPathFn to prevent path traversal
The `localize-translate` CLI tool uses the `locale` field from translation files to expand the `{{LOCALE}}` placeholder in the output directory. It failed to sanitize `locale` input, allowing malicious translations to write files outside of the configured output directory.

This change mitigates this issue by combining.

Closes #67906

(cherry picked from commit 7871093822)
2026-03-30 12:15:31 +02:00
Angular Robot
11767cabe4 build: update Jasmine to 6.0.0
Jasmine enables `forbidDuplicateNames: true` by default. So we also need to desambiguate duplicate spec names.
2026-02-09 12:15:57 -08:00
Kristiyan Kostadinov
d9c980a958 build: initial test of TypeScript 6
Resolves some initial test failures after updating to TypeScript 6.
2026-01-15 13:41:01 -08:00
Jessica Janiuk
37092d00b7 Revert "refactor(compiler-cli): remove deep imports from compiler-cli (#64732)"
This reverts commit 05938c1054.
2025-11-06 13:09:01 -08:00
Matthieu Riegler
05938c1054 refactor(compiler-cli): remove deep imports from compiler-cli (#64732)
Accessed symbols are grouped into dedicated `private` entries

PR Close #64732
2025-11-06 20:01:26 +00:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
Joey Perrott
3df1dccebe refactor: various build and import specificer fixes for strict deps (#63323)
Change direct deps in bazel targets and import specifiers within files to maintain strict deps requirements ahead of enabling strict deps tests in the repo

PR Close #63323
2025-08-22 14:45:00 -07:00
Joey Perrott
c4dcfdf644 build: update to the latest version of devinfra and rename npm2 workspace (#63093)
Rename the npm2 workspace to npm and use the latest version of devinfra which drops rules_nodejs

PR Close #63093
2025-08-11 10:35:32 -07:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Joey Perrott
49b7729e88 build: remove usages of rules_nodejs (#62885)
Remove rules_nodejs usages with direct migrations to rule_js alternatives

PR Close #62885
2025-07-30 08:51:27 +00:00
Joey Perrott
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
Joey Perrott
b2714243d8 build: use tsc from @npm2// instead of @npm// (#62558)
Use tsc from the new node_modules layout

PR Close #62558
2025-07-10 10:25:36 -07:00
Paul Gschwendtner
bd6d043767 refactor(compiler-cli): ensure mock file system can be loaded in the browser (#62493)
The mock file system currently relies on some NodeJS logic. This blocks
the convenient use of the mock file system in the browser. The file
system is useful for creating tests to verify e.g. that our transforms
can work in the browser.

PR Close #62493
2025-07-07 12:59:25 +02:00
Kristiyan Kostadinov
223279eaf5 refactor(compiler): remove TranslationParseError (#62160)
Replaces the `TranslationParseError` with `ParseError` since it wasn't adding much on top of `ParseError`.

PR Close #62160
2025-06-23 14:25:28 +02:00
Joey Perrott
557ac51c32 build: migrate to using new jasmine_test (#62131)
Migrate additional targets to jasmine_test

PR Close #62131
2025-06-19 10:06:27 +02:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
Joey Perrott
b478a43804 build: migrate localize package to use rules_js (#61613)
Use ts_project to build localize package

PR Close #61613
2025-05-26 08:53:55 +00:00
Andrew Kushnir
6a207ebfb0 refactor(localize): convert scripts within packages/localize to relative imports (#60540)
This commit updates scripts within `packages/localize` to relative imports as a prep work to the upcoming infra updates.

PR Close #60540
2025-03-26 20:40:01 -07:00
Alan Agius
45f899a272 refactor: replace fast-glob usage with tinyglobby (#60264)
Usage of the `fast-glob` package has been replaced with the `tinyglobby` package. The change reduces the number of transitive dependencies related to these packages from 17 to 2 while also maintaining equivalent functionality. This was also changed in the Angular CLI packages.

PR Close #60264
2025-03-07 10:57:23 -08:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Doug Parker
292c987791 refactor(compiler): add handler attribute to XMB output (#54865)
This allows tracking of which tools generated which XMB files and helps attribute Angular usage.

PR Close #54865
2024-04-29 11:56:31 -07:00
Joey Perrott
488c711a57 refactor: migrate localize to prettier formatting (#55423)
Migrate formatting to prettier for localize from clang-format

PR Close #55423
2024-04-19 13:49:24 -07:00
Charles Lyding
ad52eeb164 refactor: reduce direct babel dependencies (#53441)
The `@babel/core` package provides the functionality of multiple other babel packages
without the need to directly depend or import the other babel packages. Since the
`@babel/core` package is already used and imported in the locations that previously
used the other babel packages, an overall reduction in both imports and dependencies
is possible. Six babel related packages were able to be removed from the root `package.json`
and one (also present in the aforementioned six) was removed as a dependency from the
`@angular/localize` package. Unfortunately, the functionality used from the `@babel/generator`
package is not provided by `@babel/core` and is still present. Further refactoring may
allow its removal as well in the future.

The following packages were removed:
* @babel/parser
* @babel/template
* @babel/traverse
* @babel/types
* @types/babel__template
* @types/babel__traverse

PR Close #53441
2023-12-08 14:33:59 -08:00
Alex Rickabaugh
299eae44a9 Revert "refactor: reduce direct babel dependencies (#53374)" (#53432)
This reverts commit 3b12c59696.

PR Close #53432
2023-12-07 13:21:15 -08:00
Charles Lyding
3b12c59696 refactor: reduce direct babel dependencies (#53374)
The `@babel/core` package provides the functionality of multiple other babel packages
without the need to directly depend or import the other babel packages. Since the
`@babel/core` package is already used and imported in the locations that previously
used the other babel packages, an overall reduction in both imports and dependencies
is possible. Six babel related packages were able to be removed from the root `package.json`
and one (also present in the aforementioned six) was removed as a dependency from the
`@angular/localize` package. Unfortunately, the functionality used from the `@babel/generator`
package is not provided by `@babel/core` and is still present. Further refactoring may
allow its removal as well in the future.

The following packages were removed:
* @babel/parser
* @babel/template
* @babel/traverse
* @babel/types
* @types/babel__template
* @types/babel__traverse

PR Close #53374
2023-12-07 09:34:22 -08:00
Kevin Gay
d5a8ff39b9 build: Update Glob to fast-glob to remove Inflight due to memory leak (#50632)
Update Glob to fast-glob to remove the dependence of Inflight that contains a memory leak

Signed-off-by: Kevin Gay <5970002+GayKevin@users.noreply.github.com>

PR Close #50632
2023-06-12 15:33:47 +02:00
Paul Gschwendtner
d0d6966d41 refactor: update packages/localize to be strict ESM (#48521)
The `packages/localize` package still required some trickery
to support CommonJS because tests in the repo were running as CommonJS.

This commit removes the CommonJS logic in localize and its tests, so
that only ESM is used in production & tests.

PR Close #48521
2022-12-19 19:50:43 +00:00
Paul Gschwendtner
c9415e4d75 build: ensure bootstrap transitive runfiles are made available (#48521)
Since we generate a `.mjs` file as entry-point for jasmine tests,
a couple of issues prevented the transitive dependencies from
bootstrap targets to be brought in (causing resolution errors):

1. The `_files` (previously `_esm2015`) targets are no longer needed,
   and they also miss all the information on runfiles.
2. The aspect for computing linker mappings does not respect the
   `bootstrap` attribute from the `spec_entrypoint` so we manually
   add the extract ESM output targets (this rule works with the aspect
   and forwards linker mappings).

PR Close #48521
2022-12-19 19:50:41 +00:00
Paul Gschwendtner
20551503fa build: replace _es2015 shorthand with more flexible _files suffix (#48521)
For every `ts_library` target we expose a shorthand that grants
access to the JS files because `DefaultInfo` of a ts library
only exposes the `.d.ts` files.

We rename this away from `es2015` since in practice it's a much
higher target these days. Additionally we no longer use the devmode
output but rather use the prodmode output which has the explicit
`.mjs` output- compatible with ESM.

PR Close #48521
2022-12-19 19:50:41 +00:00
Alan Agius
d36fd3d9e4 refactor(localize): remove deprecated canParse method from TranslationParsers (#47275)
This change removed the deprecated `canParse` method from all the TranslationParsers.

BREAKING CHANGE:

- `canParse` method has been removed from all translation parsers in `@angular/localize/tools`. `analyze` should be used instead.
-  the `hint` parameter in the`parse` methods is now mandatory.

PR Close #47275
2022-09-06 09:57:02 -07:00
JoostK
7bbddb5873 refactor(localize): update version of Babel (#44931)
The `@angular/localize` package depends on a version of Babel that is two years
old, so this commit updates to the latest version.

Some changes were made to the linker and compliance tests to account for slight
changes in source maps, along with a few code updates because of changes to
the typings of Babel.

PR Close #44931
2022-02-24 21:42:54 +00:00
Paul Gschwendtner
c46d533b22 build: switch devmode output to es2015 (#44505)
To make our test output i.e. devmode output more aligned
with what we produce in the NPM packages, or to be more
aligned with what Angular applications will usually consume,
the devmode output is switched from ES5 to ES2015.

Additionally various tsconfigs (outside of Bazel) have been
updated to match with the other parts of the build. The rules
are:

ES2015 for test configurations, ES2020 for actual code that will
end up being shipped (this includes the IDE-only tsconfigs).

PR Close #44505
2022-01-05 23:20:20 +00:00
Pete Bacon Darwin
d3cf222a81 feat(localize): support "associated message ids" for placeholders (#43534)
When extracting i18n messages, the Angular compiler needs to split ICU expressions
into their own message.  Currently there is no guaranteed way to re-associate
the ICU message with the original message where the ICU was found.

This change adds support in the localize tooling so that associated ids can be
stored as metadata in the `$localize` tagged strings. These ids can then be
used in generated translation files to provide a link between the two messages.

The XLIFF 1.2 and 2.0 formats have been updated to render these relationships,
via the `xid` and `subFlows` attributes respectively.

PR Close #43534
2021-10-18 09:23:59 -07:00
Paul Gschwendtner
8d7f1098d8 refactor: make all imports compatible with ESM/CJS output. (#43431)
As outlined in the previous commit which enabled the `esModuleInterop`
TypeScript compiler option, we need to update all namespace imports
for `typescript` to default imports. This is needed to allow for
TypeScript to be imported at runtime from an ES module.

Similar changes are needed for modules like `semver` where the types incorrectly
suggest named exports that will not exist at runtime when imported from ESM.

This commit refactors all imports to match with the lint rule we have
configured in the previous commit. See the previous commit for more
details on why certain imports have been changed.

A special case are the imports to `@babel/core` and `@babel/types`. For
these a special interop is needed as both default imports, or named
imports break the other module format. e.g default imports would work
well for ESM, but it breaks for CJS. For CJS, the named imports would
only work, but in ESM, only the default export exist. We work around
this for now until the devmode is using ESM as well (which would be
consistent with prodmode and gives us more valuable test results). More
details on the interop can be found in the `babel_core.ts` files (two
interops are needed for both localize/or the compiler-cli).

PR Close #43431
2021-10-01 18:28:45 +00:00
Paul Gschwendtner
27535bfb79 refactor: expose new @angular/localize/tools entry-point for CLI usage (#43431)
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
2021-10-01 18:28:44 +00:00
Paul Gschwendtner
a18981ab7b refactor: move localize/src/tools into localize/tools folder (#43431)
Moves the `src/tools` folder of the `@angular/localize` package into the
top-level of the package. This is in preparation of actually exposing an
entry-point for the tools that can be accessed using
`@angular/localize/tools`.

We want to expose such an entry-point because the CLI currently
deep-imports into various places of the tools, but this will not
work well with strict ESM because the localize tool depends on the
v13 strict ESM packages like the `@angular/compiler` or
`@angular/compiler-cli`.

PR Close #43431
2021-10-01 18:28:44 +00:00