Skip to content

Commit

Permalink
Add package.json export
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Apr 5, 2023
1 parent bb84873 commit d06792e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
"types": "./retrievers.d.ts",
"import": "./retrievers.js",
"require": "./retrievers.cjs"
}
},
"./package.json": "./package.json"
}
}
3 changes: 3 additions & 0 deletions langchain/scripts/check-tree-shaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export function listEntrypoints() {
const entrypoints = [];

for (const [key, value] of Object.entries(exports)) {
if (key === "./package.json") {
continue;
}
if (typeof value === "string") {
entrypoints.push(value);
} else if (typeof value === "object") {
Expand Down
21 changes: 12 additions & 9 deletions langchain/scripts/create-entrypoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ const updateConfig = () => {

updateJsonFile("./package.json", (json) => ({
...json,
exports: Object.fromEntries(
["index", ...Object.keys(entrypoints)].map((key) => {
const entryPoint = {
types: `./${key}.d.ts`,
import: `./${key}.js`,
require: `./${key}.cjs`,
};
return [key === "index" ? "." : `./${key}`, entryPoint];
})
exports: Object.assign(
Object.fromEntries(
["index", ...Object.keys(entrypoints)].map((key) => {
const entryPoint = {
types: `./${key}.d.ts`,
import: `./${key}.js`,
require: `./${key}.cjs`,
};
return [key === "index" ? "." : `./${key}`, entryPoint];
})
),
{ "./package.json": "./package.json" }
),
files: ["dist/", ...filenames],
}));
Expand Down

0 comments on commit d06792e

Please sign in to comment.