Skip to content

Commit 8f8b0bc

Browse files
authored
feat!: libraries only export (valid) ES modules (#405)
The ES module exports are now actually valid (they lacked the `.js` extension required to point to real paths in some of the packages). To avoid having to change all import paths in the TypeScript code itself, we use `esnext/bundler` instead of `nodenext/nodenext` module resolution. While the latter was slightly simpler as it did not need e.g. esbuild, the `topbar` code was already quite large, so it was easier to switch to bundler (and then do that for all packages so they are aligned). BREAKING: - libraries are now only exported as (native) ES modules NOTE: Fluent UI packages are still missing extensions for most ES module imports, which is upsetting Node.js, cfr [this issue](microsoft/fluentui#30634) This means that for testing, you will need to (partially) bundle these. With vitest, you can do this by providing packages to be optimized: ``` test: { deps: { optimizer: { web: { enabled: true, include: [<package-name>, ...], }}}, }, ``` - generated tokens are not included in the repo, you need to run the `fluent-theme-tokens` command which comes with the `@axiscommunications/fluent-theme` package to generate them TLDR: - all packages are of type "module" and use the "export" field - TypeScript is updated to v5 which supports "bundler" resolution and that is used throughout - type declarations are built with tsc using tsconfig.build.json which excludes any test sources (if present) - bundles are produced using esbuild CLI (no config file), which fixes some packages that did not have proper extensions as ES modules. NOTE: these are not minifed bundles as in `.min.js` as we don't directly use modules in production yet) - ts-node is removed as it's no longer up-to-date and cannot handle ES modules properly connected to unresolved issues. Scripts use JS for now (until e.g. Node.js allows running TS directly). - lodash was removed (instead of replacing with lodash-es) - vitest + coverage was updated to v3, vite to v6
1 parent b6456a8 commit 8f8b0bc

File tree

104 files changed

+1323
-8001
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1323
-8001
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ updates:
1111
- "minor"
1212
- "patch"
1313
patterns:
14+
- "*esbuild*"
1415
- "*vite*"
1516
- "*biome*"
1617
- "depcheck"
17-
- "ts-node"
1818
- "typescript"
1919
fluent:
2020
update-types:

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup node
2222
uses: actions/setup-node@v3
2323
with:
24-
node-version: 18
24+
node-version: 22
2525

2626
- name: Install dependencies
2727
run: |

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup node
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: "18"
27+
node-version: 22
2828
registry-url: "https://npm.pkg.github.com"
2929
scope: "@axiscommunications"
3030

.github/workflows/verify-icons.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18
23+
node-version: 22
2424

2525
- name: Install dependencies
2626
run: |

.github/workflows/verify-illustrations.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18
23+
node-version: 22
2424

2525
- name: Install dependencies
2626
run: |

.github/workflows/verify-page.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup node
2222
uses: actions/setup-node@v3
2323
with:
24-
node-version: 18
24+
node-version: 22
2525

2626
- name: Install dependencies
2727
run: |

.github/workflows/verify-tokens.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18
23+
node-version: 22
2424

2525
- name: Install dependencies
2626
run: |
2727
corepack enable
2828
corepack prepare --activate
2929
pnpm install --frozen-lockfile
3030
31+
- name: Build theme library and token generator
32+
run: pnpm --filter @axiscommunications/fluent-theme build
33+
3134
- name: Transform Fluent Theme to JSON, builds tokens for platforms
32-
run: pnpm --filter @axiscommunications/fluent-theme tokens:runall
35+
run: pnpm --filter @axiscommunications/fluent-theme tokens
3336

34-
- name: Build theme
35-
run: pnpm --filter @axiscommunications/fluent-theme build

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup node
2121
uses: actions/setup-node@v3
2222
with:
23-
node-version: 18
23+
node-version: 22
2424

2525
- name: Install dependencies
2626
run: |

components/empty-view/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,29 @@
2020
"files": ["lib"],
2121
"scripts": {
2222
"prebuild": "pnpm run -C ../../illustrations build",
23-
"build": "pnpm prebuild && tsc",
23+
"build": "pnpm prebuild && pnpm build:types && pnpm build:esm",
24+
"build:esm": "esbuild --format=esm --bundle --sourcemap --packages=external --outdir=lib src/index.ts",
25+
"build:types": "tsc -p tsconfig.build.json",
2426
"check:unused-deps": "depcheck . --config=depcheck.yml",
2527
"lint": "tsc --noEmit && biome check"
2628
},
29+
"dependencies": {
30+
"@axiscommunications/fluent-hooks": "workspace: *",
31+
"@axiscommunications/fluent-illustrations": "workspace:*"
32+
},
2733
"devDependencies": {
2834
"@types/react": "^18.3.12",
2935
"@types/react-dom": "^18.3.1",
36+
"esbuild": "^0.25.0",
3037
"react": "^18.2.0",
3138
"react-dom": "^18.2.0",
32-
"typescript": "^4.5.5"
39+
"typescript": "^5.8.2"
3340
},
3441
"peerDependencies": {
3542
"@fluentui/react-components": "^9.58.2",
3643
"react": ">=16.8.0 <19.0.0",
3744
"react-dom": ">=16.8.0 <19.0.0"
3845
},
39-
"dependencies": {
40-
"@axiscommunications/fluent-hooks": "workspace: *",
41-
"@axiscommunications/fluent-illustrations": "workspace:*"
42-
},
4346
"publishConfig": {
4447
"registry": "https://npm.pkg.github.com/"
4548
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"emitDeclarationOnly": true,
6+
"outDir": "lib"
7+
}
8+
}

0 commit comments

Comments
 (0)