Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { readFileSync } from 'fs';
import { parse as parseJson } from 'jsonc-parser';
import { createRequire } from 'module';
import { dirname, resolve } from 'path';
import { TextEncoder } from 'util';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used an import for this, even though it's available globally, because for some reason the global variable wasn't in the typings.

import { Script } from 'vm';
import { assertIsError } from '../../utilities/error';

Expand Down Expand Up @@ -211,6 +212,12 @@ function wrap(
__dirname: schematicDirectory,
__filename: schematicFile,
Buffer,
// TextEncoder is used by the compiler to generate i18n message IDs. See:
// https://github.com/angular/angular/blob/main/packages/compiler/src/i18n/digest.ts#L17
// It is referenced globally, because it may be run either on the browser or the server.
// Usually Node exposes it globally, but in order for it to work, our custom context
// has to expose it too. Issue context: https://github.com/angular/angular/issues/48940.
TextEncoder,
console,
process,
get global() {
Expand Down