Skip to content

Commit e061811

Browse files
authored
fix: Update sdk-client rollup configuration to match common (#630)
This applies the same fixes to `sdk-client` that were applied to `common`. This resolves issues with using CJS+Typescript with RN. Our existing test project doesn't use node16/nodenext module resolution. Can be tested with our example project with this tsconfig. ``` { "extends": "@react-native/typescript-config/tsconfig.json", "compilerOptions": { "allowSyntheticDefaultImports": true, "jsx": "react-native", "lib": ["dom", "esnext"], "module": "nodenext", "moduleResolution": "nodenext", "noEmit": true, "skipLibCheck": true, "resolveJsonModule": true, "removeComments": true, "sourceMap": true, "strict": true, "forceConsistentCasingInFileNames": true }, "exclude": ["e2e"] } ``` Required installing the base config: ``` yarn add -D @react-native/typescript-config ```
1 parent 70cf3c3 commit e061811

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

packages/shared/common/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@
1919
"client"
2020
],
2121
"exports": {
22-
"require": { "types": "./dist/cjs/index.d.ts", "default": "./dist/cjs/index.cjs"},
23-
"import": { "types": "./dist/esm/index.d.ts", "default": "./dist/esm/index.mjs"}
22+
"require": {
23+
"types": "./dist/cjs/index.d.ts",
24+
"default": "./dist/cjs/index.cjs"
25+
},
26+
"import": {
27+
"types": "./dist/esm/index.d.ts",
28+
"default": "./dist/esm/index.mjs"
29+
}
2430
},
2531
"scripts": {
2632
"test": "npx jest --ci",

packages/shared/sdk-client/package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name": "@launchdarkly/js-client-sdk-common",
33
"version": "1.9.0",
44
"type": "module",
5-
"main": "./dist/index.mjs",
6-
"types": "./dist/index.d.ts",
5+
"main": "./dist/esm/index.mjs",
6+
"types": "./dist/esm/index.d.ts",
77
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/shared/sdk-client",
88
"repository": {
99
"type": "git",
@@ -19,14 +19,22 @@
1919
"client"
2020
],
2121
"exports": {
22-
"types": "./dist/index.d.ts",
23-
"require": "./dist/index.cjs",
24-
"import": "./dist/index.mjs"
22+
"require": {
23+
"types": "./dist/cjs/index.d.ts",
24+
"default": "./dist/cjs/index.cjs"
25+
},
26+
"import": {
27+
"types": "./dist/esm/index.d.ts",
28+
"default": "./dist/esm/index.mjs"
29+
}
2530
},
2631
"scripts": {
2732
"doc": "../../../scripts/build-doc.sh .",
2833
"test": "npx jest --ci",
29-
"build": "tsc --noEmit && rollup -c rollup.config.js",
34+
"make-cjs-package-json": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
35+
"make-esm-package-json": "echo '{\"type\":\"module\"}' > dist/esm/package.json",
36+
"make-package-jsons": "npm run make-cjs-package-json && npm run make-esm-package-json",
37+
"build": "npx tsc --noEmit && rollup -c rollup.config.js && npm run make-package-jsons",
3038
"clean": "rimraf dist",
3139
"lint": "npx eslint . --ext .ts",
3240
"lint:fix": "yarn run lint -- --fix",

packages/shared/sdk-client/rollup.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const getSharedConfig = (format, file) => ({
2121

2222
export default [
2323
{
24-
...getSharedConfig('es', 'dist/index.mjs'),
24+
...getSharedConfig('es', 'dist/esm/index.mjs'),
2525
plugins: [
2626
typescript({
2727
module: 'esnext',
@@ -37,7 +37,7 @@ export default [
3737
],
3838
},
3939
{
40-
...getSharedConfig('cjs', 'dist/index.cjs'),
41-
plugins: [typescript({ tsconfig: './tsconfig.json' }), common(), resolve(), json()],
40+
...getSharedConfig('cjs', 'dist/cjs/index.cjs'),
41+
plugins: [typescript({ tsconfig: './tsconfig.json', outputToFilesystem: true, }), common(), resolve(), json()],
4242
},
4343
];

0 commit comments

Comments
 (0)