New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loadTranslations from @angular/localize dependes on Node.js #38692
Comments
Great issue report @janousek - thanks. I will take a look at this today. |
It's a bit complicated to fix this way since I realise though that the |
…itted A recent change to `@angular/localize` brought in the `AbsoluteFsPath` type from the `@angular/compiler-cli`. But this brought along with it a reference to NodeJS typings - specifically the `FileSystem` interface refers to the `Buffer` type from NodeJS. This affects compilation of `@angular/localize` code that will be run in the browser - for example projects that reference `loadTranslations()`. The compilation breaks if the NodeJS typings are not included in the build. Clearly it is not desirable to have these typings included when the project is not targeting NodeJS. This commit replaces references to the NodeJS `Buffer` type with `Uint8Array`, which is available across all platforms and is actually the super-class of `Buffer`. Fixes angular#38692
A recent change to `@angular/localize` brought in the `AbsoluteFsPath` type from the `@angular/compiler-cli`. But this brought along with it a reference to NodeJS typings - specifically the `FileSystem` interface refers to the `Buffer` type from NodeJS. This affects compilation of `@angular/localize` code that will be run in the browser - for example projects that reference `loadTranslations()`. The compilation breaks if the NodeJS typings are not included in the build. Clearly it is not desirable to have these typings included when the project is not targeting NodeJS. This commit replaces references to the NodeJS `Buffer` type with `Uint8Array`, which is available across all platforms and is actually the super-class of `Buffer`. Fixes angular#38692
…#38700) A recent change to `@angular/localize` brought in the `AbsoluteFsPath` type from the `@angular/compiler-cli`. But this brought along with it a reference to NodeJS typings - specifically the `FileSystem` interface refers to the `Buffer` type from NodeJS. This affects compilation of `@angular/localize` code that will be run in the browser - for example projects that reference `loadTranslations()`. The compilation breaks if the NodeJS typings are not included in the build. Clearly it is not desirable to have these typings included when the project is not targeting NodeJS. This commit replaces references to the NodeJS `Buffer` type with `Uint8Array`, which is available across all platforms and is actually the super-class of `Buffer`. Fixes #38692 PR Close #38700
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 bug report
Affected Package
The issue is caused by package @angular/localize
Is this a regression?
Yes, the previous version in which this bug was not present was: 10.0.x
Description
I was using "loadTranslations" to dynamically load translations at runtime. Example:
This worked until Angular 10.1.0. Now build breaks with this error message:
The problem is that "loadTranslations" use "MessageId" and "TargetMessage" (
angular/packages/localize/src/utils/src/messages.ts
Line 40 in fdea180
angular/packages/localize/src/utils/src/messages.ts
Line 9 in fdea180
So it depends on Node.js (therefore, it cannot be used in a browser).
The problem is just with typings. There is simple solution. Divide messages.ts into 2 files (one that contains types that are dependent on Node and the second that is independent).
A clear and concise description of the problem...🔥 Exception or Error
🌍 Your Environment
**Angular Version: **
The text was updated successfully, but these errors were encountered: