Skip to content

Commit b5b4549

Browse files
authored
build(test-loader-utils): use node16 module resolution (#20237)
Semi-automatic PR to switch to node16 module resolution
1 parent 818c96f commit b5b4549

File tree

8 files changed

+45
-19
lines changed

8 files changed

+45
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
4+
// CJS is actually secondary; so, no report.
5+
"apiReport": {
6+
"enabled": false
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"extends": "../../../common/build/build-common/api-extractor-lint.json"
3+
"extends": "../../../common/build/build-common/api-extractor-lint.esm.primary.json"
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"extends": "../../../common/build/build-common/api-extractor-base.json"
3+
"extends": "../../../common/build/build-common/api-extractor-base.esm.primary.json"
44
}

packages/loader/test-loader-utils/package.json

+21-7
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,43 @@
1111
"license": "MIT",
1212
"author": "Microsoft and contributors",
1313
"sideEffects": false,
14-
"type": "commonjs",
14+
"type": "module",
15+
"exports": {
16+
".": {
17+
"import": {
18+
"types": "./lib/index.d.ts",
19+
"default": "./lib/index.js"
20+
},
21+
"require": {
22+
"types": "./dist/index.d.ts",
23+
"default": "./dist/index.js"
24+
}
25+
}
26+
},
1527
"main": "dist/index.js",
16-
"module": "dist/index.js",
1728
"types": "dist/index.d.ts",
1829
"scripts": {
1930
"api": "fluid-build . --task api",
20-
"api-extractor:commonjs": "api-extractor run --local",
31+
"api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
32+
"api-extractor:esnext": "api-extractor run --local",
2133
"build": "fluid-build . --task build",
2234
"build:compile": "fluid-build . --task compile",
2335
"build:docs": "fluid-build . --task api",
24-
"check:are-the-types-wrong": "attw --pack",
36+
"build:esnext": "tsc --project ./tsconfig.json",
37+
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
2538
"check:biome": "biome check .",
2639
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
2740
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
2841
"ci:build:docs": "api-extractor run",
29-
"clean": "rimraf --glob dist \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp",
42+
"clean": "rimraf --glob dist \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp lib",
3043
"eslint": "eslint --format stylish src",
3144
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
3245
"format": "fluid-build --task format .",
3346
"format:biome": "biome check --apply .",
3447
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
3548
"lint": "fluid-build . --task lint",
3649
"lint:fix": "fluid-build . --task eslint:fix --task format",
37-
"tsc": "tsc"
50+
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist"
3851
},
3952
"dependencies": {
4053
"@fluid-internal/client-utils": "workspace:~",
@@ -62,7 +75,8 @@
6275
"build:docs": {
6376
"dependsOn": [
6477
"...",
65-
"api-extractor:commonjs"
78+
"api-extractor:commonjs",
79+
"api-extractor:esnext"
6680
],
6781
"script": false
6882
}

packages/loader/test-loader-utils/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
* Licensed under the MIT License.
44
*/
55

6-
export { MockDocumentDeltaStorageService } from "./mockDeltaStorage";
7-
export { MockDocumentService } from "./mockDocumentService";
8-
export { MockDocumentDeltaConnection } from "./mockDocumentDeltaConnection";
6+
export { MockDocumentDeltaStorageService } from "./mockDeltaStorage.js";
7+
export { MockDocumentService } from "./mockDocumentService.js";
8+
export { MockDocumentDeltaConnection } from "./mockDocumentDeltaConnection.js";

packages/loader/test-loader-utils/src/mockDocumentService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
IResolvedUrl,
1414
} from "@fluidframework/driver-definitions";
1515
import { IClient, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
16-
import { MockDocumentDeltaStorageService } from "./mockDeltaStorage";
17-
import { MockDocumentDeltaConnection } from "./mockDocumentDeltaConnection";
16+
import { MockDocumentDeltaStorageService } from "./mockDeltaStorage.js";
17+
import { MockDocumentDeltaConnection } from "./mockDocumentDeltaConnection.js";
1818

1919
/**
2020
* Mock Document Service for testing.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// This config must be used in a "type": "commonjs" environment. (Use `fluid-tsc commonjs`.)
3+
"extends": "./tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "./dist",
6+
},
7+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
2-
"extends": [
3-
"../../../common/build/build-common/tsconfig.base.json",
4-
"../../../common/build/build-common/tsconfig.cjs.json",
5-
],
2+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
63
"include": ["src/**/*"],
74
"exclude": ["dist", "node_modules"],
85
"compilerOptions": {
96
"rootDir": "./src",
10-
"outDir": "./dist",
7+
"outDir": "./lib",
118
},
129
}

0 commit comments

Comments
 (0)