From acb04f6b057d0de8300a660ed188c3c5ce09be9c Mon Sep 17 00:00:00 2001 From: Alexander Emelin Date: Fri, 1 Sep 2023 08:28:28 +0300 Subject: [PATCH] support esm --- package.json | 7 +++-- tsconfig.json => tsconfig.cjs.json | 0 tsconfig.esm.json | 42 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) rename tsconfig.json => tsconfig.cjs.json (100%) create mode 100644 tsconfig.esm.json diff --git a/package.json b/package.json index 59431c95..56f8f426 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "JavaScript client SDK for bidirectional communication with Centrifugo and Centrifuge-based server from browser, NodeJS and React Native", "main": "build/index.js", "types": "build/index.d.ts", + "module": "build/esm/index.js", "files": [ "dist/**", "build/**" @@ -18,8 +19,10 @@ "clean": "rm -rf dist build package", "ts-node": "ts-node", "docs": "typedoc --exclude '**/transport_*.ts' --exclude '**/*.test.ts' --exclude '**/*+(utils|json|codes|browser).ts' --excludePrivate --excludeInternal --entryPoints src/*.ts", - "build": "tsc -p tsconfig.json", - "build-all": "yarn clean && yarn build && yarn build-browser && yarn build-browser-protobuf", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build:esm": "tsc -p tsconfig.esm.json", + "build": "yarn build:cjs && yarn build:esm", + "build-all": "yarn clean && yarn build:cjs && yarn build:esm && yarn build-browser && yarn build-browser-protobuf", "build-browser": "esbuild src/browser.ts --bundle --minify --sourcemap --outfile=dist/centrifuge.js", "dev": "esbuild src/browser.ts --bundle --outfile=dist/centrifuge.js --servedir=dist/ --serve=2000", "build-browser-protobuf": "esbuild src/protobuf/browser.ts --bundle --minify --sourcemap --outfile=dist/centrifuge.protobuf.js", diff --git a/tsconfig.json b/tsconfig.cjs.json similarity index 100% rename from tsconfig.json rename to tsconfig.cjs.json diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 00000000..c014e0a8 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,42 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "ESNext", + "moduleResolution": "node", + "declaration": true, + "strict": true, + "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, + "strictNullChecks": true /* Enable strict null checks. */, + "strictFunctionTypes": true /* Enable strict checking of function types. */, + "noUnusedLocals": true /* Report errors on unused locals. */, + "noUnusedParameters": true /* Report errors on unused parameters. */, + "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, + "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, + "importHelpers": false, /* https://github.com/centrifugal/centrifuge-js/issues/193 */ + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "resolveJsonModule": true, + "sourceMap": true, + "stripInternal": true, + "outDir": "./build/esm", + "types": [ + "node", + "jest" + ], + "lib": [ + "ES6", + "DOM" + ] + }, + "include": [ + "src/**/*.ts", + "src/**/*.json" + ], + "exclude": [ + "node_modules", + "**/*.test.ts", + "**/browser.ts" + ] +} \ No newline at end of file