Commit e9f7bd6
authored
feat: add CJS build output for dual format (#518)
Ideally we want to use ESM, but the reality is that
@fluentui/react-theme (and other Fluent packages) ESM lacks Node.js
compliance (missing .js extensions) - it works in bundlers but not in
Node.js.
This means downstream tools are forced to use a CJS bundler, which can
`require` Fluent UI from `node_modules` because Fluent has CJS exports
as a fallback.
However, this package doesn't provide CJS, so such a downstream bundler
cannot `require` it and must bundle our source into its own dist instead.
By adding CJS here, downstream libraries can externalize us from
node_modules, reducing their bundle sizes. Otherwise we become a nested
dependency.
- Add build:cjs script and lib-commonjs output
- Update exports with require condition
- Remove "type": "module" for dual-format semantics1 parent 1051da4 commit e9f7bd6
File tree
4 files changed
+210
-7
lines changed- theme
- lib-commonjs
4 files changed
+210
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
0 commit comments