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
Copy file name to clipboardExpand all lines: rfcs/build-system/02_standard_package_output_folders.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,12 @@ Today, `lib` contains esm JavaScript output, except for node-only packages which
20
20
21
21
We've historically used the following standard output folders in a published JavaScript package (only applicable output folders would be present):
22
22
23
-
-`lib` - esm (as we've had for a long time)
24
-
-`lib-commonjs` - commonjs (only needed while Node <= 13.2.0 is supported)
25
-
-`lib-amd` - amd (hopefully we can drop someday)
26
-
-`dist` - bundles and static content
23
+
-`/lib` - esm (as we've had for a long time)
24
+
-`/lib-commonjs` - commonjs (only needed while Node <= 13.2.0 is supported)
25
+
-`/lib-amd` - amd (hopefully we can drop someday)
26
+
-`/dist` - bundles and static content
27
27
28
-
If this seems reasonable to folks, we should just stick with this and stay consistent. If a library needs to output CommonJS, it should go inthe`lib-commonjs` folder.
28
+
If this seems reasonable, we should adopt and stay consistent to stay predictable to consumers. If a library needs to output CommonJS, it should be output within the`lib-commonjs` folder.
29
29
30
30
A library like `react-button` which might be consumed by Node and bundlers likely will need both ESM and CommonJS, until Node 13.2.0 or greater is the minimum requirement. Its output will have both a `lib` and `lib-commonjs` folder.
31
31
@@ -52,12 +52,10 @@ Once 13.2.0 becomes the minimum Node requirement, there is little reason to buil
52
52
53
53
Many libraries in OSS have kept `lib` representing CommonJS and have added `es` to the mix as the folder for containing esm. This is very likely because they've existed for a while and didn't want to change their existing folder structure. We could also consider this convention. React itself avoids `lib` and explicitly uses `cjs` to indicate the output format. (It also has no ESM flavor.)
54
54
55
-
#### Alternative proposal:
56
-
57
-
*`cjs` - CommonJS
58
-
*`es` - esm
59
-
*`amd` - amd
60
-
*`dist` - statics and bundles
55
+
*`/cjs` - CommonJS
56
+
*`/es` - esm
57
+
*`/amd` - amd
58
+
*`/dist` - statics and bundles
61
59
62
60
#### Pros:
63
61
@@ -85,3 +83,4 @@ Many libraries in OSS have kept `lib` representing CommonJS and have added `es`
85
83
## Discarded Solutions
86
84
87
85
The current solution of using `lib` for either CommonJS or ESM depending on which platforms are (currently) supported should be replaced with something that doesn't mean different things in different contexts.
0 commit comments