Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(drivers/framework): Fix type generation for ESM and add exports field #18824

Merged
merged 6 commits into from Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/build/build-common/tsc-multi.test.json
@@ -1,4 +1,4 @@
{
"targets": [{ "extname": ".cjs", "module": "CommonJS", "moduleResolution": "Node10" }],
"targets": [{ "extname": ".cjs", "module": "CommonJS", "moduleResolution": "Node16" }],
"projects": ["./tsconfig.json", "./src/test/tsconfig.json"]
}
34 changes: 27 additions & 7 deletions fluidBuild.config.cjs
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

const tscDependsOn = ["^tsc", "^api", "build:genver"];
const tscDependsOn = ["^tsc", "^api", "^build:rename-types", "build:genver"];
/**
* The settings in this file configure the Fluid build tools, such as fluid-build and flub. Some settings apply to the
* whole repo, while others apply only to the client release group.
Expand All @@ -23,7 +23,14 @@ module.exports = {
script: false,
},
"compile": {
dependsOn: ["commonjs", "build:esnext", "build:test", "build:copy"],
dependsOn: [
"commonjs",
"build:esnext",
"build:test",
"build:copy",
// "^build:rename-types",
tylerbutler marked this conversation as resolved.
Show resolved Hide resolved
"build:rename-types",
],
script: false,
},
"commonjs": {
Expand Down Expand Up @@ -58,10 +65,11 @@ module.exports = {
dependsOn: ["api-extractor:commonjs", "api-extractor:esnext"],
script: false,
},
"api-extractor:commonjs": [...tscDependsOn, "tsc"],
"api-extractor:esnext": [...tscDependsOn, "api-extractor:commonjs", "build:esnext"],
"build:docs": [...tscDependsOn, "tsc"],
"ci:build:docs": [...tscDependsOn, "tsc"],
"api-extractor:commonjs": ["tsc"],
"api-extractor:esnext": ["api-extractor:commonjs", "build:esnext"],
"build:rename-types": ["build:esnext", "api-extractor:esnext"],
"build:docs": ["tsc"],
"ci:build:docs": ["tsc"],
"build:readme": {
dependsOn: ["build:manifest"],
script: true,
Expand Down Expand Up @@ -159,9 +167,17 @@ module.exports = {
// Can be removed once the policy handler is updated to support tsc-multi as equivalent to tsc.
"^azure/packages/azure-client/package.json",
"^azure/packages/azure-service-utils/package.json",
"^experimental/dds/tree2/package.json",
"^experimental/dds/sequence-deprecated/package.json",
"^experimental/framework/tree-react-api/package.json",
"^packages/common/.*/package.json",
"^packages/dds/.*/package.json",
"^packages/drivers/.*/package.json",
"^packages/framework/.*/package.json",
"^packages/loader/.*/package.json",
"^packages/runtime/.*/package.json",
"^packages/service-clients/.*/package.json",
"^packages/utils/.*/package.json",
"^packages/loader/container-loader/package.json",
],
"html-copyright-file-header": [
Expand Down Expand Up @@ -217,9 +233,10 @@ module.exports = {
"^tools/getkeys",
],
"npm-package-json-esm": [
// This is an ESM-only package, and uses tsc to build the ESM output. The policy handler doesn't understand this
// These are ESM-only packages and use tsc to build the ESM output. The policy handler doesn't understand this
// case.
"packages/dds/migration-shim/package.json",
"packages/test/functional-tests/package.json",
],
// This handler will be rolled out slowly, so excluding most packages here while we roll it out.
"npm-package-exports-field": [
Expand Down Expand Up @@ -315,6 +332,9 @@ module.exports = {
["depcruise", "dependency-cruiser"],
["copyfiles", "copyfiles"],
["oclif", "oclif"],
["renamer", "renamer"],
["tsc-multi", "tsc-multi"],
["attw", "@arethetypeswrong/cli"],
],
},
// These packages are independently versioned and released, but we use pnpm workspaces in single packages to work
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/debugger/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -22,6 +34,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
"ci:build:docs": "api-extractor run",
Expand Down Expand Up @@ -57,6 +70,7 @@
"copyfiles": "^2.4.1",
"eslint": "~8.50.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/driver-base/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -24,6 +36,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -93,6 +106,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"socket.io-client": "^4.6.1",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/driver-web-cache/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -24,6 +36,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -64,6 +77,7 @@
"fake-indexeddb": "3.1.4",
"jest": "^29.6.2",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/fluidapp-odsp-urlResolver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -69,6 +82,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/local-driver/package.json
Expand Up @@ -10,6 +10,18 @@
},
"license": "MIT",
"author": "Microsoft and contributors",
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"browser": {
Expand All @@ -25,6 +37,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -107,6 +120,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"socket.io-client": "^4.6.1",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/odsp-driver-definitions/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -55,6 +68,7 @@
"cross-env": "^7.0.3",
"eslint": "~8.50.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
2 changes: 2 additions & 0 deletions packages/drivers/odsp-driver/package.json
Expand Up @@ -24,6 +24,7 @@
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:genver": "gen-version",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -102,6 +103,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"sinon": "^7.4.2",
"tsc-multi": "^1.1.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/odsp-urlResolver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -23,6 +35,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"build:test": "tsc-multi --config ./tsc-multi.test.json",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
Expand Down Expand Up @@ -67,6 +80,7 @@
"mocha-multi-reporters": "^1.5.1",
"moment": "^2.21.0",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down
14 changes: 14 additions & 0 deletions packages/drivers/replay-driver/package.json
Expand Up @@ -11,6 +11,18 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.cjs"
}
}
},
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -22,6 +34,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
"check:are-the-types-wrong": "attw --pack",
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
"ci:build:docs": "api-extractor run",
Expand Down Expand Up @@ -60,6 +73,7 @@
"eslint": "~8.50.0",
"nock": "^13.3.3",
"prettier": "~3.0.3",
"renamer": "^4.0.0",
"rimraf": "^4.4.0",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
Expand Down