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

Better dual ESM/CJS support, tsconfig module now Node16, improved pnpm support #791

Merged
merged 38 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2354d69
Use Audience in LivePresence for setting online/offline state, delete…
Jul 29, 2024
07291f5
comment
Jul 29, 2024
23119c7
use aggregated connection state for LivePresenceUser connection state…
Jul 30, 2024
eddbac6
improving docs
Jul 30, 2024
5f88b2f
undo change
Jul 30, 2024
0b0117a
remove state param from initialize
Jul 30, 2024
9169542
fixed tests, updated react usePresence
Jul 30, 2024
4f93b3c
fix test
Jul 31, 2024
9c047f8
updating versions, adding module entry to package.json
Jul 31, 2024
aa61b13
changed live share and live share media to module node16
Jul 31, 2024
2d67ab6
tsc alias and package.json extra field in cjs
Aug 1, 2024
8cf678a
removed tsc-alias
Aug 2, 2024
e5dec83
add more extensions
Aug 6, 2024
85ef5c8
apply suggestion from Jason Hartman, delete main index file, use the …
Aug 6, 2024
bbda18d
made same changes to canvas, acs and react
Aug 7, 2024
f078148
moved cjs and esm build to script
Aug 7, 2024
66351d2
updating peer dependencies
Aug 7, 2024
790a0e1
updating tsconfig path
Aug 7, 2024
900e6f8
doctor
Aug 7, 2024
eb75566
add workflow dispatch
Aug 7, 2024
f4635f8
get pipeline to run temporarily
Aug 7, 2024
d54bbbe
remove redundant step
Aug 7, 2024
54d0a80
cleanup
Aug 7, 2024
b3c709b
cleanup
Aug 7, 2024
830f7ec
fix bug with wrong package.json type, changed when moving to script
Aug 7, 2024
ee021b5
fix resolution of live-share/internal when using node10
Aug 7, 2024
e2456b9
added @fluidframework/azure-client to depenencies, instead of devDepe…
Aug 8, 2024
47e0083
ensure pnpm is supported and add a CI check
Aug 8, 2024
85df942
ensure pnpm is supported and add a CI check
Aug 8, 2024
0bdda4e
deleted lock
Aug 8, 2024
c42c4db
better usage tests
Aug 9, 2024
f8d858d
update working dir
Aug 9, 2024
180f172
fixed path
Aug 9, 2024
ff50ec0
optimize test-for-race-conditions
Aug 12, 2024
8841bd0
move ff version to 2.0
Aug 13, 2024
85d950c
cleanup
Aug 13, 2024
8e03007
cleanup
Aug 13, 2024
bf9d6ce
fix merge conflicts
Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ name: "CodeQL"

on:
push:
branches: ["main", main*]
branches: [main, mainv2]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main", "main*"]
branches: [main, mainv2, jameshunt/presence-with-audience-state]
schedule:
- cron: "0 2 * * 6"
workflow_dispatch:

jobs:
analyze:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/live-share-build-samples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches: [main, mainv2]
pull_request:
branches: [main, mainv2]
branches: [main, mainv2, jameshunt/presence-with-audience-state]
workflow_dispatch:

jobs:
build:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/live-share-formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches: [main, mainv2]
pull_request:
branches: [main, mainv2]
branches: [main, mainv2, jameshunt/presence-with-audience-state]
workflow_dispatch:

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/live-share-test-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches: [main, mainv2]
pull_request:
branches: [main, mainv2]
branches: [main, mainv2, jameshunt/presence-with-audience-state]
workflow_dispatch:

jobs:
build:
Expand All @@ -20,8 +21,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build:packages
- run: npm install # install will trigger a build of all packages

- name: "test live-share"
run: npm run test
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/live-share-test-usage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Test Usage of Live Share SDK packages in different JS environments

on:
push:
branches: [main, mainv2]
pull_request:
branches: [main, mainv2, jameshunt/presence-with-audience-state]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install # install will trigger a build of all packages

- name: "test live-share with cjs app"
run: npm run test
working-directory: internal/usage-test/cjs-test

- name: "test live-share with esm app"
run: npm run test
working-directory: internal/usage-test/esm-test

- uses: pnpm/action-setup@v4
name: Install pnpm for next step
with:
version: 9
run_install: false
- name: "test live-share with pnpm typescript esm app"
run: pnpm run test
working-directory: internal/usage-test/pnpm-test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,5 @@ docs/assets/main.js
coverage/
nyc/
.nyc_output/
build-data.json
build-data.json
tsconfig.tsbuildinfo
55 changes: 55 additions & 0 deletions internal/build-tools/build-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Tool used to consolidate building package with different outputs of esm, cjs, or cjs with tests included.
* Invokation with all arguments looks like `node <path>/build-package.js --cjs --esm --test`
*/

const childProcess = require("child_process");
const fs = require("fs");
const { argv } = require("process");

async function build(tsConfig) {
console.log(
"building",
process.env.PWD.substring(process.env.PWD.indexOf("packages")),
tsConfig
);
return new Promise((resolve, reject) => {
const buildProcess = childProcess.spawn(
"npx",
["tsc", "-p", tsConfig],
{
shell: true,
stdio: "inherit",
}
);

buildProcess.on("close", (code) => {
if (code == 0) {
resolve();
} else {
reject(code);
}
});
});
}

function addCJSPackageJsonOverride(type) {
fs.writeFileSync(
`./bin/${type}/package.json`,
JSON.stringify({ type: "commonjs" })
);
}

const esmBuildTask = argv.includes("--esm")
? build("tsconfig.json")
: Promise.resolve();

const cjsBuildTask = argv.includes("--cjs")
? build("tsconfig.cjs.json").then(() => addCJSPackageJsonOverride("cjs"))
: Promise.resolve();

const testBuildTask = argv.includes("--test")
? build("tsconfig.test.json").then(() => addCJSPackageJsonOverride("test"))
: Promise.resolve();

Promise.all([esmBuildTask, cjsBuildTask, testBuildTask]);
44 changes: 22 additions & 22 deletions internal/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@
"tsc": "tsc"
},
"dependencies": {
"@fluid-experimental/attributor": "^2.0.0-rc.5.0.1",
"@fluid-experimental/sequence-deprecated": "^2.0.0-rc.5.0.1",
"@fluidframework/agent-scheduler": "^2.0.0-rc.5.0.1",
"@fluidframework/aqueduct": "^2.0.0-rc.5.0.1",
"@fluidframework/cell": "^2.0.0-rc.5.0.1",
"@fluidframework/container-loader": "^2.0.0-rc.5.0.1",
"@fluidframework/container-runtime": "^2.0.0-rc.5.0.1",
"@fluidframework/core-interfaces": "^2.0.0-rc.5.0.1",
"@fluidframework/core-utils": "^2.0.0-rc.5.0.1",
"@fluidframework/counter": "^2.0.0-rc.5.0.1",
"@fluidframework/datastore-definitions": "^2.0.0-rc.5.0.1",
"@fluidframework/driver-definitions": "^2.0.0-rc.5.0.1",
"@fluidframework/local-driver": "^2.0.0-rc.5.0.1",
"@fluidframework/map": "^2.0.0-rc.5.0.1",
"@fluidframework/matrix": "^2.0.0-rc.5.0.1",
"@fluidframework/ordered-collection": "^2.0.0-rc.5.0.1",
"@fluidframework/register-collection": "^2.0.0-rc.5.0.1",
"@fluidframework/runtime-definitions": "^2.0.0-rc.5.0.1",
"@fluidframework/sequence": "^2.0.0-rc.5.0.1",
"@fluid-experimental/attributor": "^2.1.0",
"@fluid-experimental/sequence-deprecated": "^2.1.0",
"@fluidframework/agent-scheduler": "^2.1.0",
"@fluidframework/aqueduct": "^2.1.0",
"@fluidframework/cell": "^2.1.0",
"@fluidframework/container-loader": "^2.1.0",
"@fluidframework/container-runtime": "^2.1.0",
"@fluidframework/core-interfaces": "^2.1.0",
"@fluidframework/core-utils": "^2.1.0",
"@fluidframework/counter": "^2.1.0",
"@fluidframework/datastore-definitions": "^2.1.0",
"@fluidframework/driver-definitions": "^2.1.0",
"@fluidframework/local-driver": "^2.1.0",
"@fluidframework/map": "^2.1.0",
"@fluidframework/matrix": "^2.1.0",
"@fluidframework/ordered-collection": "^2.1.0",
"@fluidframework/register-collection": "^2.1.0",
"@fluidframework/runtime-definitions": "^2.1.0",
"@fluidframework/sequence": "^2.1.0",
"@fluidframework/server-local-server": "^5.0.0",
"@fluidframework/telemetry-utils": "^2.0.0-rc.5.0.1",
"@fluidframework/test-driver-definitions": "^2.0.0-rc.2.0.8",
"@fluidframework/test-utils": "^2.0.0-rc.5.0.1"
"@fluidframework/telemetry-utils": "^2.1.0",
"@fluid-internal/test-driver-definitions": "^2.1.0",
"@fluidframework/test-utils": "^2.1.0"
},
"devDependencies": {
"@fluidframework/eslint-config-fluid": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion internal/test-utils/src/localServerTestDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ILocalDeltaConnectionServer,
LocalDeltaConnectionServer,
} from "@fluidframework/server-local-server";
import { ITestDriver } from "@fluidframework/test-driver-definitions";
import { ITestDriver } from "@fluid-internal/test-driver-definitions";
import { LocalDriverApiType, LocalDriverApi } from "./localDriverApi.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion internal/test-utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"exclude": ["build", "dist", "node_modules"],
"exclude": ["bin", "node_modules"],
"include": ["test/**/*.ts"],
"files": ["src/index.ts"]
}
1 change: 0 additions & 1 deletion internal/test-utils/tsconfig.tsbuildinfo

This file was deleted.

3 changes: 3 additions & 0 deletions internal/usage-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# lock files not needed for usage tests
pnpm-lock.yaml
package-lock.json
1 change: 1 addition & 0 deletions internal/usage-test/cjs-test/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
20 changes: 20 additions & 0 deletions internal/usage-test/cjs-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "live-share-cjs-test",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"type": "commonjs",
"scripts": {
"test": "npm install && node src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microsoft/live-share": "file:/../../../packages/live-share",
"fluid-framework": "2.1.0"
},
"devDependencies": {
"@fluidframework/test-runtime-utils": "^2.1.0"
}
}
19 changes: 19 additions & 0 deletions internal/usage-test/cjs-test/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { LiveShareClient, TestLiveShareHost } = require("@microsoft/live-share");
const { waitForDelay } = require("@microsoft/live-share/internal");

const client = new LiveShareClient(TestLiveShareHost.create());
const canUseLiveShare = client !== undefined;
const canUseLiveShareInternal = waitForDelay(10) !== undefined;

if (!canUseLiveShare) {
process.exit(1);
}

if (!canUseLiveShareInternal) {
process.exit(2);
}

console.log("client", client);
console.log(
"Sucessfully imported and able to use Live Share package in cjs project"
);
1 change: 1 addition & 0 deletions internal/usage-test/esm-test/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
20 changes: 20 additions & 0 deletions internal/usage-test/esm-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "live-share-esm-test",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"type": "module",
"scripts": {
"test": "npm install && node src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microsoft/live-share": "file:/../../../packages/live-share",
"fluid-framework": "2.1.0"
},
"devDependencies": {
"@fluidframework/test-runtime-utils": "^2.1.0"
}
}
19 changes: 19 additions & 0 deletions internal/usage-test/esm-test/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LiveShareClient, TestLiveShareHost } from "@microsoft/live-share";
import { waitForDelay } from "@microsoft/live-share/internal";

const client = new LiveShareClient(TestLiveShareHost.create());
const canUseLiveShare = client !== undefined;
const canUseLiveShareInternal = waitForDelay(10) !== undefined;

if (!canUseLiveShare) {
process.exit(1);
}

if (!canUseLiveShareInternal) {
process.exit(2);
}

console.log("client", client);
console.log(
"Sucessfully imported and able to use Live Share package in esm project"
);
1 change: 1 addition & 0 deletions internal/usage-test/pnpm-test/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
22 changes: 22 additions & 0 deletions internal/usage-test/pnpm-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "live-share-pnpm-test",
"version": "1.0.0",
"description": "",
"main": "bin/index.js",
"type": "module",
"scripts": {
"test": "pnpm install && pnpm run build && node bin/index.js",
"build": "tsc -p tsconfig.json"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@microsoft/live-share": "file:/../../../packages/live-share",
"fluid-framework": "2.1.0"
},
"devDependencies": {
"@fluidframework/test-runtime-utils": "^2.1.0",
"@types/node": "^20.14.14"
}
}
19 changes: 19 additions & 0 deletions internal/usage-test/pnpm-test/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { LiveShareClient, TestLiveShareHost } from "@microsoft/live-share";
import { waitForDelay } from "@microsoft/live-share/internal";

const client = new LiveShareClient(TestLiveShareHost.create());
const canUseLiveShare = client !== undefined;
const canUseLiveShareInternal = waitForDelay(10) !== undefined;

if (!canUseLiveShare) {
process.exit(1);
}

if (!canUseLiveShareInternal) {
process.exit(2);
}

console.log("client", client);
console.log(
"Sucessfully imported and able to use Live Share package in pnpm typescript esm project"
);
25 changes: 25 additions & 0 deletions internal/usage-test/pnpm-test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "Node16",
"moduleResolution": "Node16",
"outDir": "./bin",
"rootDir": "./src",
"composite": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"incremental": true,
"inlineSources": true,
"jsx": "react",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"noImplicitAny": false,
"noUnusedLocals": true,
"pretty": true,
"sourceMap": true,
"strict": true,
"target": "ES2020",
"types": ["node"],
"skipLibCheck": true
},
"files": ["src/index.ts"]
}
Loading
Loading