Skip to content

Import errors with Angular 21, Signal Forms and other sub modules #102

@fabiobiondi

Description

@fabiobiondi

Hi, I'm not sure if this is the right repository to share this issue with.
Anyway, I have a problem to run examples using Angular 21, problems that I never had until Angular 20 (and 21 next 2).
i'm not using Web Container / Node (that work instead) but I prefer the "old" client side approach because it's faster to load.

It seems to be having trouble importing submodules like:

Main.ts:

import { provideHttpClient, withFetch } from '@angular/common/http';

in any component:

import { form, FormField } from '@angular/forms/signals';

The error is:

Cannot find module '@angular/forms/signals' or its corresponding type declarations.

I created an example to reproduce the problem:
https://stackblitz.com/edit/angular-xtzhxq6u?devtoolsheight=75&file=src%2Fapp.ts,src%2Fmain.ts&theme=light
(The example works fine if i remove these imports from main.ts and app.ts)

I'm not sure but it seems the problem is with the secondary entrypoints of the "parent" library and the parent lib doesn't expose them (see image)

Image

Note: this is the package.json of @angular/forms package (from your Angular Starter Kit) and there is the signal/forms export :

{
  "name": "@angular/forms",
  "version": "21.1.0",
  "description": "Angular - directives and services for creating forms",
  "author": "angular",
  "license": "MIT",
  "engines": {
    "node": "^20.19.0 || ^22.12.0 || >=24.0.0"
  },
  "dependencies": {
    "tslib": "^2.3.0",
    "@standard-schema/spec": "^1.0.0"
  },
  "peerDependencies": {
    "@angular/core": "21.1.0",
    "@angular/common": "21.1.0",
    "@angular/platform-browser": "21.1.0",
    "rxjs": "^6.5.3 || ^7.4.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/angular/angular.git",
    "directory": "packages/forms"
  },
  "angular": {
    "examples": {
      "format": "sqlite",
      "path": "./resources/code-examples.db"
    }
  },
  "ng-update": {
    "packageGroup": [
      "@angular/core",
      "@angular/bazel",
      "@angular/common",
      "@angular/compiler",
      "@angular/compiler-cli",
      "@angular/animations",
      "@angular/elements",
      "@angular/platform-browser",
      "@angular/platform-browser-dynamic",
      "@angular/forms",
      "@angular/platform-server",
      "@angular/upgrade",
      "@angular/router",
      "@angular/language-service",
      "@angular/localize",
      "@angular/service-worker"
    ]
  },
  "sideEffects": false,
  "module": "./fesm2022/forms.mjs",
  "typings": "./types/forms.d.ts",
  "type": "module",
  "exports": {
    "./package.json": {
      "default": "./package.json"
    },
    ".": {
      "types": "./types/forms.d.ts",
      "default": "./fesm2022/forms.mjs"
    },
    "./signals": {
      "types": "./types/signals.d.ts",
      "default": "./fesm2022/signals.mjs"
    },
    "./signals/compat": {
      "types": "./types/signals-compat.d.ts",
      "default": "./fesm2022/signals-compat.mjs"
    }
  }
}

Have you got any advice or do you know what is the problem?

Thank you
Fabio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions