components icon indicating copy to clipboard operation
components copied to clipboard

bug(package): Unannounced breaking change: new package structure requires `exports` field support

Open thw0rted opened this issue 3 years ago • 0 comments
trafficstars

Is this a regression?

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

The previous version in which this bug was not present was

13.3.9

Description

Until v13.x, @angular/material shipped with one top level package.json, as well as individual package.json files for each component, e.g. @angular/material/button/package.json. As part of the 14.0 update, these individual component-level files were removed. Instead, the top level package.json exposes path resolutions for each version of each component via a series of exports entries. As a result, any consumer that does not understand or respect the exports field in the top level package.json becomes incompatible with this library.

Reproduction

Steps to reproduce: Clone this repro and execute npm run start. The build should be successful.

Clone the same thing updated to v14 of Angular and Material, and run the same command. You will see:

ERROR in ./src/app/app.module.ts 29:17-52 Module not found: Error: Can't resolve '@angular/material/button' in 'path\to\src\app' resolve '@angular/material/button' in 'path\to\src\app'

Note that the Webpack config uses resolve.exportsFields: [] to ignore the exports field.

Expected Behavior

Consumers that do not understand the exports field should still be able to use the library.

(If the files are not restored, and exports-field support is required going forward, this is a breaking change and should be documented as such in the change log, dating back to 14.0.0.)

Actual Behavior

Consumers that don't understand, or intentionally ignore, the exports field can no longer use the library.

Ignoring the exports field is the recommended solution suggested by Webpack, when using a library that fails to explicitly export a resource you need to consume. I am stuck with such a library, I've had an open issue with them to fix it for over a year and I'm not happy about it, but there is literally nothing else I can do. Still, this is the first time I've run into a library that does not work at all when the exports field is ignored / unsupported.

Environment

  • Angular: 14.0.6
  • CDK/Material: 14.0.5
  • Browser(s): N/A
  • Operating System (e.g. Windows, macOS, Ubuntu): Win10

thw0rted avatar Jul 19 '22 14:07 thw0rted