Skip to content

Angular 16 with esbuild throws [ERROR] Could not resolve "src/polyfills.ts" #25341

Closed
@NudeFox

Description

@NudeFox

Command

build, serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Enabling the "builder": "@angular-devkit/build-angular:browser-esbuild" in angular.json leads to the following error

Minimal Reproduction

  1. enable esbuild
  2. run ng serve or ng build
  3. tsconfig.json
{
    "compileOnSave": false,
    "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "baseUrl": "src/",
    "declaration": false,
    "downlevelIteration": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "importHelpers": false,
    "lib": [
	"ES2022",
        "dom",
        "esnext.asynciterable"
    ],
    "module": "ES2022",
    "moduleResolution": "node",
    "noUnusedLocals": true,
    "outDir": "./dist/out-tsc",
    "paths": {
      "@app/*": [
        "app/*"
      ],
      "@env/*": [
        "environments/*"
      ],
      "@auth/*": [
        "app/auth/*"
      ],
      "@layout/*": [
        "app/layout/*"
      ],
      "@core/*": [
        "app/core/*"
      ],
      "@shared/*": [
        "app/shared/*"
      ],
      "@svg-icons": [
        "app/config/svg-icons.config"
      ]
    },
    "resolveJsonModule": true,
    "sourceMap": false,
    "target": "ES2022",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": [
      "jest",
      "node"
    ],
    "useDefineForClassFields": false
  },
  "angularCompilerOptions": {
	"fullTemplateTypeCheck": true,
	"strictInjectionParameters": true
  },
  "exclude": [
	"node_modules"
  ]
}

Exception or Error

[ERROR] Could not resolve "src/polyfills.ts"
angular:polyfills:entry:1:7:
      1 │ import 'src/polyfills.ts';
        ╵        ~~~~~~~~~~~~~~~~~~

  You can mark the path "src/polyfills.ts" as external to exclude it from the bundle, which will remove this error.

Your Environment

Angular CLI: 16.0.5
Node: 18.16.0
Package Manager: npm 9.5.1
OS: darwin x64

Angular: 16.0.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.5
@angular-devkit/build-angular   16.0.5
@angular-devkit/core            16.0.5
@angular-devkit/schematics      16.0.5
@angular/cdk                    16.0.3
@angular/cli                    16.0.5
@angular/flex-layout            15.0.0-beta.42
@angular/material               16.0.3
@schematics/angular             16.0.5
rxjs                            7.8.1
typescript                      5.0.4
webpack                         5.86.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions