Skip to content

Commit

Permalink
Add CommonJS support and fix esBuild build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyball710 authored and jdanyow committed Nov 13, 2024
1 parent 33864e7 commit e3af475
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 39 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions packages/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
"service-worker"
],
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"types": "dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/cosmos/README.md",
Expand All @@ -32,7 +36,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"pretest": "esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
"test": "node ../../test.mjs"
Expand Down
11 changes: 11 additions & 0 deletions packages/cosmos/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/cosmos/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"]
Expand Down
12 changes: 8 additions & 4 deletions packages/csv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
"version": "2.2.0",
"description": "Streaming CSV encoding for Cloudflare Workers and service workers",
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"types": "dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/csv/README.md",
Expand All @@ -22,7 +26,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"pretest": "esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
"test": "node ../../test.mjs"
Expand Down
11 changes: 11 additions & 0 deletions packages/csv/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/csv/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"]
Expand Down
6 changes: 5 additions & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"type": "module",
"version": "2.1.0",
"description": "cfworker examples",
"main": "dist/index.js",
"main": "dist/cjs/index.js",
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/examples/README.md",
Expand Down
10 changes: 10 additions & 0 deletions packages/examples/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"composite": false,
"outDir": "dist/cjs"
}
}
3 changes: 2 additions & 1 deletion packages/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"composite": false
"composite": false,
"outDir": "dist/esm"
}
}
12 changes: 8 additions & 4 deletions packages/json-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
"service-worker"
],
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/json-schema/README.md",
Expand All @@ -31,7 +35,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"pretest": "node --experimental-import-meta-resolve suite-gen.js && esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
"test": "node ../../test.mjs"
Expand Down
11 changes: 11 additions & 0 deletions packages/json-schema/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/json-schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"]
Expand Down
12 changes: 8 additions & 4 deletions packages/jwt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@
"workers",
"service-worker"
],
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/cjs/index.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"types": "dist/cjs/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/jwt/README.md",
Expand All @@ -29,7 +33,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"pretest": "esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
"test": "node ../../test.mjs"
Expand Down
12 changes: 12 additions & 0 deletions packages/jwt/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"],
"references": []
}
2 changes: 1 addition & 1 deletion packages/jwt/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"],
Expand Down
12 changes: 8 additions & 4 deletions packages/sentry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
"service-worker"
],
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"types": "dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/sentry/README.md",
Expand All @@ -30,7 +34,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"test": "echo \"no tests 🥺\""
},
Expand Down
12 changes: 12 additions & 0 deletions packages/sentry/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"],
"references": [{ "path": "../uuid" }]
}
2 changes: 1 addition & 1 deletion packages/sentry/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"],
Expand Down
12 changes: 8 additions & 4 deletions packages/uuid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
"service-worker"
],
"sideEffects": false,
"main": "dist/index.js",
"module": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"source": "src/index.ts",
"types": "dist/index.d.ts",
"types": "dist/esm/index.d.ts",
"files": [
"dist/**/*",
"src/**/*",
"README.md",
"package.json"
],
"exports": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"repository": "https://github.com/cfworker/cfworker",
"author": "Jeremy Danyow <jdanyow@gmail.com>",
"homepage": "https://github.com/cfworker/cfworker/tree/master/packages/uuid/README.md",
Expand All @@ -31,7 +35,7 @@
"access": "public"
},
"scripts": {
"build": "tsc --build",
"build": "tsc --build & tsc --build tsconfig-cjs.json",
"clean": "tsc --build --clean",
"pretest": "esbuild test/test.ts --target=esnext --bundle --format=esm --conditions=worker,browser --outdir=dist-test --ignore-annotations",
"test": "node ../../test.mjs"
Expand Down
11 changes: 11 additions & 0 deletions packages/uuid/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig-base",
"compilerOptions": {
"module": "CommonJS",
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist/cjs",
"rootDir": "./src"
},
"include": ["src"]
}
2 changes: 1 addition & 1 deletion packages/uuid/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ESNext",
"lib": ["ESNext", "WebWorker", "Webworker.Iterable"],
"outDir": "dist",
"outDir": "dist/esm",
"rootDir": "./src"
},
"include": ["src"]
Expand Down
Loading

0 comments on commit e3af475

Please sign in to comment.