Skip to content

Commit

Permalink
[Port v2int/7.4] Reduce v2int7.4 bundle size (microsoft#19187)
Browse files Browse the repository at this point in the history
Ported PRs: 
- microsoft#18822
- microsoft#18825

## Description
Our partner team notified us of a 150kb increase in size when consuming
`2.0.0-internal.7.4.x`. After an investigation into our bundle size
telemetry, it was determined that these two commits in main had reduced
the bundle size by about ~100kb.

## Impact
Reduce bundle size by ~100kb.

---------

Co-authored-by: Tyler Butler <tylerbu@microsoft.com>
  • Loading branch information
tyler-cai-microsoft and tylerbutler authored Jan 10, 2024
1 parent 298cb80 commit f9ef2f9
Show file tree
Hide file tree
Showing 28 changed files with 857 additions and 1,983 deletions.
2 changes: 1 addition & 1 deletion common/build/build-common/tsc-multi.test.json
Original file line number Diff line number Diff line change
@@ -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"]
}
33 changes: 26 additions & 7 deletions fluidBuild.config.cjs
Original file line number Diff line number Diff line change
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,13 @@ module.exports = {
script: false,
},
"compile": {
dependsOn: ["commonjs", "build:esnext", "build:test", "build:copy"],
dependsOn: [
"commonjs",
"build:esnext",
"build:test",
"build:copy",
"build:rename-types",
],
script: false,
},
"commonjs": {
Expand Down Expand Up @@ -58,10 +64,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 +166,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 +232,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 +331,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
2 changes: 1 addition & 1 deletion packages/common/client-utils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ module.exports = {
},
],
],
testMatch: ["**/dist/test/jest/?(*.)+(spec|test).js"],
testMatch: ["**/dist/test/jest/?(*.)+(spec|test).?js"],
testPathIgnorePatterns: ["/node_modules/"],
};
41 changes: 13 additions & 28 deletions packages/common/client-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"license": "MIT",
"author": "Microsoft and contributors",
"sideEffects": false,
"main": "dist/index.js",
"module": "lib/index.js",
"main": "dist/index.cjs",
"module": "lib/index.mjs",
"browser": {
"./dist/indexNode.js": "./dist/indexBrowser.js",
"./lib/indexNode.js": "./lib/indexBrowser.js"
"./dist/indexNode.cjs": "./dist/indexBrowser.cjs",
"./lib/indexNode.mjs": "./lib/indexBrowser.mjs"
},
"types": "dist/index.d.ts",
"scripts": {
Expand All @@ -26,11 +26,9 @@
"build:commonjs": "fluid-build . --task commonjs",
"build:compile": "fluid-build . --task compile",
"build:docs": "fluid-build . --task api",
"build:esnext": "tsc --project ./tsconfig.esnext.json",
"build:test": "concurrently npm:build:test:mocha npm:build:test:jest npm:build:test:types",
"build:test:jest": "tsc --project ./src/test/jest/tsconfig.json",
"build:test:mocha": "tsc --project ./src/test/mocha/tsconfig.json",
"build:test:types": "tsc --project ./src/test/types/tsconfig.json",
"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",
"ci:build:docs": "api-extractor run",
Expand All @@ -45,8 +43,8 @@
"test": "npm run test:mocha && npm run test:jest",
"test:coverage": "c8 npm test",
"test:jest": "jest",
"test:mocha": "mocha --recursive \"dist/test/mocha/**/*.spec.js\" --exit --project test/tsconfig.json",
"tsc": "tsc",
"test:mocha": "mocha --recursive \"dist/test/mocha/**/*.spec.?js\" --exit --project test/tsconfig.json",
"tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
"typetests:gen": "fluid-type-test-generator",
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
},
Expand Down Expand Up @@ -82,6 +80,7 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.13.3",
"@fluid-internal/client-utils-previous": "npm:@fluid-internal/client-utils@2.0.0-internal.7.3.0",
"@fluid-tools/build-cli": "^0.28.0",
"@fluidframework/build-common": "^2.0.3",
"@fluidframework/build-tools": "^0.28.0",
Expand Down Expand Up @@ -112,42 +111,28 @@
"moment": "^2.21.0",
"prettier": "~3.0.3",
"puppeteer": "^17.1.3",
"renamer": "^4.0.0",
"rewire": "^5.0.0",
"rimraf": "^4.4.0",
"sinon": "^7.4.2",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tsc-multi": "^1.1.0",
"typescript": "~5.1.6"
},
"fluidBuild": {
"tasks": {
"eslint": [
"tsc",
"build:test:mocha",
"build:test:jest",
"build:test:types"
],
"build:docs": {
"dependsOn": [
"...",
"api-extractor:commonjs",
"api-extractor:esnext"
],
"script": false
},
"build:test:jest": [
"tsc"
],
"build:test:mocha": [
"tsc"
],
"build:test:types": [
"tsc"
]
}
}
},
"typeValidation": {
"disabled": true,
"broken": {}
}
}
2 changes: 1 addition & 1 deletion packages/common/client-utils/src/test/jest/gitHash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import rewire from "rewire";
import * as HashNode from "../../hashFileNode";

// Use rewire to access private functions
const HashBrowser = rewire("../../hashFileBrowser");
const HashBrowser = rewire("../../hashFileBrowser.cjs");

async function getFileContents(p: string): Promise<Buffer> {
return new Promise<Buffer>((resolve, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { strict as assert } from "node:assert";
import { EventEmitter } from "node:events";
import { IErrorEvent } from "@fluidframework/core-interfaces";
import { EventForwarder } from "../..";
import { EventForwarder } from "../../eventForwarder";

interface ITestEvents extends IErrorEvent {
(event: "testEvent", listener: (name: string, count: number) => void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import { strict as assert } from "node:assert";
import { IErrorEvent } from "@fluidframework/core-interfaces";
import { TypedEventEmitter } from "../..";
import { TypedEventEmitter } from "../../typedEventEmitter";

describe("TypedEventEmitter", () => {
it("Validate Function proxies", () => {
Expand Down
Loading

0 comments on commit f9ef2f9

Please sign in to comment.