mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Enables the `esModuleInterop` for all TypeScript compilations in the project. This allows us to emit proper ESM-compatible code. e.g. consider the following import: ```ts import * as ts from 'typescript'; ``` This import currently will break at runtime in NodeJS because the `typescript` package is not shipping ESM. It's still a CommonJS module. ES modules are able to import from `typescript` though, using an import statement as above, but everything in `module.exports` is being exposed as the `default` named export. TypeScript at runtime does not have any other named exports, so for actual ESM compatibility, all of our imports need to be switched to: ``` import ts from 'typescript'; ``` The `esModuleInterop` option allows this to work even though the `d.ts` file of TS currently suggests that there are _only_ named exports. The TypeScript language service will now suggest the correct import form as shown above. It doesn't enforce that unfortunately, but this commit also adds a lint rule that enforces certain patterns so that we emit imports that are compatible with both ESM and CJS output (CJS still needed here since tests run with CJS devmode output still; this is a future project to switch that over to ESM!) PR Close #43431
56 lines
1.9 KiB
JSON
56 lines
1.9 KiB
JSON
{
|
|
"compilerOptions": {
|
|
// Setting the "baseUrl" to a different directory than "packages/" because otherwise
|
|
// packages like the native "http" module are resolved to the Angular "http" package.
|
|
"baseUrl": "..",
|
|
"declaration": true,
|
|
"downlevelIteration": true,
|
|
"experimentalDecorators": true,
|
|
"emitDecoratorMetadata": true,
|
|
"module": "es2020",
|
|
"strict": true,
|
|
"moduleResolution": "node",
|
|
"esModuleInterop": true,
|
|
"strictNullChecks": true,
|
|
"strictPropertyInitialization": true,
|
|
"outDir": "../dist/all/@angular",
|
|
"noImplicitAny": true,
|
|
"noImplicitOverride": true,
|
|
"useUnknownInCatchVariables": false,
|
|
"noFallthroughCasesInSwitch": true,
|
|
"paths": {
|
|
"selenium-webdriver": ["./node_modules/@types/selenium-webdriver/index.d.ts"],
|
|
"rxjs/*": ["./node_modules/rxjs/*"],
|
|
"@angular/*": ["./packages/*"],
|
|
"zone.js/*": ["./packages/zone.js/*"],
|
|
"angular-in-memory-web-api": ["./packages/misc/angular-in-memory-web-api/index.ts"]
|
|
},
|
|
"rootDir": ".",
|
|
"inlineSourceMap": true,
|
|
"lib": ["es2020", "dom"],
|
|
"skipDefaultLibCheck": true,
|
|
"skipLibCheck": true,
|
|
"target": "es2020",
|
|
"types": ["angular"]
|
|
},
|
|
"bazelOptions": {
|
|
"suppressTsconfigOverrideWarnings": true
|
|
},
|
|
"exclude": [
|
|
"bazel",
|
|
"common/locales",
|
|
"compiler-cli/integrationtest",
|
|
"compiler-cli/test/compliance",
|
|
"core/schematics",
|
|
"elements/schematics",
|
|
// Do not build the example package because there are no legacy tests that need to be
|
|
// built. Additionally the examples are not made compatible with the "strict" option.
|
|
"examples/**",
|
|
// Http doesn't need to built since it is no longer maintained and
|
|
// will be removed eventually. See: FW-1392.
|
|
"http/**",
|
|
"language-service/test/project",
|
|
"platform-server/integrationtest",
|
|
"router/test/aot_ngsummary_test"
|
|
]
|
|
}
|