-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better dual ESM/CJS support, tsconfig module now Node16, improved pnp…
…m support (#791) Co-authored-by: James Hunt <[email protected]>
- Loading branch information
Showing
200 changed files
with
3,316 additions
and
3,096 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ on: | |
branches: [main, mainv2] | ||
pull_request: | ||
branches: [main, mainv2] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ on: | |
branches: [main, mainv2] | ||
pull_request: | ||
branches: [main, mainv2] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,4 +367,5 @@ docs/assets/main.js | |
coverage/ | ||
nyc/ | ||
.nyc_output/ | ||
build-data.json | ||
build-data.json | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.0.0" | ||
}, | ||
"devDependencies": { | ||
"@fluidframework/test-runtime-utils": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.0.0" | ||
}, | ||
"devDependencies": { | ||
"@fluidframework/test-runtime-utils": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.0.0" | ||
}, | ||
"devDependencies": { | ||
"@fluidframework/test-runtime-utils": "^2.0.0", | ||
"@types/node": "^20.14.14" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |
Oops, something went wrong.