You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(bazel): remove unused ESM2022 from APF (angular#57559)
We have removed the `esm2022` directory from the generated package, as it was unused and contributed 7.7 MB to `@angular/core`. The `ng_package` rule still passes `esm2022` to the packager to perform `analyzeFileAndEnsureNoCrossImports`. A moment of reflection: You've always been there, full of potential, yet never called upon. Now, we bid you farewell. PR Closeangular#57559
Copy file name to clipboardExpand all lines: adev/src/content/tools/libraries/angular-package-format.md
+6-27Lines changed: 6 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,21 +26,16 @@ The following example shows a simplified version of the `@angular/core` package'
26
26
27
27
```markdown
28
28
node_modules/@angular/core
29
-
├── README.md
30
-
├── package.json
31
-
├── index.d.ts
32
-
├── esm2022
33
-
│ ├── core.mjs
34
-
│ ├── index.mjs
35
-
│ ├── public_api.mjs
36
-
│ └── testing
37
-
├── fesm2022
29
+
├── README.md
30
+
├── package.json
31
+
├── index.d.ts
32
+
├── fesm2022
38
33
│ ├── core.mjs
39
34
│ ├── core.mjs.map
40
35
│ ├── testing.mjs
41
36
│ └── testing.mjs.map
42
-
└── testing
43
-
└── index.d.ts
37
+
└── testing
38
+
└── index.d.ts
44
39
```
45
40
46
41
This table describes the file layout under `node_modules/@angular/core` annotated to describe the purpose of files and directories:
@@ -50,8 +45,6 @@ This table describes the file layout under `node_modules/@angular/core` annotate
50
45
|`README.md`| Package README, used by npmjs web UI. |
51
46
|`package.json`| Primary `package.json`, describing the package itself as well as all available entrypoints and code formats. This file contains the "exports" mapping used by runtimes and tools to perform module resolution. |
52
47
|`index.d.ts`| Bundled `.d.ts` for the primary entrypoint `@angular/core`. |
53
-
|`esm2022/` <br />   ─ `core.mjs` <br />   ─ `index.mjs` <br />   ─ `public_api.mjs`| Tree of `@angular/core` sources in unflattened ES2022 format. |
54
-
|`esm2022/testing/`| Tree of the `@angular/core/testing` entrypoint in unflattened ES2022 format. |
55
48
|`fesm2022/` <br />   ─ `core.mjs` <br />   ─ `core.mjs.map` <br />   ─ `testing.mjs` <br />   ─ `testing.mjs.map`| Code for all entrypoints in flattened \(FESM\) ES2022 format, along with source maps. |
56
49
|`testing/`| Directory representing the "testing" entrypoint. |
57
50
|`testing/index.d.ts`| Bundled `.d.ts` for the `@angular/core/testing` entrypoint. |
@@ -96,14 +89,10 @@ The `"exports"` field has the following structure:
96
89
},
97
90
".": {
98
91
"types": "./core.d.ts",
99
-
"esm": "./esm2022/core.mjs",
100
-
"esm2022": "./esm2022/core.mjs",
101
92
"default": "./fesm2022/core.mjs"
102
93
},
103
94
"./testing": {
104
95
"types": "./testing/testing.d.ts",
105
-
"esm": "./esm2022/testing/testing.mjs",
106
-
"esm2022": "./esm2022/testing/testing.mjs",
107
96
"default": "./fesm2022/testing.mjs"
108
97
}
109
98
}
@@ -116,8 +105,6 @@ For each entrypoint, the available formats are:
116
105
| Formats | Details |
117
106
|:--- |:--- |
118
107
| Typings \(`.d.ts` files\)|`.d.ts` files are used by TypeScript when depending on a given package. |
119
-
|`es2022`| ES2022 code flattened into a single source file. |
120
-
|`esm2022`| ES2022 code in unflattened source files \(this format is included for experimentation - see [this discussion of defaults](#note-about-the-defaults-in-packagejson) for details\). |
121
108
| `default` | ES2022 code flattened into a single source.
122
109
123
110
Tooling that is aware of these keys may preferentially select a desirable code format from `"exports"`.
@@ -263,14 +250,6 @@ To generate a flattened ES Module index file, use the following configuration op
263
250
264
251
Once the index file \(for example, `my-ui-lib.js`\) is generated by ngc, bundlers and optimizers like Rollup can be used to produce the flattened ESM file.
265
252
266
-
#### Note about the defaults in package.json
267
-
268
-
As of webpack v4, the flattening of ES modules optimization should not be necessary for webpack users. It should be possible to get better code-splitting without flattening of modules in webpack.
269
-
In practice, size regressions can still be seen when using unflattened modules as input for webpack v4.
270
-
This is why `module` and `es2022` package.json entries still point to FESM files.
271
-
This issue is being investigated. It is expected to switch the `module` and `es2022` package.json entry points to unflattened files after the size regression issue is resolved.
272
-
The APF currently includes unflattened ESM2022 code for the purpose of validating such a future change.
273
-
274
253
### "sideEffects" flag
275
254
276
255
By default, EcmaScript Modules are side-effectful: importing from a module ensures that any code at the top level of that module should run.
0 commit comments