Skip to content

Commit 11de076

Browse files
authored
fix!: Change to ES Modules to improve support of dynamic loading (#1011)
1 parent 15e59c4 commit 11de076

28 files changed

+197
-83
lines changed

packages/ai-providers/server-ai-langchain/package.json

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,33 @@
77
"type": "git",
88
"url": "https://github.com/launchdarkly/js-core.git"
99
},
10-
"main": "dist/index.js",
11-
"types": "dist/index.d.ts",
12-
"type": "commonjs",
10+
"main": "./dist/index.cjs",
11+
"module": "./dist/index.js",
12+
"types": "./dist/index.d.ts",
13+
"type": "module",
14+
"exports": {
15+
".": {
16+
"require": {
17+
"types": "./dist/index.d.cts",
18+
"default": "./dist/index.cjs"
19+
},
20+
"import": {
21+
"types": "./dist/index.d.ts",
22+
"default": "./dist/index.js"
23+
}
24+
}
25+
},
1326
"scripts": {
14-
"build": "npx tsc",
27+
"build": "tsup-node",
1528
"lint": "npx eslint . --ext .ts",
1629
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
1730
"lint:fix": "yarn run lint --fix",
1831
"check": "yarn prettier && yarn lint && yarn build && yarn test",
1932
"test": "jest"
2033
},
34+
"files": [
35+
"dist"
36+
],
2137
"keywords": [
2238
"launchdarkly",
2339
"ai",
@@ -27,6 +43,7 @@
2743
"author": "LaunchDarkly",
2844
"license": "Apache-2.0",
2945
"devDependencies": {
46+
"@langchain/community": "^0.3.0",
3047
"@langchain/core": "^0.3.0",
3148
"@launchdarkly/server-sdk-ai": "^0.14.1",
3249
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
@@ -44,9 +61,11 @@
4461
"langchain": "^0.3.0",
4562
"prettier": "^3.0.0",
4663
"ts-jest": "^29.1.1",
64+
"tsup": "^8.5.1",
4765
"typescript": "5.1.6"
4866
},
4967
"peerDependencies": {
68+
"@langchain/community": "^0.2.0 || ^0.3.0",
5069
"@langchain/core": "^0.2.0 || ^0.3.0",
5170
"@launchdarkly/server-sdk-ai": "^0.14.0",
5271
"langchain": "^0.2.0 || ^0.3.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "./tsconfig.json",
3-
"include": ["/**/*.ts"],
3+
"include": ["**/*.ts", "**/*.js"],
44
"exclude": ["node_modules"]
55
}

packages/ai-providers/server-ai-langchain/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2020",
4-
"module": "CommonJS",
4+
"module": "ES2020",
55
"lib": ["ES2020"],
66
"moduleResolution": "node",
77
"esModuleInterop": true,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// It is a dev dependency and the linter doesn't understand.
2+
// eslint-disable-next-line import/no-extraneous-dependencies
3+
import { defineConfig } from 'tsup';
4+
5+
export default defineConfig({
6+
entry: {
7+
index: 'src/index.ts',
8+
},
9+
format: ['esm', 'cjs'],
10+
splitting: false,
11+
sourcemap: true,
12+
clean: true,
13+
dts: true,
14+
});

packages/ai-providers/server-ai-openai/package.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,33 @@
77
"type": "git",
88
"url": "https://github.com/launchdarkly/js-core.git"
99
},
10-
"main": "dist/index.js",
11-
"types": "dist/index.d.ts",
12-
"type": "commonjs",
10+
"main": "./dist/index.cjs",
11+
"module": "./dist/index.js",
12+
"types": "./dist/index.d.ts",
13+
"type": "module",
14+
"exports": {
15+
".": {
16+
"require": {
17+
"types": "./dist/index.d.cts",
18+
"default": "./dist/index.cjs"
19+
},
20+
"import": {
21+
"types": "./dist/index.d.ts",
22+
"default": "./dist/index.js"
23+
}
24+
}
25+
},
1326
"scripts": {
14-
"build": "npx tsc",
27+
"build": "tsup-node",
1528
"lint": "npx eslint . --ext .ts",
1629
"prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
1730
"lint:fix": "yarn run lint --fix",
1831
"check": "yarn prettier && yarn lint && yarn build && yarn test",
1932
"test": "jest"
2033
},
34+
"files": [
35+
"dist"
36+
],
2137
"keywords": [
2238
"launchdarkly",
2339
"ai",
@@ -44,6 +60,7 @@
4460
"openai": "^6.0.0",
4561
"prettier": "^3.0.0",
4662
"ts-jest": "^29.1.1",
63+
"tsup": "^8.5.1",
4764
"typescript": "5.1.6"
4865
},
4966
"peerDependencies": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"extends": "./tsconfig.json",
3-
"include": ["/**/*.ts"],
3+
"include": ["**/*.ts", "**/*.js"],
44
"exclude": ["node_modules"]
55
}

packages/ai-providers/server-ai-openai/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "ES2020",
4-
"module": "CommonJS",
4+
"module": "ES2020",
55
"lib": ["ES2020"],
66
"moduleResolution": "node",
77
"esModuleInterop": true,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// It is a dev dependency and the linter doesn't understand.
2+
// eslint-disable-next-line import/no-extraneous-dependencies
3+
import { defineConfig } from 'tsup';
4+
5+
export default defineConfig({
6+
entry: {
7+
index: 'src/index.ts',
8+
},
9+
format: ['esm', 'cjs'],
10+
splitting: false,
11+
sourcemap: true,
12+
clean: true,
13+
dts: true,
14+
});

0 commit comments

Comments
 (0)