From f5b36eb321f9e26b8ce46a54f2ee4a25cc6e5b72 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 11:13:54 -0700 Subject: [PATCH 01/10] scripts[major]: New build --- langchain-core/package.json | 3 +- libs/langchain-scripts/src/new/build.ts | 501 ++++++++++++++++++++++++ 2 files changed, 503 insertions(+), 1 deletion(-) create mode 100644 libs/langchain-scripts/src/new/build.ts diff --git a/langchain-core/package.json b/langchain-core/package.json index e8eae815f715..40b5a609b330 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", + "build": "yarn build:esm && yarn build:cjs", + "build:old": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", "build:deps": "yarn turbo:command build --filter=@langchain/scripts", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-scripts/src/new/build.ts b/libs/langchain-scripts/src/new/build.ts new file mode 100644 index 000000000000..604f1cefb7a9 --- /dev/null +++ b/libs/langchain-scripts/src/new/build.ts @@ -0,0 +1,501 @@ +import { spawn } from "child_process"; +import ts from "typescript"; +import fs from "node:fs"; +import { rimraf } from "rimraf"; +import { Command } from "commander"; +import { rollup } from "rollup"; +import { ExportsMapValue, ImportData, LangChainConfig } from "../types.js"; +import path from "node:path"; + +async function asyncSpawn(command: string, args: string[]) { + return new Promise((resolve, reject) => { + const child = spawn(command, args, { stdio: "inherit" }); + child.on("close", (code) => { + if (code !== 0) { + reject(new Error(`Command failed: ${command} ${args.join(" ")}`)); + return; + } + resolve(); + }); + }); +} + +const NEWLINE = ` +`; + +// List of test-exports-* packages which we use to test that the exports field +// works correctly across different JS environments. +// Each entry is a tuple of [package name, import statement]. +const testExports: Array<[string, (p: string) => string]> = [ + [ + "test-exports-esm", + (p: string) => + `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, + ], + [ + "test-exports-esbuild", + (p: string) => + `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, + ], + [ + "test-exports-cjs", + (p: string) => + `const ${p.replace(/\//g, "_")} = require("langchain/${p}");`, + ], + ["test-exports-cf", (p: string) => `export * from "langchain/${p}";`], + ["test-exports-vercel", (p: string) => `export * from "langchain/${p}";`], + ["test-exports-vite", (p: string) => `export * from "langchain/${p}";`], + ["test-exports-bun", (p: string) => `export * from "langchain/${p}";`], +]; + +async function createImportMapFile(config: LangChainConfig): Promise { + const createImportStatement = (k: string, p: string) => + `export * as ${k.replace(/\//g, "__")} from "../${p + .replace("src/", "") + .replace(".ts", ".js")}";`; + + const entrypointsToInclude = Object.keys(config.entrypoints) + .filter((key) => key !== "load") + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => !config.requiresOptionalDependency?.includes(key)) + .filter((key) => !config.deprecatedOmitFromImportMap?.includes(key)); + const importMapExports = entrypointsToInclude + .map((key) => `${createImportStatement(key, config.entrypoints[key])}`) + .join("\n"); + + let extraContent = ""; + if (config.extraImportMapEntries) { + const extraImportData = config.extraImportMapEntries?.reduce( + (data, { modules, alias, path }) => { + const newData = { ...data }; + if (!newData.imports[path]) { + newData.imports[path] = []; + } + newData.imports[path] = [ + ...new Set(newData.imports[path].concat(modules)), + ]; + const exportAlias = alias.join("__"); + if (!newData.exportedAliases[exportAlias]) { + newData.exportedAliases[exportAlias] = []; + } + newData.exportedAliases[exportAlias] = + newData.exportedAliases[exportAlias].concat(modules); + return newData; + }, + { + imports: {}, + exportedAliases: {}, + } + ); + const extraImportStatements = Object.entries(extraImportData.imports).map( + ([path, modules]) => + `import {\n ${modules.join(",\n ")}\n} from "${path}";` + ); + const extraDeclarations = Object.entries( + extraImportData.exportedAliases + ).map(([exportAlias, modules]) => + [ + `const ${exportAlias} = {\n ${modules.join(",\n ")}\n};`, + `export { ${exportAlias} };`, + ].join("\n") + ); + extraContent = `${extraImportStatements.join( + "\n" + )}\n${extraDeclarations.join("\n")}\n`; + + extraContent.trim(); + if (!/[a-zA-Z0-9]/.test(extraContent)) { + extraContent = ""; + } + } + + const importMapContents = `// Auto-generated by build script. Do not edit manually.\n\n${importMapExports}\n${extraContent}`; + await fs.promises.writeFile("src/load/import_map.ts", importMapContents); +} + +async function generateImportConstants(config: LangChainConfig): Promise { + // Generate import constants + const entrypointsToInclude = Object.keys(config.entrypoints) + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => config.requiresOptionalDependency?.includes(key)); + const importConstantsPath = "src/load/import_constants.ts"; + const createImportStatement = (k: string) => + ` "langchain${ + config.packageSuffix ? `_${config.packageSuffix}` : "" + }/${k}"`; + const contents = + entrypointsToInclude.length > 0 + ? `\n${entrypointsToInclude + .map((key) => createImportStatement(key)) + .join(",\n")},\n];\n` + : "];\n"; + await fs.promises.writeFile( + `${importConstantsPath}`, + `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually.\n\nexport const optionalImportEntrypoints: string[] = [${contents}` + ); +} + +async function generateDCTSFiles(config: LangChainConfig): Promise { + return Promise.all( + Object.keys(config.entrypoints).map(async (key) => { + const filePath = `./dist/${key}.d.cts`; + const content = `export * from './${key}.js'`; + await fs.promises.mkdir(path.dirname(filePath), { recursive: true }); + await fs.promises.writeFile(filePath, content); + }) + ); +} + +async function updateExportTestFiles(config: LangChainConfig): Promise { + // Update test-exports-*/entrypoints.js + const entrypointsToTest = Object.keys(config.entrypoints) + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => !config.requiresOptionalDependency?.includes(key)); + + return Promise.all( + testExports.map(async ([pkg, importStatement]) => { + const contents = `${entrypointsToTest + .map((key) => importStatement(key)) + .join("\n")}\n`; + fs.promises.writeFile( + `../environment_tests/${pkg}/src/entrypoints.js`, + contents + ); + }) + ); +} + +async function updatePackageJson(config: LangChainConfig): Promise { + const packageJson = JSON.parse( + await fs.promises.readFile(`package.json`, "utf8") + ); + packageJson.files = ["dist/**/*"]; + packageJson.exports = Object.keys(config.entrypoints).reduce( + (acc: Record, key) => { + let entrypoint = `./${key}`; + if (key === "index") { + entrypoint = "."; + } + acc[entrypoint] = { + types: { + import: `./dist/${key}.d.ts`, + require: `./dist/${key}.d.cts`, + default: `./dist/${key}.d.ts`, + }, + import: `./dist/${key}.js`, + require: `./dist/${key}.cjs`, + }; + return acc; + }, + {} + ); + + let packageJsonString = JSON.stringify(packageJson, null, 2); + if ( + !packageJsonString.endsWith("\n") && + !packageJsonString.endsWith(NEWLINE) + ) { + packageJsonString += NEWLINE; + } + + // Write package.json and generate d.cts files + // Optionally, update test exports files + await Promise.all([ + fs.promises.writeFile(`package.json`, packageJsonString), + generateDCTSFiles(config), + config.shouldTestExports + ? updateExportTestFiles(config) + : Promise.resolve(), + ]); +} + +export function identifySecrets(absTsConfigPath: string) { + const secrets = new Set(); + + const tsConfig = ts.parseJsonConfigFileContent( + ts.readJsonConfigFile(absTsConfigPath, (p) => fs.readFileSync(p, "utf-8")), + ts.sys, + "./src/" + ); + + // `tsConfig.options.target` is not always defined when running this + // via the `@langchain/scripts` package. Instead, fallback to the raw + // tsConfig.json file contents. + const tsConfigFileContentsText = + "text" in tsConfig.raw + ? JSON.parse(tsConfig.raw.text as string) + : { compilerOptions: {} }; + + const tsConfigTarget = + tsConfig.options.target || tsConfigFileContentsText.compilerOptions.target; + + for (const fileName of tsConfig.fileNames.filter( + (fn) => !fn.endsWith("test.ts") + )) { + if (!tsConfigTarget) { + continue; + } + + const sourceFile = ts.createSourceFile( + fileName, + fs.readFileSync(fileName, "utf-8"), + tsConfigTarget, + true + ); + + sourceFile.forEachChild((node) => { + switch (node.kind) { + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.ClassExpression: { + node.forEachChild((node) => { + // look for get lc_secrets() + switch (node.kind) { + case ts.SyntaxKind.GetAccessor: { + const property = node; + if ( + ts.isGetAccessor(property) && + property.name.getText() === "lc_secrets" + ) { + // look for return { ... } + property.body?.statements.forEach((stmt) => { + if ( + ts.isReturnStatement(stmt) && + stmt.expression && + ts.isObjectLiteralExpression(stmt.expression) + ) { + stmt.expression.properties.forEach((element) => { + if (ts.isPropertyAssignment(element)) { + // Type guard for PropertyAssignment + if ( + element.initializer && + ts.isStringLiteral(element.initializer) + ) { + const secret = element.initializer.text; + + if (secret.toUpperCase() !== secret) { + throw new Error( + `Secret identifier must be uppercase: ${secret} at ${fileName}` + ); + } + if (/\s/.test(secret)) { + throw new Error( + `Secret identifier must not contain whitespace: ${secret} at ${fileName}` + ); + } + + secrets.add(secret); + } + } + }); + } + }); + } + break; + } + default: + break; + } + }); + break; + } + default: + break; + } + }); + } + + return secrets; +} + +async function generateImportTypes(config: LangChainConfig): Promise { + // Generate import types + const pkg = `langchain${ + config.packageSuffix ? `-${config.packageSuffix}` : "" + }`; + const importTypesPath = "src/load/import_type.ts"; + + await fs.promises.writeFile( + `../${pkg}/${importTypesPath}`, + `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually. + +export interface OptionalImportMap {} + +export interface SecretMap { +${[...identifySecrets(config.tsConfigPath)] + .sort() + .map((secret) => ` ${secret}?: string;`) + .join("\n")} +} +` + ); +} + +function listExternals( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + packageJson: Record, + extraInternals?: Array +) { + return [ + ...Object.keys(packageJson.dependencies ?? {}), + ...Object.keys(packageJson.peerDependencies ?? {}), + ...(extraInternals || []), + ]; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function listEntrypoints(packageJson: Record) { + const { exports } = packageJson; + /** @type {Record | null} */ + const exportsWithoutPackageJSON: Record< + string, + ExportsMapValue | string + > | null = exports + ? Object.entries(exports) + .filter(([k]) => k !== "./package.json") + .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}) + : null; + + if (!exportsWithoutPackageJSON) { + throw new Error("No exports found in package.json"); + } + /** @type {string[]} */ + const entrypoints = []; + + for (const [key, value] of Object.entries(exportsWithoutPackageJSON)) { + if (key === "./package.json") { + continue; + } + if (typeof value === "string") { + entrypoints.push(value); + } else if ( + "import" in value && + value.import && + typeof value.import === "string" + ) { + entrypoints.push(value.import); + } + } + + return entrypoints; +} + +async function checkTreeShaking(config: LangChainConfig) { + const packageJson = JSON.parse( + await fs.promises.readFile("package.json", "utf8") + ); + const externals = listExternals(packageJson, config?.internals ?? []); + const entrypoints = listEntrypoints(packageJson); + const consoleLog = console.log; + /** @type {Map} */ + const reportMap = new Map(); + + for (const entrypoint of entrypoints) { + let sideEffects = ""; + + console.log = function (...args) { + const line = args.length ? args.join(" ") : ""; + if (line.trim().startsWith("First side effect in")) { + sideEffects += `${line}\n`; + } + }; + + await rollup({ + external: externals, + input: entrypoint, + experimentalLogSideEffects: true, + }); + + reportMap.set(entrypoint, { + log: sideEffects, + hasSideEffects: sideEffects.length > 0, + }); + } + + console.log = consoleLog; + + let failed = false; + for (const [entrypoint, report] of reportMap) { + if (report.hasSideEffects) { + failed = true; + console.log("---------------------------------"); + console.log(`Tree shaking failed for ${entrypoint}`); + console.log(report.log); + } + } + + if (failed) { + process.exit(1); + } else { + console.log("Tree shaking checks passed!"); + } +} + +function processOptions(): { + shouldCreateEntrypoints: boolean; + shouldCheckTreeShaking: boolean; + shouldGenMaps: boolean; +} { + const program = new Command(); + program + .description("Run a build script for a LangChain package.") + .option( + "--config ", + "Path to the config file, defaults to ./langchain.config.js" + ) + .option( + "--create-entrypoints", + "Pass only if you want to create entrypoints" + ) + .option("--tree-shaking", "Pass only if you want to check tree shaking") + .option("--gen-maps"); + + program.parse(); + + const options = program.opts(); + + const shouldCreateEntrypoints = options.createEntrypoints; + const shouldCheckTreeShaking = options.treeShaking; + const shouldGenMaps = options.genMaps; + + return { + shouldCreateEntrypoints, + shouldCheckTreeShaking, + shouldGenMaps, + }; +} + +export async function buildWithTSup() { + const { shouldCreateEntrypoints, shouldCheckTreeShaking, shouldGenMaps } = + processOptions(); + + const importPath = `${process.cwd()}/langchain.config.js`; + const { config }: { config: LangChainConfig } = await import(importPath); + + if (shouldCreateEntrypoints) { + await rimraf("dist"); + + // Build with TSC + + // Build CJS with TSC + + // Move CJS to dist + + // Rest + + if (shouldGenMaps) { + // Updates import_map.ts, import_constants.ts, and import_types.ts + await Promise.all([ + createImportMapFile(config), + generateImportConstants(config), + generateImportTypes(config), + ]); + } + // Adds entrypoints to package.json file. + await updatePackageJson(config); + } + + if (shouldCheckTreeShaking) { + // Checks tree shaking via rollup + await checkTreeShaking(config); + } +} From 57604a85f70ac225a82f72dc7fe5cd5fec91cca2 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 12:44:02 -0700 Subject: [PATCH 02/10] perfect build script and add to core! --- langchain-core/package.json | 4 +- libs/langchain-scripts/bin/build_new.js | 642 ++++++++++++++++++++++++ libs/langchain-scripts/package.json | 5 +- libs/langchain-scripts/src/new/build.ts | 224 +++++++-- libs/langchain-scripts/src/types.ts | 6 +- yarn.lock | 1 + 6 files changed, 837 insertions(+), 45 deletions(-) create mode 100755 libs/langchain-scripts/bin/build_new.js diff --git a/langchain-core/package.json b/langchain-core/package.json index 40b5a609b330..483bcf450543 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -14,8 +14,9 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/", "scripts": { - "build": "yarn build:esm && yarn build:cjs", + "build": "yarn lc-build:new --create-entrypoints --pre --tree-shaking", "build:old": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", + "clean:old": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", "build:deps": "yarn turbo:command build --filter=@langchain/scripts", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", @@ -25,7 +26,6 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", "prepack": "yarn build", "release": "release-it --only-version --config .release-it.json", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", diff --git a/libs/langchain-scripts/bin/build_new.js b/libs/langchain-scripts/bin/build_new.js new file mode 100755 index 000000000000..6c05051a8f14 --- /dev/null +++ b/libs/langchain-scripts/bin/build_new.js @@ -0,0 +1,642 @@ +import { spawn } from "child_process"; +import ts from "typescript"; +import fs from "node:fs"; +import { rimraf } from "rimraf"; +import { Command } from "commander"; +import { rollup } from "rollup"; +import path from "node:path"; + +async function asyncSpawn(command, args) { + return new Promise((resolve, reject) => { + const child = spawn(command, args, { + stdio: "inherit", + env: { + ...process.env, + NODE_OPTIONS: "--max-old-space-size=4096", + }, + }); + child.on("close", (code) => { + if (code !== 0) { + reject(new Error(`Command failed: ${command} ${args.join(" ")}`)); + return; + } + resolve(); + }); + }); +} + +const NEWLINE = ` +`; + +// List of test-exports-* packages which we use to test that the exports field +// works correctly across different JS environments. +// Each entry is a tuple of [package name, import statement]. +const testExports = [ + [ + "test-exports-esm", + (p) => + `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, + ], + [ + "test-exports-esbuild", + (p) => + `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, + ], + [ + "test-exports-cjs", + (p) => + `const ${p.replace(/\//g, "_")} = require("langchain/${p}");`, + ], + ["test-exports-cf", (p) => `export * from "langchain/${p}";`], + ["test-exports-vercel", (p) => `export * from "langchain/${p}";`], + ["test-exports-vite", (p) => `export * from "langchain/${p}";`], + ["test-exports-bun", (p) => `export * from "langchain/${p}";`], +]; + +const DEFAULT_GITIGNORE_PATHS = ["node_modules", "dist", ".yarn"]; + +async function createImportMapFile(config) { + const createImportStatement = (k, p) => + `export * as ${k.replace(/\//g, "__")} from "../${p + .replace("src/", "") + .replace(".ts", ".js")}";`; + + const entrypointsToInclude = Object.keys(config.entrypoints) + .filter((key) => key !== "load") + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => !config.requiresOptionalDependency?.includes(key)) + .filter((key) => !config.deprecatedOmitFromImportMap?.includes(key)); + const importMapExports = entrypointsToInclude + .map((key) => `${createImportStatement(key, config.entrypoints[key])}`) + .join("\n"); + + let extraContent = ""; + if (config.extraImportMapEntries) { + const extraImportData = config.extraImportMapEntries?.reduce( + (data, { modules, alias, path }) => { + const newData = { ...data }; + if (!newData.imports[path]) { + newData.imports[path] = []; + } + newData.imports[path] = [ + ...new Set(newData.imports[path].concat(modules)), + ]; + const exportAlias = alias.join("__"); + if (!newData.exportedAliases[exportAlias]) { + newData.exportedAliases[exportAlias] = []; + } + newData.exportedAliases[exportAlias] = + newData.exportedAliases[exportAlias].concat(modules); + return newData; + }, + { + imports: {}, + exportedAliases: {}, + } + ); + const extraImportStatements = Object.entries(extraImportData.imports).map( + ([path, modules]) => + `import {\n ${modules.join(",\n ")}\n} from "${path}";` + ); + const extraDeclarations = Object.entries( + extraImportData.exportedAliases + ).map(([exportAlias, modules]) => + [ + `const ${exportAlias} = {\n ${modules.join(",\n ")}\n};`, + `export { ${exportAlias} };`, + ].join("\n") + ); + extraContent = `${extraImportStatements.join( + "\n" + )}\n${extraDeclarations.join("\n")}\n`; + + extraContent.trim(); + if (!/[a-zA-Z0-9]/.test(extraContent)) { + extraContent = ""; + } + } + + const importMapContents = `// Auto-generated by build script. Do not edit manually.\n\n${importMapExports}\n${extraContent}`; + await fs.promises.writeFile("src/load/import_map.ts", importMapContents); +} + +async function generateImportConstants(config) { + // Generate import constants + const entrypointsToInclude = Object.keys(config.entrypoints) + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => config.requiresOptionalDependency?.includes(key)); + const importConstantsPath = "src/load/import_constants.ts"; + const createImportStatement = (k) => + ` "langchain${config.packageSuffix ? `_${config.packageSuffix}` : "" + }/${k}"`; + const contents = + entrypointsToInclude.length > 0 + ? `\n${entrypointsToInclude + .map((key) => createImportStatement(key)) + .join(",\n")},\n];\n` + : "];\n"; + await fs.promises.writeFile( + `${importConstantsPath}`, + `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually.\n\nexport const optionalImportEntrypoints: string[] = [${contents}` + ); +} + +const generateFiles = (config) => { + const files = [...Object.entries(config.entrypoints)].flatMap( + ([key, value]) => { + const nrOfDots = key.split("/").length - 1; + const relativePath = "../".repeat(nrOfDots) || "./"; + const compiledPath = `${relativePath}dist/${value}.js`; + return [ + [ + `${key}.cjs`, + `module.exports = require('${relativePath}dist/${value}.cjs');`, + ], + [`${key}.js`, `export * from '${compiledPath}'`], + [`${key}.d.ts`, `export * from '${compiledPath}'`], + [`${key}.d.cts`, `export * from '${compiledPath}'`], + ]; + } + ); + + return Object.fromEntries(files); +}; + +async function updateExportTestFiles(config) { + // Update test-exports-*/entrypoints.js + const entrypointsToTest = Object.keys(config.entrypoints) + .filter((key) => !config.deprecatedNodeOnly?.includes(key)) + .filter((key) => !config.requiresOptionalDependency?.includes(key)); + + return Promise.all( + testExports.map(async ([pkg, importStatement]) => { + const contents = `${entrypointsToTest + .map((key) => importStatement(key)) + .join("\n")}\n`; + fs.promises.writeFile( + `../environment_tests/${pkg}/src/entrypoints.js`, + contents + ); + }) + ); +} + +async function writeTopLevelGeneratedFiles( + generatedFiles +) { + return Promise.all( + Object.entries(generatedFiles).map(async ([filename, content]) => { + await fs.promises.mkdir(path.dirname(filename), { recursive: true }); + await fs.promises.writeFile(filename, content); + }) + ); +} + +async function updateGitIgnore( + config, + filenames +) { + const gitignorePaths = [ + ...filenames, + ...DEFAULT_GITIGNORE_PATHS, + ...(config.additionalGitignorePaths ? config.additionalGitignorePaths : []), + ]; + + // Update .gitignore + return fs.promises.writeFile( + "./.gitignore", + `${gitignorePaths.join("\n")}\n` + ); +} + +async function updatePackageJson(config) { + const packageJson = JSON.parse( + await fs.promises.readFile(`package.json`, "utf8") + ); + const generatedFiles = generateFiles(config); + const filenames = Object.keys(generatedFiles); + packageJson.files = ["dist/", ...filenames]; + packageJson.exports = Object.keys(config.entrypoints).reduce( + (acc, key) => { + let entrypoint = `./${key}`; + if (key === "index") { + entrypoint = "."; + } + acc[entrypoint] = { + types: { + import: `./${key}.d.ts`, + require: `./${key}.d.cts`, + default: `./${key}.d.ts`, + }, + import: `./${key}.js`, + require: `./${key}.cjs`, + }; + return acc; + }, + {} + ); + packageJson.exports = { + ...packageJson.exports, + "./package.json": "./package.json", + }; + + let packageJsonString = JSON.stringify(packageJson, null, 2); + if ( + !packageJsonString.endsWith("\n") && + !packageJsonString.endsWith(NEWLINE) + ) { + packageJsonString += NEWLINE; + } + + // Write package.json and generate d.cts files + // Optionally, update test exports files + await Promise.all([ + fs.promises.writeFile(`package.json`, packageJsonString), + writeTopLevelGeneratedFiles(generatedFiles), + updateGitIgnore(config, filenames), + config.shouldTestExports + ? updateExportTestFiles(config) + : Promise.resolve(), + ]); +} + +export function identifySecrets(absTsConfigPath) { + const secrets = new Set(); + + const tsConfig = ts.parseJsonConfigFileContent( + ts.readJsonConfigFile(absTsConfigPath, (p) => fs.readFileSync(p, "utf-8")), + ts.sys, + "./src/" + ); + + // `tsConfig.options.target` is not always defined when running this + // via the `@langchain/scripts` package. Instead, fallback to the raw + // tsConfig.json file contents. + const tsConfigFileContentsText = + "text" in tsConfig.raw + ? JSON.parse(tsConfig.raw.text) + : { compilerOptions: {} }; + + const tsConfigTarget = + tsConfig.options.target || tsConfigFileContentsText.compilerOptions.target; + + for (const fileName of tsConfig.fileNames.filter( + (fn) => !fn.endsWith("test.ts") + )) { + if (!tsConfigTarget) { + continue; + } + + const sourceFile = ts.createSourceFile( + fileName, + fs.readFileSync(fileName, "utf-8"), + tsConfigTarget, + true + ); + + sourceFile.forEachChild((node) => { + switch (node.kind) { + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.ClassExpression: { + node.forEachChild((node) => { + // look for get lc_secrets() + switch (node.kind) { + case ts.SyntaxKind.GetAccessor: { + const property = node; + if ( + ts.isGetAccessor(property) && + property.name.getText() === "lc_secrets" + ) { + // look for return { ... } + property.body?.statements.forEach((stmt) => { + if ( + ts.isReturnStatement(stmt) && + stmt.expression && + ts.isObjectLiteralExpression(stmt.expression) + ) { + stmt.expression.properties.forEach((element) => { + if (ts.isPropertyAssignment(element)) { + // Type guard for PropertyAssignment + if ( + element.initializer && + ts.isStringLiteral(element.initializer) + ) { + const secret = element.initializer.text; + + if (secret.toUpperCase() !== secret) { + throw new Error( + `Secret identifier must be uppercase: ${secret} at ${fileName}` + ); + } + if (/\s/.test(secret)) { + throw new Error( + `Secret identifier must not contain whitespace: ${secret} at ${fileName}` + ); + } + + secrets.add(secret); + } + } + }); + } + }); + } + break; + } + default: + break; + } + }); + break; + } + default: + break; + } + }); + } + + return secrets; +} + +async function generateImportTypes(config) { + // Generate import types + const pkg = `langchain${config.packageSuffix ? `-${config.packageSuffix}` : "" + }`; + const importTypesPath = "src/load/import_type.ts"; + + await fs.promises.writeFile( + `../${pkg}/${importTypesPath}`, + `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually. + +export interface OptionalImportMap {} + +export interface SecretMap { +${[...identifySecrets(config.tsConfigPath)] + .sort() + .map((secret) => ` ${secret}?: string;`) + .join("\n")} +} +` + ); +} + +function listExternals( + packageJson, + extraInternals +) { + return [ + ...Object.keys(packageJson.dependencies ?? {}), + ...Object.keys(packageJson.peerDependencies ?? {}), + ...(extraInternals || []), + ]; +} + +function listEntrypoints(packageJson) { + const { exports } = packageJson; + /** @type {Record | null} */ + const exportsWithoutPackageJSON = exports + ? Object.entries(exports) + .filter(([k]) => k !== "./package.json") + .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}) + : null; + + if (!exportsWithoutPackageJSON) { + throw new Error("No exports found in package.json"); + } + /** @type {string[]} */ + const entrypoints = []; + + for (const [key, value] of Object.entries(exportsWithoutPackageJSON)) { + if (key === "./package.json") { + continue; + } + if (typeof value === "string") { + entrypoints.push(value); + } else if ( + "import" in value && + value.import && + typeof value.import === "string" + ) { + entrypoints.push(value.import); + } + } + + return entrypoints; +} + +async function checkTreeShaking(config) { + const packageJson = JSON.parse( + await fs.promises.readFile("package.json", "utf8") + ); + const externals = listExternals(packageJson, config?.internals ?? []); + const entrypoints = listEntrypoints(packageJson); + const consoleLog = console.log; + /** @type {Map} */ + const reportMap = new Map(); + + for (const entrypoint of entrypoints) { + let sideEffects = ""; + + console.log = function (...args) { + const line = args.length ? args.join(" ") : ""; + if (line.trim().startsWith("First side effect in")) { + sideEffects += `${line}\n`; + } + }; + + await rollup({ + external: externals, + input: entrypoint, + experimentalLogSideEffects: true, + }); + + reportMap.set(entrypoint, { + log: sideEffects, + hasSideEffects: sideEffects.length > 0, + }); + } + + console.log = consoleLog; + + let failed = false; + for (const [entrypoint, report] of reportMap) { + if (report.hasSideEffects) { + failed = true; + console.log("---------------------------------"); + console.log(`Tree shaking failed for ${entrypoint}`); + console.log(report.log); + } + } + + if (failed) { + process.exit(1); + } else { + console.log("Tree shaking checks passed!"); + } +} + +/** + * Processes the command line options and returns an object with the parsed options. + * + * @returns {Object} An object containing the parsed options: + * - shouldCreateEntrypoints: boolean indicating if entrypoints should be created + * - shouldCheckTreeShaking: boolean indicating if tree shaking should be checked + * - shouldGenMaps: boolean indicating if maps should be generated + * - pre: boolean value of the --pre flag + */ +function processOptions() { + const program = new Command(); + program + .description("Run a build script for a LangChain package.") + .option( + "--config ", + "Path to the config file, defaults to ./langchain.config.js" + ) + .option( + "--create-entrypoints", + "Pass only if you want to create entrypoints" + ) + .option("--tree-shaking", "Pass only if you want to check tree shaking") + .option("--gen-maps") + .option("--pre"); + + program.parse(); + + const options = program.opts(); + + const shouldCreateEntrypoints = options.createEntrypoints; + const shouldCheckTreeShaking = options.treeShaking; + const shouldGenMaps = options.genMaps; + const pre = options.pre; + + return { + shouldCreateEntrypoints, + shouldCheckTreeShaking, + shouldGenMaps, + pre, + }; +} + +async function cleanGeneratedFiles(config) { + const allFileNames = Object.keys(config.entrypoints) + .map((key) => [`${key}.cjs`, `${key}.js`, `${key}.d.ts`, `${key}.d.cts`]) + .flat(); + return Promise.all( + allFileNames.map(async (fileName) => { + try { + await fs.promises.unlink(fileName); + } catch { + // no-op + } + }) + ); +} + +export async function moveAndRename({ + source, + dest, + abs, +}) { + try { + for (const file of await fs.promises.readdir(abs(source), { + withFileTypes: true, + })) { + if (file.isDirectory()) { + await moveAndRename({ + source: `${source}/${file.name}`, + dest: `${dest}/${file.name}`, + abs, + }); + } else if (file.isFile()) { + const parsed = path.parse(file.name); + + // Ignore anything that's not a .js file + if (parsed.ext !== ".js") { + continue; + } + + // Rewrite any require statements to use .cjs + const content = await fs.promises.readFile( + abs(`${source}/${file.name}`), + "utf8" + ); + const rewritten = content.replace( + /require\("(\..+?).js"\)/g, + (_, p1) => `require("${p1}.cjs")` + ); + + // Rename the file to .cjs + const renamed = path.format({ name: parsed.name, ext: ".cjs" }); + + await fs.promises.writeFile( + abs(`${dest}/${renamed}`), + rewritten, + "utf8" + ); + } + } + } catch (err) { + console.error(err); + process.exit(1); + } +} + +export async function buildWithTSup() { + const { + shouldCreateEntrypoints, + shouldCheckTreeShaking, + shouldGenMaps, + pre, + } = processOptions(); + + const importPath = `${process.cwd()}/langchain.config.js`; + const { config } = await import(importPath); + + // Clean & generate build files + if (pre && shouldGenMaps) { + await Promise.all([ + rimraf("dist"), + rimraf(".turbo"), + cleanGeneratedFiles(config), + createImportMapFile(config), + generateImportConstants(config), + generateImportTypes(config), + ]); + } else if (pre && !shouldGenMaps) { + await Promise.all([ + rimraf("dist"), + rimraf(".turbo"), + cleanGeneratedFiles(config), + ]); + } + + if (shouldCreateEntrypoints) { + await Promise.all([ + asyncSpawn("tsc", ["--outDir", "dist/"]), + asyncSpawn("tsc", ["--outDir", "dist-cjs/", "-p", "tsconfig.cjs.json"]), + ]); + await moveAndRename({ + source: config.cjsSource, + dest: config.cjsDestination, + abs: config.abs, + }); + // move CJS to dist + await Promise.all([ + updatePackageJson(config), + rimraf("dist-cjs"), + rimraf("dist/tests"), + rimraf("dist/**/tests"), + ]); + } + + if (shouldCheckTreeShaking) { + // Checks tree shaking via rollup + await checkTreeShaking(config); + } +} + + +/* #__PURE__ */ buildWithTSup().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/libs/langchain-scripts/package.json b/libs/langchain-scripts/package.json index 984d0fb23ed4..8ec282473603 100644 --- a/libs/langchain-scripts/package.json +++ b/libs/langchain-scripts/package.json @@ -14,10 +14,11 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-scripts/", "bin": { - "lc-build": "bin/build.js" + "lc-build": "bin/build.js", + "lc-build:new": "bin/build_new.js" }, "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "node bin/build_new.js --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 rm -f src/package.json && tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs src/package.json", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-scripts/src/new/build.ts b/libs/langchain-scripts/src/new/build.ts index 604f1cefb7a9..7782382e0916 100644 --- a/libs/langchain-scripts/src/new/build.ts +++ b/libs/langchain-scripts/src/new/build.ts @@ -9,7 +9,13 @@ import path from "node:path"; async function asyncSpawn(command: string, args: string[]) { return new Promise((resolve, reject) => { - const child = spawn(command, args, { stdio: "inherit" }); + const child = spawn(command, args, { + stdio: "inherit", + env: { + ...process.env, + NODE_OPTIONS: "--max-old-space-size=4096", + }, + }); child.on("close", (code) => { if (code !== 0) { reject(new Error(`Command failed: ${command} ${args.join(" ")}`)); @@ -48,6 +54,8 @@ const testExports: Array<[string, (p: string) => string]> = [ ["test-exports-bun", (p: string) => `export * from "langchain/${p}";`], ]; +const DEFAULT_GITIGNORE_PATHS = ["node_modules", "dist", ".yarn"]; + async function createImportMapFile(config: LangChainConfig): Promise { const createImportStatement = (k: string, p: string) => `export * as ${k.replace(/\//g, "__")} from "../${p @@ -135,16 +143,26 @@ async function generateImportConstants(config: LangChainConfig): Promise { ); } -async function generateDCTSFiles(config: LangChainConfig): Promise { - return Promise.all( - Object.keys(config.entrypoints).map(async (key) => { - const filePath = `./dist/${key}.d.cts`; - const content = `export * from './${key}.js'`; - await fs.promises.mkdir(path.dirname(filePath), { recursive: true }); - await fs.promises.writeFile(filePath, content); - }) +const generateFiles = (config: LangChainConfig): Record => { + const files = [...Object.entries(config.entrypoints)].flatMap( + ([key, value]) => { + const nrOfDots = key.split("/").length - 1; + const relativePath = "../".repeat(nrOfDots) || "./"; + const compiledPath = `${relativePath}dist/${value}.js`; + return [ + [ + `${key}.cjs`, + `module.exports = require('${relativePath}dist/${value}.cjs');`, + ], + [`${key}.js`, `export * from '${compiledPath}'`], + [`${key}.d.ts`, `export * from '${compiledPath}'`], + [`${key}.d.cts`, `export * from '${compiledPath}'`], + ]; + } ); -} + + return Object.fromEntries(files); +}; async function updateExportTestFiles(config: LangChainConfig): Promise { // Update test-exports-*/entrypoints.js @@ -165,11 +183,41 @@ async function updateExportTestFiles(config: LangChainConfig): Promise { ); } +async function writeTopLevelGeneratedFiles( + generatedFiles: Record +): Promise { + return Promise.all( + Object.entries(generatedFiles).map(async ([filename, content]) => { + await fs.promises.mkdir(path.dirname(filename), { recursive: true }); + await fs.promises.writeFile(filename, content); + }) + ); +} + +async function updateGitIgnore( + config: LangChainConfig, + filenames: string[] +): Promise { + const gitignorePaths = [ + ...filenames, + ...DEFAULT_GITIGNORE_PATHS, + ...(config.additionalGitignorePaths ? config.additionalGitignorePaths : []), + ]; + + // Update .gitignore + return fs.promises.writeFile( + "./.gitignore", + `${gitignorePaths.join("\n")}\n` + ); +} + async function updatePackageJson(config: LangChainConfig): Promise { const packageJson = JSON.parse( await fs.promises.readFile(`package.json`, "utf8") ); - packageJson.files = ["dist/**/*"]; + const generatedFiles = generateFiles(config); + const filenames = Object.keys(generatedFiles); + packageJson.files = ["dist/", ...filenames]; packageJson.exports = Object.keys(config.entrypoints).reduce( (acc: Record, key) => { let entrypoint = `./${key}`; @@ -178,17 +226,21 @@ async function updatePackageJson(config: LangChainConfig): Promise { } acc[entrypoint] = { types: { - import: `./dist/${key}.d.ts`, - require: `./dist/${key}.d.cts`, - default: `./dist/${key}.d.ts`, + import: `./${key}.d.ts`, + require: `./${key}.d.cts`, + default: `./${key}.d.ts`, }, - import: `./dist/${key}.js`, - require: `./dist/${key}.cjs`, + import: `./${key}.js`, + require: `./${key}.cjs`, }; return acc; }, {} ); + packageJson.exports = { + ...packageJson.exports, + "./package.json": "./package.json", + }; let packageJsonString = JSON.stringify(packageJson, null, 2); if ( @@ -202,7 +254,8 @@ async function updatePackageJson(config: LangChainConfig): Promise { // Optionally, update test exports files await Promise.all([ fs.promises.writeFile(`package.json`, packageJsonString), - generateDCTSFiles(config), + writeTopLevelGeneratedFiles(generatedFiles), + updateGitIgnore(config, filenames), config.shouldTestExports ? updateExportTestFiles(config) : Promise.resolve(), @@ -430,10 +483,12 @@ async function checkTreeShaking(config: LangChainConfig) { } } + function processOptions(): { shouldCreateEntrypoints: boolean; shouldCheckTreeShaking: boolean; shouldGenMaps: boolean; + pre: boolean; } { const program = new Command(); program @@ -447,7 +502,8 @@ function processOptions(): { "Pass only if you want to create entrypoints" ) .option("--tree-shaking", "Pass only if you want to check tree shaking") - .option("--gen-maps"); + .option("--gen-maps") + .option("--pre"); program.parse(); @@ -456,42 +512,130 @@ function processOptions(): { const shouldCreateEntrypoints = options.createEntrypoints; const shouldCheckTreeShaking = options.treeShaking; const shouldGenMaps = options.genMaps; + const pre = options.pre; return { shouldCreateEntrypoints, shouldCheckTreeShaking, shouldGenMaps, + pre, }; } -export async function buildWithTSup() { - const { shouldCreateEntrypoints, shouldCheckTreeShaking, shouldGenMaps } = - processOptions(); - - const importPath = `${process.cwd()}/langchain.config.js`; - const { config }: { config: LangChainConfig } = await import(importPath); +async function cleanGeneratedFiles(config: LangChainConfig) { + const allFileNames = Object.keys(config.entrypoints) + .map((key) => [`${key}.cjs`, `${key}.js`, `${key}.d.ts`, `${key}.d.dts`]) + .flat(); + return Promise.all( + allFileNames.map(async (fileName) => { + try { + await fs.promises.unlink(fileName); + } catch { + // no-op + } + }) + ); +} - if (shouldCreateEntrypoints) { - await rimraf("dist"); +export async function moveAndRename({ + source, + dest, + abs, +}: { + source: string; + dest: string; + abs: (p: string) => string; +}) { + try { + for (const file of await fs.promises.readdir(abs(source), { + withFileTypes: true, + })) { + if (file.isDirectory()) { + await moveAndRename({ + source: `${source}/${file.name}`, + dest: `${dest}/${file.name}`, + abs, + }); + } else if (file.isFile()) { + const parsed = path.parse(file.name); + + // Ignore anything that's not a .js file + if (parsed.ext !== ".js") { + continue; + } - // Build with TSC + // Rewrite any require statements to use .cjs + const content = await fs.promises.readFile( + abs(`${source}/${file.name}`), + "utf8" + ); + const rewritten = content.replace( + /require\("(\..+?).js"\)/g, + (_, p1) => `require("${p1}.cjs")` + ); + + // Rename the file to .cjs + const renamed = path.format({ name: parsed.name, ext: ".cjs" }); + + await fs.promises.writeFile( + abs(`${dest}/${renamed}`), + rewritten, + "utf8" + ); + } + } + } catch (err) { + console.error(err); + process.exit(1); + } +} - // Build CJS with TSC +export async function buildWithTSup() { + const { + shouldCreateEntrypoints, + shouldCheckTreeShaking, + shouldGenMaps, + pre, + } = processOptions(); - // Move CJS to dist + const importPath = `${process.cwd()}/langchain.config.js`; + const { config }: { config: LangChainConfig } = await import(importPath); - // Rest + // Clean & generate build files + if (pre && shouldGenMaps) { + await Promise.all([ + rimraf("dist"), + rimraf(".turbo"), + cleanGeneratedFiles(config), + createImportMapFile(config), + generateImportConstants(config), + generateImportTypes(config), + ]); + } else if (pre && !shouldGenMaps) { + await Promise.all([ + rimraf("dist"), + rimraf(".turbo"), + cleanGeneratedFiles(config), + ]); + } - if (shouldGenMaps) { - // Updates import_map.ts, import_constants.ts, and import_types.ts - await Promise.all([ - createImportMapFile(config), - generateImportConstants(config), - generateImportTypes(config), - ]); - } - // Adds entrypoints to package.json file. - await updatePackageJson(config); + if (shouldCreateEntrypoints) { + await Promise.all([ + asyncSpawn("tsc", ["--outDir", "dist/"]), + asyncSpawn("tsc", ["--outDir", "dist-cjs/", "-p", "tsconfig.cjs.json"]), + ]); + await moveAndRename({ + source: config.cjsSource, + dest: config.cjsDestination, + abs: config.abs, + }); + // move CJS to dist + await Promise.all([ + updatePackageJson(config), + rimraf("dist-cjs"), + rimraf("dist/tests"), + rimraf("dist/**/tests"), + ]); } if (shouldCheckTreeShaking) { diff --git a/libs/langchain-scripts/src/types.ts b/libs/langchain-scripts/src/types.ts index 64a43f749342..bb56fbd4e2ea 100644 --- a/libs/langchain-scripts/src/types.ts +++ b/libs/langchain-scripts/src/types.ts @@ -17,7 +17,11 @@ export interface PackageJSONPerson extends PackageJSONAddress { } export interface ExportsMapValue { - types: string; + types: { + import: string; + require: string; + default: string; + }; import: string; require: string; } diff --git a/yarn.lock b/yarn.lock index f131d921432f..f71b23ab2375 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10114,6 +10114,7 @@ __metadata: typescript: ^5.4.5 bin: lc-build: bin/build.js + "lc-build:new": bin/build_new.js languageName: unknown linkType: soft From b0377cf143d5634b42f4a9d20866038311397bbc Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 12:44:43 -0700 Subject: [PATCH 03/10] chore: lint files --- libs/langchain-scripts/src/new/build.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/langchain-scripts/src/new/build.ts b/libs/langchain-scripts/src/new/build.ts index 7782382e0916..b685016db84e 100644 --- a/libs/langchain-scripts/src/new/build.ts +++ b/libs/langchain-scripts/src/new/build.ts @@ -4,8 +4,8 @@ import fs from "node:fs"; import { rimraf } from "rimraf"; import { Command } from "commander"; import { rollup } from "rollup"; -import { ExportsMapValue, ImportData, LangChainConfig } from "../types.js"; import path from "node:path"; +import { ExportsMapValue, ImportData, LangChainConfig } from "../types.js"; async function asyncSpawn(command: string, args: string[]) { return new Promise((resolve, reject) => { @@ -483,7 +483,6 @@ async function checkTreeShaking(config: LangChainConfig) { } } - function processOptions(): { shouldCreateEntrypoints: boolean; shouldCheckTreeShaking: boolean; @@ -512,7 +511,7 @@ function processOptions(): { const shouldCreateEntrypoints = options.createEntrypoints; const shouldCheckTreeShaking = options.treeShaking; const shouldGenMaps = options.genMaps; - const pre = options.pre; + const {pre} = options; return { shouldCreateEntrypoints, From 5ba09d00523106150a6dd6ce7c540fd343e4003f Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 13:01:57 -0700 Subject: [PATCH 04/10] very nice much better --- langchain-core/package.json | 2 +- libs/langchain-scripts/.gitignore | 1 + libs/langchain-scripts/bin/build_new.js | 642 ------------------ libs/langchain-scripts/bin/build_v2.js | 1 + libs/langchain-scripts/langchain.config.js | 2 +- libs/langchain-scripts/package.json | 18 +- .../src/{new/build.ts => build_v2.ts} | 9 +- libs/langchain-scripts/tsconfig.build.json | 36 + libs/langchain-scripts/tsconfig.json | 4 +- yarn.lock | 2 +- 10 files changed, 56 insertions(+), 661 deletions(-) delete mode 100755 libs/langchain-scripts/bin/build_new.js create mode 100755 libs/langchain-scripts/bin/build_v2.js rename libs/langchain-scripts/src/{new/build.ts => build_v2.ts} (98%) create mode 100644 libs/langchain-scripts/tsconfig.build.json diff --git a/langchain-core/package.json b/langchain-core/package.json index 483bcf450543..7a4558556339 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/", "scripts": { - "build": "yarn lc-build:new --create-entrypoints --pre --tree-shaking", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:old": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", "clean:old": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", "build:deps": "yarn turbo:command build --filter=@langchain/scripts", diff --git a/libs/langchain-scripts/.gitignore b/libs/langchain-scripts/.gitignore index 7c79377877a9..c0d1a0a68d25 100644 --- a/libs/langchain-scripts/.gitignore +++ b/libs/langchain-scripts/.gitignore @@ -18,3 +18,4 @@ node_modules dist .yarn !bin/build.js +dist_build diff --git a/libs/langchain-scripts/bin/build_new.js b/libs/langchain-scripts/bin/build_new.js deleted file mode 100755 index 6c05051a8f14..000000000000 --- a/libs/langchain-scripts/bin/build_new.js +++ /dev/null @@ -1,642 +0,0 @@ -import { spawn } from "child_process"; -import ts from "typescript"; -import fs from "node:fs"; -import { rimraf } from "rimraf"; -import { Command } from "commander"; -import { rollup } from "rollup"; -import path from "node:path"; - -async function asyncSpawn(command, args) { - return new Promise((resolve, reject) => { - const child = spawn(command, args, { - stdio: "inherit", - env: { - ...process.env, - NODE_OPTIONS: "--max-old-space-size=4096", - }, - }); - child.on("close", (code) => { - if (code !== 0) { - reject(new Error(`Command failed: ${command} ${args.join(" ")}`)); - return; - } - resolve(); - }); - }); -} - -const NEWLINE = ` -`; - -// List of test-exports-* packages which we use to test that the exports field -// works correctly across different JS environments. -// Each entry is a tuple of [package name, import statement]. -const testExports = [ - [ - "test-exports-esm", - (p) => - `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, - ], - [ - "test-exports-esbuild", - (p) => - `import * as ${p.replace(/\//g, "_")} from "langchain/${p}";`, - ], - [ - "test-exports-cjs", - (p) => - `const ${p.replace(/\//g, "_")} = require("langchain/${p}");`, - ], - ["test-exports-cf", (p) => `export * from "langchain/${p}";`], - ["test-exports-vercel", (p) => `export * from "langchain/${p}";`], - ["test-exports-vite", (p) => `export * from "langchain/${p}";`], - ["test-exports-bun", (p) => `export * from "langchain/${p}";`], -]; - -const DEFAULT_GITIGNORE_PATHS = ["node_modules", "dist", ".yarn"]; - -async function createImportMapFile(config) { - const createImportStatement = (k, p) => - `export * as ${k.replace(/\//g, "__")} from "../${p - .replace("src/", "") - .replace(".ts", ".js")}";`; - - const entrypointsToInclude = Object.keys(config.entrypoints) - .filter((key) => key !== "load") - .filter((key) => !config.deprecatedNodeOnly?.includes(key)) - .filter((key) => !config.requiresOptionalDependency?.includes(key)) - .filter((key) => !config.deprecatedOmitFromImportMap?.includes(key)); - const importMapExports = entrypointsToInclude - .map((key) => `${createImportStatement(key, config.entrypoints[key])}`) - .join("\n"); - - let extraContent = ""; - if (config.extraImportMapEntries) { - const extraImportData = config.extraImportMapEntries?.reduce( - (data, { modules, alias, path }) => { - const newData = { ...data }; - if (!newData.imports[path]) { - newData.imports[path] = []; - } - newData.imports[path] = [ - ...new Set(newData.imports[path].concat(modules)), - ]; - const exportAlias = alias.join("__"); - if (!newData.exportedAliases[exportAlias]) { - newData.exportedAliases[exportAlias] = []; - } - newData.exportedAliases[exportAlias] = - newData.exportedAliases[exportAlias].concat(modules); - return newData; - }, - { - imports: {}, - exportedAliases: {}, - } - ); - const extraImportStatements = Object.entries(extraImportData.imports).map( - ([path, modules]) => - `import {\n ${modules.join(",\n ")}\n} from "${path}";` - ); - const extraDeclarations = Object.entries( - extraImportData.exportedAliases - ).map(([exportAlias, modules]) => - [ - `const ${exportAlias} = {\n ${modules.join(",\n ")}\n};`, - `export { ${exportAlias} };`, - ].join("\n") - ); - extraContent = `${extraImportStatements.join( - "\n" - )}\n${extraDeclarations.join("\n")}\n`; - - extraContent.trim(); - if (!/[a-zA-Z0-9]/.test(extraContent)) { - extraContent = ""; - } - } - - const importMapContents = `// Auto-generated by build script. Do not edit manually.\n\n${importMapExports}\n${extraContent}`; - await fs.promises.writeFile("src/load/import_map.ts", importMapContents); -} - -async function generateImportConstants(config) { - // Generate import constants - const entrypointsToInclude = Object.keys(config.entrypoints) - .filter((key) => !config.deprecatedNodeOnly?.includes(key)) - .filter((key) => config.requiresOptionalDependency?.includes(key)); - const importConstantsPath = "src/load/import_constants.ts"; - const createImportStatement = (k) => - ` "langchain${config.packageSuffix ? `_${config.packageSuffix}` : "" - }/${k}"`; - const contents = - entrypointsToInclude.length > 0 - ? `\n${entrypointsToInclude - .map((key) => createImportStatement(key)) - .join(",\n")},\n];\n` - : "];\n"; - await fs.promises.writeFile( - `${importConstantsPath}`, - `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually.\n\nexport const optionalImportEntrypoints: string[] = [${contents}` - ); -} - -const generateFiles = (config) => { - const files = [...Object.entries(config.entrypoints)].flatMap( - ([key, value]) => { - const nrOfDots = key.split("/").length - 1; - const relativePath = "../".repeat(nrOfDots) || "./"; - const compiledPath = `${relativePath}dist/${value}.js`; - return [ - [ - `${key}.cjs`, - `module.exports = require('${relativePath}dist/${value}.cjs');`, - ], - [`${key}.js`, `export * from '${compiledPath}'`], - [`${key}.d.ts`, `export * from '${compiledPath}'`], - [`${key}.d.cts`, `export * from '${compiledPath}'`], - ]; - } - ); - - return Object.fromEntries(files); -}; - -async function updateExportTestFiles(config) { - // Update test-exports-*/entrypoints.js - const entrypointsToTest = Object.keys(config.entrypoints) - .filter((key) => !config.deprecatedNodeOnly?.includes(key)) - .filter((key) => !config.requiresOptionalDependency?.includes(key)); - - return Promise.all( - testExports.map(async ([pkg, importStatement]) => { - const contents = `${entrypointsToTest - .map((key) => importStatement(key)) - .join("\n")}\n`; - fs.promises.writeFile( - `../environment_tests/${pkg}/src/entrypoints.js`, - contents - ); - }) - ); -} - -async function writeTopLevelGeneratedFiles( - generatedFiles -) { - return Promise.all( - Object.entries(generatedFiles).map(async ([filename, content]) => { - await fs.promises.mkdir(path.dirname(filename), { recursive: true }); - await fs.promises.writeFile(filename, content); - }) - ); -} - -async function updateGitIgnore( - config, - filenames -) { - const gitignorePaths = [ - ...filenames, - ...DEFAULT_GITIGNORE_PATHS, - ...(config.additionalGitignorePaths ? config.additionalGitignorePaths : []), - ]; - - // Update .gitignore - return fs.promises.writeFile( - "./.gitignore", - `${gitignorePaths.join("\n")}\n` - ); -} - -async function updatePackageJson(config) { - const packageJson = JSON.parse( - await fs.promises.readFile(`package.json`, "utf8") - ); - const generatedFiles = generateFiles(config); - const filenames = Object.keys(generatedFiles); - packageJson.files = ["dist/", ...filenames]; - packageJson.exports = Object.keys(config.entrypoints).reduce( - (acc, key) => { - let entrypoint = `./${key}`; - if (key === "index") { - entrypoint = "."; - } - acc[entrypoint] = { - types: { - import: `./${key}.d.ts`, - require: `./${key}.d.cts`, - default: `./${key}.d.ts`, - }, - import: `./${key}.js`, - require: `./${key}.cjs`, - }; - return acc; - }, - {} - ); - packageJson.exports = { - ...packageJson.exports, - "./package.json": "./package.json", - }; - - let packageJsonString = JSON.stringify(packageJson, null, 2); - if ( - !packageJsonString.endsWith("\n") && - !packageJsonString.endsWith(NEWLINE) - ) { - packageJsonString += NEWLINE; - } - - // Write package.json and generate d.cts files - // Optionally, update test exports files - await Promise.all([ - fs.promises.writeFile(`package.json`, packageJsonString), - writeTopLevelGeneratedFiles(generatedFiles), - updateGitIgnore(config, filenames), - config.shouldTestExports - ? updateExportTestFiles(config) - : Promise.resolve(), - ]); -} - -export function identifySecrets(absTsConfigPath) { - const secrets = new Set(); - - const tsConfig = ts.parseJsonConfigFileContent( - ts.readJsonConfigFile(absTsConfigPath, (p) => fs.readFileSync(p, "utf-8")), - ts.sys, - "./src/" - ); - - // `tsConfig.options.target` is not always defined when running this - // via the `@langchain/scripts` package. Instead, fallback to the raw - // tsConfig.json file contents. - const tsConfigFileContentsText = - "text" in tsConfig.raw - ? JSON.parse(tsConfig.raw.text) - : { compilerOptions: {} }; - - const tsConfigTarget = - tsConfig.options.target || tsConfigFileContentsText.compilerOptions.target; - - for (const fileName of tsConfig.fileNames.filter( - (fn) => !fn.endsWith("test.ts") - )) { - if (!tsConfigTarget) { - continue; - } - - const sourceFile = ts.createSourceFile( - fileName, - fs.readFileSync(fileName, "utf-8"), - tsConfigTarget, - true - ); - - sourceFile.forEachChild((node) => { - switch (node.kind) { - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: { - node.forEachChild((node) => { - // look for get lc_secrets() - switch (node.kind) { - case ts.SyntaxKind.GetAccessor: { - const property = node; - if ( - ts.isGetAccessor(property) && - property.name.getText() === "lc_secrets" - ) { - // look for return { ... } - property.body?.statements.forEach((stmt) => { - if ( - ts.isReturnStatement(stmt) && - stmt.expression && - ts.isObjectLiteralExpression(stmt.expression) - ) { - stmt.expression.properties.forEach((element) => { - if (ts.isPropertyAssignment(element)) { - // Type guard for PropertyAssignment - if ( - element.initializer && - ts.isStringLiteral(element.initializer) - ) { - const secret = element.initializer.text; - - if (secret.toUpperCase() !== secret) { - throw new Error( - `Secret identifier must be uppercase: ${secret} at ${fileName}` - ); - } - if (/\s/.test(secret)) { - throw new Error( - `Secret identifier must not contain whitespace: ${secret} at ${fileName}` - ); - } - - secrets.add(secret); - } - } - }); - } - }); - } - break; - } - default: - break; - } - }); - break; - } - default: - break; - } - }); - } - - return secrets; -} - -async function generateImportTypes(config) { - // Generate import types - const pkg = `langchain${config.packageSuffix ? `-${config.packageSuffix}` : "" - }`; - const importTypesPath = "src/load/import_type.ts"; - - await fs.promises.writeFile( - `../${pkg}/${importTypesPath}`, - `// Auto-generated by \`scripts/create-entrypoints.js\`. Do not edit manually. - -export interface OptionalImportMap {} - -export interface SecretMap { -${[...identifySecrets(config.tsConfigPath)] - .sort() - .map((secret) => ` ${secret}?: string;`) - .join("\n")} -} -` - ); -} - -function listExternals( - packageJson, - extraInternals -) { - return [ - ...Object.keys(packageJson.dependencies ?? {}), - ...Object.keys(packageJson.peerDependencies ?? {}), - ...(extraInternals || []), - ]; -} - -function listEntrypoints(packageJson) { - const { exports } = packageJson; - /** @type {Record | null} */ - const exportsWithoutPackageJSON = exports - ? Object.entries(exports) - .filter(([k]) => k !== "./package.json") - .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}) - : null; - - if (!exportsWithoutPackageJSON) { - throw new Error("No exports found in package.json"); - } - /** @type {string[]} */ - const entrypoints = []; - - for (const [key, value] of Object.entries(exportsWithoutPackageJSON)) { - if (key === "./package.json") { - continue; - } - if (typeof value === "string") { - entrypoints.push(value); - } else if ( - "import" in value && - value.import && - typeof value.import === "string" - ) { - entrypoints.push(value.import); - } - } - - return entrypoints; -} - -async function checkTreeShaking(config) { - const packageJson = JSON.parse( - await fs.promises.readFile("package.json", "utf8") - ); - const externals = listExternals(packageJson, config?.internals ?? []); - const entrypoints = listEntrypoints(packageJson); - const consoleLog = console.log; - /** @type {Map} */ - const reportMap = new Map(); - - for (const entrypoint of entrypoints) { - let sideEffects = ""; - - console.log = function (...args) { - const line = args.length ? args.join(" ") : ""; - if (line.trim().startsWith("First side effect in")) { - sideEffects += `${line}\n`; - } - }; - - await rollup({ - external: externals, - input: entrypoint, - experimentalLogSideEffects: true, - }); - - reportMap.set(entrypoint, { - log: sideEffects, - hasSideEffects: sideEffects.length > 0, - }); - } - - console.log = consoleLog; - - let failed = false; - for (const [entrypoint, report] of reportMap) { - if (report.hasSideEffects) { - failed = true; - console.log("---------------------------------"); - console.log(`Tree shaking failed for ${entrypoint}`); - console.log(report.log); - } - } - - if (failed) { - process.exit(1); - } else { - console.log("Tree shaking checks passed!"); - } -} - -/** - * Processes the command line options and returns an object with the parsed options. - * - * @returns {Object} An object containing the parsed options: - * - shouldCreateEntrypoints: boolean indicating if entrypoints should be created - * - shouldCheckTreeShaking: boolean indicating if tree shaking should be checked - * - shouldGenMaps: boolean indicating if maps should be generated - * - pre: boolean value of the --pre flag - */ -function processOptions() { - const program = new Command(); - program - .description("Run a build script for a LangChain package.") - .option( - "--config ", - "Path to the config file, defaults to ./langchain.config.js" - ) - .option( - "--create-entrypoints", - "Pass only if you want to create entrypoints" - ) - .option("--tree-shaking", "Pass only if you want to check tree shaking") - .option("--gen-maps") - .option("--pre"); - - program.parse(); - - const options = program.opts(); - - const shouldCreateEntrypoints = options.createEntrypoints; - const shouldCheckTreeShaking = options.treeShaking; - const shouldGenMaps = options.genMaps; - const pre = options.pre; - - return { - shouldCreateEntrypoints, - shouldCheckTreeShaking, - shouldGenMaps, - pre, - }; -} - -async function cleanGeneratedFiles(config) { - const allFileNames = Object.keys(config.entrypoints) - .map((key) => [`${key}.cjs`, `${key}.js`, `${key}.d.ts`, `${key}.d.cts`]) - .flat(); - return Promise.all( - allFileNames.map(async (fileName) => { - try { - await fs.promises.unlink(fileName); - } catch { - // no-op - } - }) - ); -} - -export async function moveAndRename({ - source, - dest, - abs, -}) { - try { - for (const file of await fs.promises.readdir(abs(source), { - withFileTypes: true, - })) { - if (file.isDirectory()) { - await moveAndRename({ - source: `${source}/${file.name}`, - dest: `${dest}/${file.name}`, - abs, - }); - } else if (file.isFile()) { - const parsed = path.parse(file.name); - - // Ignore anything that's not a .js file - if (parsed.ext !== ".js") { - continue; - } - - // Rewrite any require statements to use .cjs - const content = await fs.promises.readFile( - abs(`${source}/${file.name}`), - "utf8" - ); - const rewritten = content.replace( - /require\("(\..+?).js"\)/g, - (_, p1) => `require("${p1}.cjs")` - ); - - // Rename the file to .cjs - const renamed = path.format({ name: parsed.name, ext: ".cjs" }); - - await fs.promises.writeFile( - abs(`${dest}/${renamed}`), - rewritten, - "utf8" - ); - } - } - } catch (err) { - console.error(err); - process.exit(1); - } -} - -export async function buildWithTSup() { - const { - shouldCreateEntrypoints, - shouldCheckTreeShaking, - shouldGenMaps, - pre, - } = processOptions(); - - const importPath = `${process.cwd()}/langchain.config.js`; - const { config } = await import(importPath); - - // Clean & generate build files - if (pre && shouldGenMaps) { - await Promise.all([ - rimraf("dist"), - rimraf(".turbo"), - cleanGeneratedFiles(config), - createImportMapFile(config), - generateImportConstants(config), - generateImportTypes(config), - ]); - } else if (pre && !shouldGenMaps) { - await Promise.all([ - rimraf("dist"), - rimraf(".turbo"), - cleanGeneratedFiles(config), - ]); - } - - if (shouldCreateEntrypoints) { - await Promise.all([ - asyncSpawn("tsc", ["--outDir", "dist/"]), - asyncSpawn("tsc", ["--outDir", "dist-cjs/", "-p", "tsconfig.cjs.json"]), - ]); - await moveAndRename({ - source: config.cjsSource, - dest: config.cjsDestination, - abs: config.abs, - }); - // move CJS to dist - await Promise.all([ - updatePackageJson(config), - rimraf("dist-cjs"), - rimraf("dist/tests"), - rimraf("dist/**/tests"), - ]); - } - - if (shouldCheckTreeShaking) { - // Checks tree shaking via rollup - await checkTreeShaking(config); - } -} - - -/* #__PURE__ */ buildWithTSup().catch((e) => { - console.error(e); - process.exit(1); -}); diff --git a/libs/langchain-scripts/bin/build_v2.js b/libs/langchain-scripts/bin/build_v2.js new file mode 100755 index 000000000000..2424bde5af0f --- /dev/null +++ b/libs/langchain-scripts/bin/build_v2.js @@ -0,0 +1 @@ +import "../dist_build/build_v2.js"; diff --git a/libs/langchain-scripts/langchain.config.js b/libs/langchain-scripts/langchain.config.js index ea51869fbff7..64ea4089853a 100644 --- a/libs/langchain-scripts/langchain.config.js +++ b/libs/langchain-scripts/langchain.config.js @@ -21,5 +21,5 @@ export const config = { cjsSource: "./dist-cjs", cjsDestination: "./dist", abs, - additionalGitignorePaths: ["!bin/build.js"] + additionalGitignorePaths: ["!bin/build.js", "dist_build"] } diff --git a/libs/langchain-scripts/package.json b/libs/langchain-scripts/package.json index 8ec282473603..51fe97892ac1 100644 --- a/libs/langchain-scripts/package.json +++ b/libs/langchain-scripts/package.json @@ -15,29 +15,23 @@ "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-scripts/", "bin": { "lc-build": "bin/build.js", - "lc-build:new": "bin/build_new.js" + "lc-build:v2": "bin/build_v2.js" }, "scripts": { - "build": "node bin/build_new.js --create-entrypoints --pre --tree-shaking", - "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 rm -f src/package.json && tsc --outDir dist/", - "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 echo '{}' > src/package.json && tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs src/package.json", - "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", - "build:scripts": "yarn create-entrypoints && yarn check-tree-shaking", + "build": "rm -rf ./build_new && tsc --project ./tsconfig.build.json && yarn build:generated", + "build:generated": "node bin/build_v2.js --create-entrypoints --pre --tree-shaking", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 node ./bin/build.js --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf ./dist ./dist_build .turbo", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000", "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%", "format": "prettier --write \"src\"", - "format:check": "prettier --check \"src\"", - "move-cjs-to-dist": "node ./bin/build.js --config ./langchain.config.js --move-cjs-dist", - "create-entrypoints": "node ./bin/build.js --config ./langchain.config.js --create-entrypoints", - "check-tree-shaking": "node ./bin/build.js --config ./langchain.config.js --tree-shaking" + "format:check": "prettier --check \"src\"" }, "author": "LangChain", "license": "MIT", @@ -45,6 +39,7 @@ "axios": "^1.6.7", "commander": "^11.1.0", "glob": "^10.3.10", + "rimraf": "^5.0.1", "rollup": "^4.5.2", "ts-morph": "^21.0.1", "typescript": "^5.4.5" @@ -68,7 +63,6 @@ "jest-environment-node": "^29.6.4", "prettier": "^2.8.3", "release-it": "^15.10.1", - "rimraf": "^5.0.1", "ts-jest": "^29.1.0" }, "publishConfig": { diff --git a/libs/langchain-scripts/src/new/build.ts b/libs/langchain-scripts/src/build_v2.ts similarity index 98% rename from libs/langchain-scripts/src/new/build.ts rename to libs/langchain-scripts/src/build_v2.ts index b685016db84e..178d67e7535d 100644 --- a/libs/langchain-scripts/src/new/build.ts +++ b/libs/langchain-scripts/src/build_v2.ts @@ -1,11 +1,11 @@ -import { spawn } from "child_process"; +import { spawn } from "node:child_process"; import ts from "typescript"; import fs from "node:fs"; import { rimraf } from "rimraf"; import { Command } from "commander"; import { rollup } from "rollup"; import path from "node:path"; -import { ExportsMapValue, ImportData, LangChainConfig } from "../types.js"; +import { ExportsMapValue, ImportData, LangChainConfig } from "./types.js"; async function asyncSpawn(command: string, args: string[]) { return new Promise((resolve, reject) => { @@ -642,3 +642,8 @@ export async function buildWithTSup() { await checkTreeShaking(config); } } + +/* #__PURE__ */ buildWithTSup().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/libs/langchain-scripts/tsconfig.build.json b/libs/langchain-scripts/tsconfig.build.json new file mode 100644 index 000000000000..191e76c228c2 --- /dev/null +++ b/libs/langchain-scripts/tsconfig.build.json @@ -0,0 +1,36 @@ +{ + "extends": "@tsconfig/recommended", + "compilerOptions": { + "outDir": "./dist_build", + "rootDir": "./src", + "target": "ES2021", + "lib": [ + "ES2021", + "ES2022.Object", + "DOM" + ], + "module": "NodeNext", + "moduleResolution": "nodenext", + "esModuleInterop": true, + "declaration": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "useDefineForClassFields": true, + "strictPropertyInitialization": false, + "allowJs": true, + "strict": true + }, + "include": [ + "src/build_v2.ts", + "src/types.ts" + ], + "exclude": [ + "node_modules/", + "dist", + "docs", + "bin/", + "../../node_modules/" + ] +} \ No newline at end of file diff --git a/libs/langchain-scripts/tsconfig.json b/libs/langchain-scripts/tsconfig.json index 4d818190e533..e0bc2f01fad7 100644 --- a/libs/langchain-scripts/tsconfig.json +++ b/libs/langchain-scripts/tsconfig.json @@ -24,10 +24,10 @@ }, "include": [ "src/**/*", - "bin" + "src/*" ], "exclude": [ - "node_modules", + "node_modules/", "dist", "docs", "bin/" diff --git a/yarn.lock b/yarn.lock index f71b23ab2375..6afc6fd2b289 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10114,7 +10114,7 @@ __metadata: typescript: ^5.4.5 bin: lc-build: bin/build.js - "lc-build:new": bin/build_new.js + "lc-build:v2": bin/build_v2.js languageName: unknown linkType: soft From c5cc961f33745dec31c94e1b53786206b4deae49 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 13:04:43 -0700 Subject: [PATCH 05/10] yarn format && yarn lint:fix --- libs/langchain-scripts/src/build_v2.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/langchain-scripts/src/build_v2.ts b/libs/langchain-scripts/src/build_v2.ts index 178d67e7535d..fd3c36fa2bf5 100644 --- a/libs/langchain-scripts/src/build_v2.ts +++ b/libs/langchain-scripts/src/build_v2.ts @@ -12,6 +12,7 @@ async function asyncSpawn(command: string, args: string[]) { const child = spawn(command, args, { stdio: "inherit", env: { + // eslint-disable-next-line no-process-env ...process.env, NODE_OPTIONS: "--max-old-space-size=4096", }, @@ -175,7 +176,7 @@ async function updateExportTestFiles(config: LangChainConfig): Promise { const contents = `${entrypointsToTest .map((key) => importStatement(key)) .join("\n")}\n`; - fs.promises.writeFile( + return fs.promises.writeFile( `../environment_tests/${pkg}/src/entrypoints.js`, contents ); @@ -511,7 +512,7 @@ function processOptions(): { const shouldCreateEntrypoints = options.createEntrypoints; const shouldCheckTreeShaking = options.treeShaking; const shouldGenMaps = options.genMaps; - const {pre} = options; + const { pre } = options; return { shouldCreateEntrypoints, From e3c0a46e85e2a9ddfd61cd1f911c9958e0c0ae5e Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 14:06:53 -0700 Subject: [PATCH 06/10] all build script updates --- langchain/package.json | 2 +- langchain/src/load/import_map.ts | 2 +- libs/create-langchain-integration/template/package.json | 2 +- libs/langchain-anthropic/package.json | 2 +- libs/langchain-anthropic/src/load/import_map.ts | 2 +- libs/langchain-azure-openai/package.json | 2 +- libs/langchain-cloudflare/package.json | 2 +- libs/langchain-cohere/package.json | 2 +- libs/langchain-community/package.json | 2 +- libs/langchain-community/src/load/import_map.ts | 2 +- libs/langchain-exa/package.json | 2 +- libs/langchain-google-common/package.json | 2 +- libs/langchain-google-gauth/package.json | 2 +- libs/langchain-google-genai/package.json | 2 +- libs/langchain-google-vertexai-web/package.json | 2 +- libs/langchain-google-vertexai/package.json | 2 +- libs/langchain-google-webauth/package.json | 2 +- libs/langchain-groq/package.json | 2 +- libs/langchain-mistralai/package.json | 2 +- libs/langchain-mongodb/package.json | 2 +- libs/langchain-nomic/package.json | 2 +- libs/langchain-openai/package.json | 2 +- libs/langchain-pinecone/package.json | 2 +- libs/langchain-qdrant/package.json | 2 +- libs/langchain-redis/package.json | 2 +- libs/langchain-scripts/src/build_v2.ts | 2 +- libs/langchain-textsplitters/package.json | 2 +- libs/langchain-weaviate/package.json | 2 +- libs/langchain-yandex/package.json | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/langchain/package.json b/langchain/package.json index b76299d79b7f..71e2d9eb0047 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -561,7 +561,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/openai --filter=@langchain/textsplitters --filter=@langchain/cohere --concurrency=1", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/langchain/src/load/import_map.ts b/langchain/src/load/import_map.ts index c9bf4a4cb134..2ac351c8fdba 100644 --- a/langchain/src/load/import_map.ts +++ b/langchain/src/load/import_map.ts @@ -1,4 +1,4 @@ -// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. +// Auto-generated by build script. Do not edit manually. export * as agents from "../agents/index.js"; export * as agents__toolkits from "../agents/toolkits/index.js"; diff --git a/libs/create-langchain-integration/template/package.json b/libs/create-langchain-integration/template/package.json index 99819010a28d..2bdec7502880 100644 --- a/libs/create-langchain-integration/template/package.json +++ b/libs/create-langchain-integration/template/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-anthropic/package.json b/libs/langchain-anthropic/package.json index ba44113d55f8..66b4abf0d541 100644 --- a/libs/langchain-anthropic/package.json +++ b/libs/langchain-anthropic/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-anthropic/src/load/import_map.ts b/libs/langchain-anthropic/src/load/import_map.ts index eba2067309ac..38d77c520377 100644 --- a/libs/langchain-anthropic/src/load/import_map.ts +++ b/libs/langchain-anthropic/src/load/import_map.ts @@ -1,4 +1,4 @@ -// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. +// Auto-generated by build script. Do not edit manually. export * as index from "../index.js"; export * as experimental from "../experimental/index.js"; diff --git a/libs/langchain-azure-openai/package.json b/libs/langchain-azure-openai/package.json index c44b7c446f62..5dda8da77a4f 100644 --- a/libs/langchain-azure-openai/package.json +++ b/libs/langchain-azure-openai/package.json @@ -13,7 +13,7 @@ "url": "git@github.com:langchain-ai/langchainjs.git" }, "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-cloudflare/package.json b/libs/langchain-cloudflare/package.json index 67334506b043..fb45d8f74ae1 100644 --- a/libs/langchain-cloudflare/package.json +++ b/libs/langchain-cloudflare/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cloudflare/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-cohere/package.json b/libs/langchain-cohere/package.json index d6ca6031ca21..d37fb49bc956 100644 --- a/libs/langchain-cohere/package.json +++ b/libs/langchain-cohere/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cohere/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index 262023c22052..61b5514198fd 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-community/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/core --filter=@langchain/openai --filter=langchain --filter=@langchain/anthropic --concurrency=1", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-community/src/load/import_map.ts b/libs/langchain-community/src/load/import_map.ts index bab7c42c0f86..69a7bb096cec 100644 --- a/libs/langchain-community/src/load/import_map.ts +++ b/libs/langchain-community/src/load/import_map.ts @@ -1,4 +1,4 @@ -// Auto-generated by `scripts/create-entrypoints.js`. Do not edit manually. +// Auto-generated by build script. Do not edit manually. export * as load__serializable from "../load/serializable.js"; export * as tools__aiplugin from "../tools/aiplugin.js"; diff --git a/libs/langchain-exa/package.json b/libs/langchain-exa/package.json index e4f1301e58a7..74c4b08eb33e 100644 --- a/libs/langchain-exa/package.json +++ b/libs/langchain-exa/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-exa/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-common/package.json b/libs/langchain-google-common/package.json index 202afefc6156..d6ec06c26a7d 100644 --- a/libs/langchain-google-common/package.json +++ b/libs/langchain-google-common/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-common/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-gauth/package.json b/libs/langchain-google-gauth/package.json index a4afe548d1d4..e0e405037315 100644 --- a/libs/langchain-google-gauth/package.json +++ b/libs/langchain-google-gauth/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-gauth/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-common", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-genai/package.json b/libs/langchain-google-genai/package.json index 2fdbe04dcf8e..0fc6c4e1712a 100644 --- a/libs/langchain-google-genai/package.json +++ b/libs/langchain-google-genai/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-genai/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-vertexai-web/package.json b/libs/langchain-google-vertexai-web/package.json index d6897c2591ec..b8eefed63421 100644 --- a/libs/langchain-google-vertexai-web/package.json +++ b/libs/langchain-google-vertexai-web/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai-web/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-vertexai/package.json b/libs/langchain-google-vertexai/package.json index 0ea96ffa6166..86487e93c89b 100644 --- a/libs/langchain-google-vertexai/package.json +++ b/libs/langchain-google-vertexai/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-webauth/package.json b/libs/langchain-google-webauth/package.json index 2f9d1c069a15..2ed9ee24b1a3 100644 --- a/libs/langchain-google-webauth/package.json +++ b/libs/langchain-google-webauth/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-webauth/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-common", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-groq/package.json b/libs/langchain-groq/package.json index 746fc2287725..a79ecb375e55 100644 --- a/libs/langchain-groq/package.json +++ b/libs/langchain-groq/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-groq/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-mistralai/package.json b/libs/langchain-mistralai/package.json index 42b218fd1936..473c33960629 100644 --- a/libs/langchain-mistralai/package.json +++ b/libs/langchain-mistralai/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mistralai/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-mongodb/package.json b/libs/langchain-mongodb/package.json index 265a344b5975..55954c1d8ddb 100644 --- a/libs/langchain-mongodb/package.json +++ b/libs/langchain-mongodb/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/openai", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-nomic/package.json b/libs/langchain-nomic/package.json index e8874c59efa6..2d75ef5c9ba1 100644 --- a/libs/langchain-nomic/package.json +++ b/libs/langchain-nomic/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-nomic/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-openai/package.json b/libs/langchain-openai/package.json index 0ecd0ae46a28..c94a2393ba68 100644 --- a/libs/langchain-openai/package.json +++ b/libs/langchain-openai/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-openai/", "scripts": { - "build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-pinecone/package.json b/libs/langchain-pinecone/package.json index 9b91ac5df698..720c07399ff8 100644 --- a/libs/langchain-pinecone/package.json +++ b/libs/langchain-pinecone/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-pinecone/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-qdrant/package.json b/libs/langchain-qdrant/package.json index 1a31f9f4f568..951cfc264dba 100644 --- a/libs/langchain-qdrant/package.json +++ b/libs/langchain-qdrant/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-qdrant", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-redis/package.json b/libs/langchain-redis/package.json index 3f28e56cdefa..4b6ba76a339d 100644 --- a/libs/langchain-redis/package.json +++ b/libs/langchain-redis/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-redis/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-scripts/src/build_v2.ts b/libs/langchain-scripts/src/build_v2.ts index fd3c36fa2bf5..7c1f119c0bf9 100644 --- a/libs/langchain-scripts/src/build_v2.ts +++ b/libs/langchain-scripts/src/build_v2.ts @@ -61,7 +61,7 @@ async function createImportMapFile(config: LangChainConfig): Promise { const createImportStatement = (k: string, p: string) => `export * as ${k.replace(/\//g, "__")} from "../${p .replace("src/", "") - .replace(".ts", ".js")}";`; + .endsWith(".ts") ? p.replace(".ts", ".js") : `${p}.js`}";`; const entrypointsToInclude = Object.keys(config.entrypoints) .filter((key) => key !== "load") diff --git a/libs/langchain-textsplitters/package.json b/libs/langchain-textsplitters/package.json index 52dd1679f791..7f9482e057ff 100644 --- a/libs/langchain-textsplitters/package.json +++ b/libs/langchain-textsplitters/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-weaviate/package.json b/libs/langchain-weaviate/package.json index ca0c651fc6e0..c05530ed8a63 100644 --- a/libs/langchain-weaviate/package.json +++ b/libs/langchain-weaviate/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-weaviate/", "scripts": { - "build": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-yandex/package.json b/libs/langchain-yandex/package.json index 622a2add3e12..6d4c072d3bb0 100644 --- a/libs/langchain-yandex/package.json +++ b/libs/langchain-yandex/package.json @@ -14,7 +14,7 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-yandex/", "scripts": { - "build": "yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts", + "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", From c13bb739d704fd8ca356d71652b7572bc2bb21e4 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 14:12:01 -0700 Subject: [PATCH 07/10] standard clean scrop[t] --- examples/package.json | 1 + langchain-core/package.json | 2 +- langchain/package.json | 2 +- libs/create-langchain-integration/template/package.json | 2 +- libs/langchain-anthropic/package.json | 2 +- libs/langchain-azure-openai/package.json | 2 +- libs/langchain-cloudflare/package.json | 2 +- libs/langchain-cohere/package.json | 2 +- libs/langchain-community/package.json | 2 +- libs/langchain-exa/package.json | 2 +- libs/langchain-google-common/package.json | 2 +- libs/langchain-google-gauth/package.json | 2 +- libs/langchain-google-genai/package.json | 2 +- libs/langchain-google-vertexai-web/package.json | 2 +- libs/langchain-google-vertexai/package.json | 2 +- libs/langchain-google-webauth/package.json | 2 +- libs/langchain-groq/package.json | 2 +- libs/langchain-mistralai/package.json | 2 +- libs/langchain-mongodb/package.json | 2 +- libs/langchain-nomic/package.json | 2 +- libs/langchain-openai/package.json | 2 +- libs/langchain-pinecone/package.json | 2 +- libs/langchain-qdrant/package.json | 2 +- libs/langchain-redis/package.json | 2 +- libs/langchain-scripts/src/build_v2.ts | 8 +++++--- libs/langchain-textsplitters/package.json | 2 +- libs/langchain-weaviate/package.json | 2 +- libs/langchain-yandex/package.json | 2 +- 28 files changed, 32 insertions(+), 29 deletions(-) diff --git a/examples/package.json b/examples/package.json index 59b01ace8847..c684caf168fe 100644 --- a/examples/package.json +++ b/examples/package.json @@ -10,6 +10,7 @@ ], "scripts": { "build": "tsc --declaration --outDir dist/", + "clean": "rm -rf .turbo dist/", "start": "tsx --experimental-wasm-modules -r dotenv/config src/index.ts", "postinstall": "prisma generate --schema ./src/indexes/vector_stores/prisma_vectorstore/prisma/schema.prisma", "start:dist": "yarn build && node -r dotenv/config dist/index.js", diff --git a/langchain-core/package.json b/langchain-core/package.json index 7a4558556339..cee512a9b095 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -16,7 +16,7 @@ "scripts": { "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:old": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", - "clean:old": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "build:deps": "yarn turbo:command build --filter=@langchain/scripts", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/langchain/package.json b/langchain/package.json index 71e2d9eb0047..42911ca5d689 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -572,7 +572,7 @@ "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", "precommit": "lint-staged", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre --gen-maps", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "release": "release-it --only-version --config .release-it.json", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", diff --git a/libs/create-langchain-integration/template/package.json b/libs/create-langchain-integration/template/package.json index 2bdec7502880..2ff5f9c3383c 100644 --- a/libs/create-langchain-integration/template/package.json +++ b/libs/create-langchain-integration/template/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-anthropic/package.json b/libs/langchain-anthropic/package.json index 66b4abf0d541..6b1487739bd3 100644 --- a/libs/langchain-anthropic/package.json +++ b/libs/langchain-anthropic/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre --gen-maps", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-azure-openai/package.json b/libs/langchain-azure-openai/package.json index 5dda8da77a4f..a4b4fdfa91df 100644 --- a/libs/langchain-azure-openai/package.json +++ b/libs/langchain-azure-openai/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-cloudflare/package.json b/libs/langchain-cloudflare/package.json index fb45d8f74ae1..536a3d778807 100644 --- a/libs/langchain-cloudflare/package.json +++ b/libs/langchain-cloudflare/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-cohere/package.json b/libs/langchain-cohere/package.json index d37fb49bc956..adbaa4fb3dae 100644 --- a/libs/langchain-cohere/package.json +++ b/libs/langchain-cohere/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index 61b5514198fd..d14f0d121700 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre --gen-maps", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-exa/package.json b/libs/langchain-exa/package.json index 74c4b08eb33e..7fde9d1115c7 100644 --- a/libs/langchain-exa/package.json +++ b/libs/langchain-exa/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-common/package.json b/libs/langchain-google-common/package.json index d6ec06c26a7d..10e1ab55475f 100644 --- a/libs/langchain-google-common/package.json +++ b/libs/langchain-google-common/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-gauth/package.json b/libs/langchain-google-gauth/package.json index e0e405037315..d6dc06bb5746 100644 --- a/libs/langchain-google-gauth/package.json +++ b/libs/langchain-google-gauth/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-genai/package.json b/libs/langchain-google-genai/package.json index 0fc6c4e1712a..366bec1eed03 100644 --- a/libs/langchain-google-genai/package.json +++ b/libs/langchain-google-genai/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-vertexai-web/package.json b/libs/langchain-google-vertexai-web/package.json index b8eefed63421..2bf4f396a126 100644 --- a/libs/langchain-google-vertexai-web/package.json +++ b/libs/langchain-google-vertexai-web/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-vertexai/package.json b/libs/langchain-google-vertexai/package.json index 86487e93c89b..f3942b41fbef 100644 --- a/libs/langchain-google-vertexai/package.json +++ b/libs/langchain-google-vertexai/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-google-webauth/package.json b/libs/langchain-google-webauth/package.json index 2ed9ee24b1a3..2ec3b6a404d2 100644 --- a/libs/langchain-google-webauth/package.json +++ b/libs/langchain-google-webauth/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-groq/package.json b/libs/langchain-groq/package.json index a79ecb375e55..7ca6af256edb 100644 --- a/libs/langchain-groq/package.json +++ b/libs/langchain-groq/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-mistralai/package.json b/libs/langchain-mistralai/package.json index 473c33960629..23339b523985 100644 --- a/libs/langchain-mistralai/package.json +++ b/libs/langchain-mistralai/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-mongodb/package.json b/libs/langchain-mongodb/package.json index 55954c1d8ddb..0bfda33c34c6 100644 --- a/libs/langchain-mongodb/package.json +++ b/libs/langchain-mongodb/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-nomic/package.json b/libs/langchain-nomic/package.json index 2d75ef5c9ba1..a3fee1b59e52 100644 --- a/libs/langchain-nomic/package.json +++ b/libs/langchain-nomic/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-openai/package.json b/libs/langchain-openai/package.json index c94a2393ba68..04521d512cc7 100644 --- a/libs/langchain-openai/package.json +++ b/libs/langchain-openai/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rimraf .turbo/ dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-pinecone/package.json b/libs/langchain-pinecone/package.json index 720c07399ff8..801b13eee356 100644 --- a/libs/langchain-pinecone/package.json +++ b/libs/langchain-pinecone/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-qdrant/package.json b/libs/langchain-qdrant/package.json index 951cfc264dba..2a7f941a7f10 100644 --- a/libs/langchain-qdrant/package.json +++ b/libs/langchain-qdrant/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-redis/package.json b/libs/langchain-redis/package.json index 4b6ba76a339d..23ccfe0f6471 100644 --- a/libs/langchain-redis/package.json +++ b/libs/langchain-redis/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-scripts/src/build_v2.ts b/libs/langchain-scripts/src/build_v2.ts index 7c1f119c0bf9..e8764f6b48e5 100644 --- a/libs/langchain-scripts/src/build_v2.ts +++ b/libs/langchain-scripts/src/build_v2.ts @@ -59,9 +59,11 @@ const DEFAULT_GITIGNORE_PATHS = ["node_modules", "dist", ".yarn"]; async function createImportMapFile(config: LangChainConfig): Promise { const createImportStatement = (k: string, p: string) => - `export * as ${k.replace(/\//g, "__")} from "../${p - .replace("src/", "") - .endsWith(".ts") ? p.replace(".ts", ".js") : `${p}.js`}";`; + `export * as ${k.replace(/\//g, "__")} from "../${ + p.replace("src/", "").endsWith(".ts") + ? p.replace(".ts", ".js") + : `${p}.js` + }";`; const entrypointsToInclude = Object.keys(config.entrypoints) .filter((key) => key !== "load") diff --git a/libs/langchain-textsplitters/package.json b/libs/langchain-textsplitters/package.json index 7f9482e057ff..bd62093d1899 100644 --- a/libs/langchain-textsplitters/package.json +++ b/libs/langchain-textsplitters/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-weaviate/package.json b/libs/langchain-weaviate/package.json index c05530ed8a63..4b7a08d1685f 100644 --- a/libs/langchain-weaviate/package.json +++ b/libs/langchain-weaviate/package.json @@ -24,7 +24,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts", diff --git a/libs/langchain-yandex/package.json b/libs/langchain-yandex/package.json index 6d4c072d3bb0..93ad34275cbb 100644 --- a/libs/langchain-yandex/package.json +++ b/libs/langchain-yandex/package.json @@ -23,7 +23,7 @@ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm", - "clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn lc-build --config ./langchain.config.js --create-entrypoints --pre", + "clean": "rm -rf .turbo dist/", "prepack": "yarn build", "release": "release-it --only-version --config .release-it.json", "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%", From 648866ecdb642d6b8c41b336c21e96fafd3fedb5 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 15:12:55 -0700 Subject: [PATCH 08/10] add turbo to every repo --- langchain-core/package.json | 7 +- langchain-core/turbo.json | 11 +++ langchain/package.json | 3 +- langchain/turbo.json | 11 +++ .../template/package.json | 3 +- .../template/turbo.json | 11 +++ libs/langchain-anthropic/package.json | 3 +- libs/langchain-anthropic/turbo.json | 11 +++ libs/langchain-azure-openai/package.json | 3 +- libs/langchain-azure-openai/turbo.json | 11 +++ libs/langchain-cloudflare/package.json | 3 +- libs/langchain-cloudflare/turbo.json | 11 +++ libs/langchain-cohere/package.json | 3 +- libs/langchain-cohere/turbo.json | 11 +++ libs/langchain-community/package.json | 3 +- libs/langchain-community/turbo.json | 11 +++ libs/langchain-exa/package.json | 3 +- libs/langchain-exa/turbo.json | 11 +++ libs/langchain-google-common/package.json | 3 +- libs/langchain-google-common/turbo.json | 11 +++ libs/langchain-google-gauth/package.json | 3 +- libs/langchain-google-gauth/turbo.json | 11 +++ libs/langchain-google-genai/package.json | 3 +- libs/langchain-google-genai/turbo.json | 11 +++ .../package.json | 3 +- libs/langchain-google-vertexai-web/turbo.json | 11 +++ libs/langchain-google-vertexai/package.json | 3 +- libs/langchain-google-vertexai/turbo.json | 11 +++ libs/langchain-google-webauth/package.json | 3 +- libs/langchain-google-webauth/turbo.json | 11 +++ libs/langchain-groq/package.json | 3 +- libs/langchain-groq/turbo.json | 11 +++ libs/langchain-mistralai/package.json | 3 +- libs/langchain-mistralai/turbo.json | 11 +++ libs/langchain-mongodb/package.json | 5 +- libs/langchain-mongodb/turbo.json | 11 +++ libs/langchain-nomic/package.json | 3 +- libs/langchain-nomic/turbo.json | 11 +++ libs/langchain-openai/package.json | 3 +- libs/langchain-openai/turbo.json | 11 +++ libs/langchain-pinecone/package.json | 3 +- libs/langchain-pinecone/turbo.json | 11 +++ libs/langchain-qdrant/package.json | 3 +- libs/langchain-qdrant/turbo.json | 11 +++ libs/langchain-redis/package.json | 3 +- libs/langchain-redis/turbo.json | 11 +++ libs/langchain-scripts/package.json | 4 +- libs/langchain-scripts/turbo.json | 12 +++ libs/langchain-textsplitters/package.json | 5 +- libs/langchain-textsplitters/turbo.json | 11 +++ libs/langchain-weaviate/package.json | 3 +- libs/langchain-weaviate/turbo.json | 11 +++ libs/langchain-yandex/package.json | 3 +- libs/langchain-yandex/turbo.json | 11 +++ package.json | 25 +++--- turbo.json | 87 +++---------------- yarn.lock | 61 +++++++------ 57 files changed, 412 insertions(+), 149 deletions(-) create mode 100644 langchain-core/turbo.json create mode 100644 langchain/turbo.json create mode 100644 libs/create-langchain-integration/template/turbo.json create mode 100644 libs/langchain-anthropic/turbo.json create mode 100644 libs/langchain-azure-openai/turbo.json create mode 100644 libs/langchain-cloudflare/turbo.json create mode 100644 libs/langchain-cohere/turbo.json create mode 100644 libs/langchain-community/turbo.json create mode 100644 libs/langchain-exa/turbo.json create mode 100644 libs/langchain-google-common/turbo.json create mode 100644 libs/langchain-google-gauth/turbo.json create mode 100644 libs/langchain-google-genai/turbo.json create mode 100644 libs/langchain-google-vertexai-web/turbo.json create mode 100644 libs/langchain-google-vertexai/turbo.json create mode 100644 libs/langchain-google-webauth/turbo.json create mode 100644 libs/langchain-groq/turbo.json create mode 100644 libs/langchain-mistralai/turbo.json create mode 100644 libs/langchain-mongodb/turbo.json create mode 100644 libs/langchain-nomic/turbo.json create mode 100644 libs/langchain-openai/turbo.json create mode 100644 libs/langchain-pinecone/turbo.json create mode 100644 libs/langchain-qdrant/turbo.json create mode 100644 libs/langchain-redis/turbo.json create mode 100644 libs/langchain-scripts/turbo.json create mode 100644 libs/langchain-textsplitters/turbo.json create mode 100644 libs/langchain-weaviate/turbo.json create mode 100644 libs/langchain-yandex/turbo.json diff --git a/langchain-core/package.json b/langchain-core/package.json index cee512a9b095..2aeab2912633 100644 --- a/langchain-core/package.json +++ b/langchain-core/package.json @@ -14,10 +14,10 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain-core/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", - "build:old": "yarn build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn run build:scripts", + "build": "yarn turbo:command build:internal --filter=@langchain/core", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "clean": "rm -rf .turbo dist/", - "build:deps": "yarn turbo:command build --filter=@langchain/scripts", + "build:deps": "yarn turbo build", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", @@ -74,7 +74,6 @@ "prettier": "^2.8.3", "release-it": "^15.10.1", "rimraf": "^5.0.1", - "turbo": "latest", "typescript": "~5.1.6", "web-streams-polyfill": "^3.3.3" }, diff --git a/langchain-core/turbo.json b/langchain-core/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/langchain-core/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/langchain/package.json b/langchain/package.json index 42911ca5d689..5e5b14f3b933 100644 --- a/langchain/package.json +++ b/langchain/package.json @@ -561,7 +561,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build": "yarn turbo:command build:internal --filter=langchain", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/openai --filter=@langchain/textsplitters --filter=@langchain/cohere --concurrency=1", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/langchain/turbo.json b/langchain/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/langchain/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/create-langchain-integration/template/package.json b/libs/create-langchain-integration/template/package.json index 2ff5f9c3383c..bdbf6649f41b 100644 --- a/libs/create-langchain-integration/template/package.json +++ b/libs/create-langchain-integration/template/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/INTEGRATION_NAME", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/create-langchain-integration/template/turbo.json b/libs/create-langchain-integration/template/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/create-langchain-integration/template/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-anthropic/package.json b/libs/langchain-anthropic/package.json index 6b1487739bd3..893f2967d9cf 100644 --- a/libs/langchain-anthropic/package.json +++ b/libs/langchain-anthropic/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-anthropic/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build": "yarn turbo:command build:internal --filter=@langchain/anthropic", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-anthropic/turbo.json b/libs/langchain-anthropic/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-anthropic/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-azure-openai/package.json b/libs/langchain-azure-openai/package.json index a4b4fdfa91df..17c6c15a5f7c 100644 --- a/libs/langchain-azure-openai/package.json +++ b/libs/langchain-azure-openai/package.json @@ -13,7 +13,8 @@ "url": "git@github.com:langchain-ai/langchainjs.git" }, "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/azure-openai", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-azure-openai/turbo.json b/libs/langchain-azure-openai/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-azure-openai/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-cloudflare/package.json b/libs/langchain-cloudflare/package.json index 536a3d778807..f6141d965bb5 100644 --- a/libs/langchain-cloudflare/package.json +++ b/libs/langchain-cloudflare/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cloudflare/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/cloudflare", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-cloudflare/turbo.json b/libs/langchain-cloudflare/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-cloudflare/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-cohere/package.json b/libs/langchain-cohere/package.json index adbaa4fb3dae..220b7f2f635f 100644 --- a/libs/langchain-cohere/package.json +++ b/libs/langchain-cohere/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-cohere/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/cohere", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-cohere/turbo.json b/libs/langchain-cohere/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-cohere/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index d14f0d121700..1266350a9846 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-community/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", + "build": "yarn turbo:command build:internal --filter=@langchain/community", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking --gen-maps", "build:deps": "yarn run turbo:command build --filter=@langchain/core --filter=@langchain/openai --filter=langchain --filter=@langchain/anthropic --concurrency=1", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-community/turbo.json b/libs/langchain-community/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-community/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-exa/package.json b/libs/langchain-exa/package.json index 7fde9d1115c7..d4cc7a84c435 100644 --- a/libs/langchain-exa/package.json +++ b/libs/langchain-exa/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-exa/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/exa", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-exa/turbo.json b/libs/langchain-exa/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-exa/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-common/package.json b/libs/langchain-google-common/package.json index 10e1ab55475f..d8c2c1ae9d90 100644 --- a/libs/langchain-google-common/package.json +++ b/libs/langchain-google-common/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-common/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-common", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-common/turbo.json b/libs/langchain-google-common/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-common/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-gauth/package.json b/libs/langchain-google-gauth/package.json index d6dc06bb5746..6eda3cb5da18 100644 --- a/libs/langchain-google-gauth/package.json +++ b/libs/langchain-google-gauth/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-gauth/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-gauth", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-common", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-gauth/turbo.json b/libs/langchain-google-gauth/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-gauth/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-genai/package.json b/libs/langchain-google-genai/package.json index 366bec1eed03..d3443dbfbdfa 100644 --- a/libs/langchain-google-genai/package.json +++ b/libs/langchain-google-genai/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-genai/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-genai", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-genai/turbo.json b/libs/langchain-google-genai/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-genai/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-vertexai-web/package.json b/libs/langchain-google-vertexai-web/package.json index 2bf4f396a126..2f354049df79 100644 --- a/libs/langchain-google-vertexai-web/package.json +++ b/libs/langchain-google-vertexai-web/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai-web/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-vertexai-web", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-vertexai-web/turbo.json b/libs/langchain-google-vertexai-web/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-vertexai-web/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-vertexai/package.json b/libs/langchain-google-vertexai/package.json index f3942b41fbef..739d397557f3 100644 --- a/libs/langchain-google-vertexai/package.json +++ b/libs/langchain-google-vertexai/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-vertexai/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-vertexai", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-gauth", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-vertexai/turbo.json b/libs/langchain-google-vertexai/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-vertexai/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-google-webauth/package.json b/libs/langchain-google-webauth/package.json index 2ec3b6a404d2..48a16aeaa543 100644 --- a/libs/langchain-google-webauth/package.json +++ b/libs/langchain-google-webauth/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-webauth/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/google-webauth", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/google-common", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-google-webauth/turbo.json b/libs/langchain-google-webauth/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-google-webauth/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-groq/package.json b/libs/langchain-groq/package.json index 7ca6af256edb..9f045b499e42 100644 --- a/libs/langchain-groq/package.json +++ b/libs/langchain-groq/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-groq/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/groq", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-groq/turbo.json b/libs/langchain-groq/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-groq/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-mistralai/package.json b/libs/langchain-mistralai/package.json index 23339b523985..56e13455425c 100644 --- a/libs/langchain-mistralai/package.json +++ b/libs/langchain-mistralai/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mistralai/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/mistralai", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-mistralai/turbo.json b/libs/langchain-mistralai/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-mistralai/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-mongodb/package.json b/libs/langchain-mongodb/package.json index 0bfda33c34c6..209405737203 100644 --- a/libs/langchain-mongodb/package.json +++ b/libs/langchain-mongodb/package.json @@ -12,9 +12,10 @@ "type": "git", "url": "git@github.com:langchain-ai/langchainjs.git" }, - "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", + "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-mongodb/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/mongodb", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/openai", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-mongodb/turbo.json b/libs/langchain-mongodb/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-mongodb/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-nomic/package.json b/libs/langchain-nomic/package.json index a3fee1b59e52..2de4973cbc01 100644 --- a/libs/langchain-nomic/package.json +++ b/libs/langchain-nomic/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-nomic/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/nomic", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-nomic/turbo.json b/libs/langchain-nomic/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-nomic/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-openai/package.json b/libs/langchain-openai/package.json index 04521d512cc7..1230420f319b 100644 --- a/libs/langchain-openai/package.json +++ b/libs/langchain-openai/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-openai/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/openai", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs", diff --git a/libs/langchain-openai/turbo.json b/libs/langchain-openai/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-openai/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-pinecone/package.json b/libs/langchain-pinecone/package.json index 801b13eee356..38280b40d9d6 100644 --- a/libs/langchain-pinecone/package.json +++ b/libs/langchain-pinecone/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-pinecone/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/pinecone", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-pinecone/turbo.json b/libs/langchain-pinecone/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-pinecone/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-qdrant/package.json b/libs/langchain-qdrant/package.json index 2a7f941a7f10..10fc4c293599 100644 --- a/libs/langchain-qdrant/package.json +++ b/libs/langchain-qdrant/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-qdrant", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/qdrant", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-qdrant/turbo.json b/libs/langchain-qdrant/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-qdrant/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-redis/package.json b/libs/langchain-redis/package.json index 23ccfe0f6471..acc38b5ed9fc 100644 --- a/libs/langchain-redis/package.json +++ b/libs/langchain-redis/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-redis/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/redis", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-redis/turbo.json b/libs/langchain-redis/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-redis/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-scripts/package.json b/libs/langchain-scripts/package.json index 51fe97892ac1..a03989e91cf6 100644 --- a/libs/langchain-scripts/package.json +++ b/libs/langchain-scripts/package.json @@ -18,8 +18,10 @@ "lc-build:v2": "bin/build_v2.js" }, "scripts": { - "build": "rm -rf ./build_new && tsc --project ./tsconfig.build.json && yarn build:generated", + "build": "yarn turbo:command build:internal --filter=@langchain/scripts", + "build:internal": "rm -rf ./build_new && tsc --project ./tsconfig.build.json && yarn build:generated", "build:generated": "node bin/build_v2.js --create-entrypoints --pre --tree-shaking", + "build:turbo": "yarn turbo:command build --filter=@langchain/scripts", "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts", "lint": "yarn lint:eslint && yarn lint:dpdm", diff --git a/libs/langchain-scripts/turbo.json b/libs/langchain-scripts/turbo.json new file mode 100644 index 000000000000..93ef37be7cec --- /dev/null +++ b/libs/langchain-scripts/turbo.json @@ -0,0 +1,12 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "dependsOn": ["^build:internal"], + "outputs": ["**/dist/**"] + }, + "build:internal": { + "outputs": ["**/dist/**"] + } + } +} diff --git a/libs/langchain-textsplitters/package.json b/libs/langchain-textsplitters/package.json index bd62093d1899..2a07d0808078 100644 --- a/libs/langchain-textsplitters/package.json +++ b/libs/langchain-textsplitters/package.json @@ -12,9 +12,10 @@ "type": "git", "url": "git@github.com:langchain-ai/langchainjs.git" }, - "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-INTEGRATION_NAME/", + "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-textsplitters/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/textsplitters", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-textsplitters/turbo.json b/libs/langchain-textsplitters/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-textsplitters/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-weaviate/package.json b/libs/langchain-weaviate/package.json index 4b7a08d1685f..294eb1691d44 100644 --- a/libs/langchain-weaviate/package.json +++ b/libs/langchain-weaviate/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-weaviate/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/weaviate", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:deps": "yarn run turbo:command build --filter=@langchain/core", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", diff --git a/libs/langchain-weaviate/turbo.json b/libs/langchain-weaviate/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-weaviate/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/libs/langchain-yandex/package.json b/libs/langchain-yandex/package.json index 93ad34275cbb..8fa657ae97e5 100644 --- a/libs/langchain-yandex/package.json +++ b/libs/langchain-yandex/package.json @@ -14,7 +14,8 @@ }, "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-yandex/", "scripts": { - "build": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", + "build": "yarn turbo:command build:internal --filter=@langchain/yandex", + "build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking", "build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests", "build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs", "build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch", diff --git a/libs/langchain-yandex/turbo.json b/libs/langchain-yandex/turbo.json new file mode 100644 index 000000000000..d024cee15c81 --- /dev/null +++ b/libs/langchain-yandex/turbo.json @@ -0,0 +1,11 @@ +{ + "extends": ["//"], + "pipeline": { + "build": { + "outputs": ["**/dist/**"] + }, + "build:internal": { + "dependsOn": ["^build:internal"] + } + } +} diff --git a/package.json b/package.json index 46a7b1f02a49..6f2fd9aab079 100644 --- a/package.json +++ b/package.json @@ -18,22 +18,23 @@ }, "packageManager": "yarn@3.4.1", "scripts": { - "build": "turbo run build --filter=\"!test-exports-*\" --concurrency 1", + "build": "turbo build --filter=\"!test-exports-*\"", "turbo:command": "turbo", - "format": "turbo run format", - "format:check": "turbo run format:check", - "lint": "turbo run lint --concurrency 1", - "lint:fix": "turbo run lint:fix", - "test": "yarn test:unit && yarn workspace @langchain/core build && yarn workspace langchain build && yarn test:exports:docker", - "test:unit": "turbo run test", - "test:unit:ci": "turbo run test:ci", - "test:int": "yarn run test:int:deps && turbo run test:integration ; yarn run test:int:deps:down", + "clean": "turbo clean", + "format": "turbo format", + "format:check": "turbo format:check", + "lint": "turbo lint", + "lint:fix": "turbo lint:fix", + "test": "yarn test:unit && yarn test:exports:docker", + "test:unit": "turbo test --filter=\"!test-exports-*\" --filter=!examples --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration", + "test:unit:ci": "turbo test:ci", + "test:int": "yarn run test:int:deps && turbo test:integration ; yarn run test:int:deps:down", "test:int:deps": "docker compose -f test-int-deps-docker-compose.yml up -d", "test:int:deps:down": "docker compose -f test-int-deps-docker-compose.yml down", "test:ranges:docker": "docker compose -f dependency_range_tests/docker-compose.yml up --force-recreate", "test:exports:docker": "docker compose -f environment_tests/docker-compose.yml up --force-recreate", "example": "yarn workspace examples start", - "precommit": "turbo run precommit", + "precommit": "turbo precommit", "docs": "yarn workspace core_docs start", "docs:api_refs": "yarn workspace api_refs start", "release": "node release_workspace.js --workspace" @@ -49,11 +50,9 @@ "lint-staged": "^13.1.1", "prettier": "^2.8.3", "semver": "^7.5.4", + "turbo": "^1.13.3", "typescript": "~5.1.6" }, - "dependencies": { - "turbo": "latest" - }, "resolutions": { "dpdm@^3.12.0": "patch:dpdm@npm%3A3.12.0#./.yarn/patches/dpdm-npm-3.12.0-0dfdd8e3b8.patch", "typedoc-plugin-markdown@next": "patch:typedoc-plugin-markdown@npm%3A4.0.0-next.6#./.yarn/patches/typedoc-plugin-markdown-npm-4.0.0-next.6-96b4b47746.patch", diff --git a/turbo.json b/turbo.json index f74259d1e70c..7fdc5c4944fa 100644 --- a/turbo.json +++ b/turbo.json @@ -2,95 +2,36 @@ "$schema": "https://turbo.build/schema.json", "globalDependencies": ["**/.env"], "pipeline": { - "@langchain/scripts#build": { - "outputs": [ - "dist/**", - "*.js", - "*.cjs", - "*.d.ts" - ], - "inputs": [ - "src/*", - "src/**/*", - "scripts/*", - "package.json", - "tsconfig.json", - "bin/*" - ] - }, - "@langchain/core#build": { - "dependsOn": ["@langchain/scripts#build"], - "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], - "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] - }, - "@langchain/anthropic#build": { - "dependsOn": ["@langchain/core#build"], - "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], - "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] - }, - "@langchain/openai#build": { - "dependsOn": ["@langchain/core#build"], - "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], - "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] - }, - "@langchain/community#build": { - "dependsOn": ["@langchain/openai#build", "langchain#build", "@langchain/anthropic#build"], - "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], - "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] - }, "build": { - "dependsOn": [ - "@langchain/scripts#build", - "@langchain/core#build", - "^build" - ], - "outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"], - "inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"] + "dependsOn": ["^build"], + "outputs": ["dist/**", ".next/**", "!.next/cache/**"] }, "lint": { - "outputs": [] + "dependsOn": ["^lint"] }, "lint:fix": { - "outputs": [ - "langchain/src/**/*.ts", - "langchain-core/src/**/*.ts", - "libs/**/src/**/*.ts", - "docs/core_docs/**/*.js", - "examples/src/**/*.ts", - "**/*.eslintcache" - ], - "inputs": [ - "langchain/src/**/*.ts", - "langchain-core/src/**/*.ts", - "libs/**/src/**/*.ts", - "docs/core_docs/**/*.js", - "examples/src/**/*.ts" - ] + "dependsOn": ["^lint:fix"] }, "format": { - "outputs": [] + "dependsOn": ["^format"] }, "format:check": { - "outputs": [] + "dependsOn": ["^format:check"] }, "test": { - "outputs": [], - "dependsOn": ["^build"] + "dependsOn": ["^build", "build"] }, - "test:ci": { - "outputs": [], - "dependsOn": ["test"] + "test:single": { + "dependsOn": ["^build", "build"] }, "test:integration": { - "outputs": [], - "dependsOn": ["^build"] + "dependsOn": ["^build", "build"] }, - "precommit": {}, - "start": { - "cache": false + "clean": { + "dependsOn": ["^clean"] }, - "build:vercel": { - "dependsOn": ["^build:vercel"] + "build:internal": { + "dependsOn": ["^build:internal"] } } } diff --git a/yarn.lock b/yarn.lock index 6afc6fd2b289..5795ad6cbfd0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9573,7 +9573,6 @@ __metadata: prettier: ^2.8.3 release-it: ^15.10.1 rimraf: ^5.0.1 - turbo: latest typescript: ~5.1.6 uuid: ^9.0.0 web-streams-polyfill: ^3.3.3 @@ -27598,7 +27597,7 @@ __metadata: lint-staged: ^13.1.1 prettier: ^2.8.3 semver: ^7.5.4 - turbo: latest + turbo: ^1.13.3 typescript: ~5.1.6 languageName: unknown linkType: soft @@ -35589,58 +35588,58 @@ __metadata: languageName: node linkType: hard -"turbo-darwin-64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-darwin-64@npm:1.9.2" +"turbo-darwin-64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-darwin-64@npm:1.13.3" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"turbo-darwin-arm64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-darwin-arm64@npm:1.9.2" +"turbo-darwin-arm64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-darwin-arm64@npm:1.13.3" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"turbo-linux-64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-linux-64@npm:1.9.2" +"turbo-linux-64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-linux-64@npm:1.13.3" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"turbo-linux-arm64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-linux-arm64@npm:1.9.2" +"turbo-linux-arm64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-linux-arm64@npm:1.13.3" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"turbo-windows-64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-windows-64@npm:1.9.2" +"turbo-windows-64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-windows-64@npm:1.13.3" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"turbo-windows-arm64@npm:1.9.2": - version: 1.9.2 - resolution: "turbo-windows-arm64@npm:1.9.2" +"turbo-windows-arm64@npm:1.13.3": + version: 1.13.3 + resolution: "turbo-windows-arm64@npm:1.13.3" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"turbo@npm:latest": - version: 1.9.2 - resolution: "turbo@npm:1.9.2" - dependencies: - turbo-darwin-64: 1.9.2 - turbo-darwin-arm64: 1.9.2 - turbo-linux-64: 1.9.2 - turbo-linux-arm64: 1.9.2 - turbo-windows-64: 1.9.2 - turbo-windows-arm64: 1.9.2 +"turbo@npm:^1.13.3": + version: 1.13.3 + resolution: "turbo@npm:1.13.3" + dependencies: + turbo-darwin-64: 1.13.3 + turbo-darwin-arm64: 1.13.3 + turbo-linux-64: 1.13.3 + turbo-linux-arm64: 1.13.3 + turbo-windows-64: 1.13.3 + turbo-windows-arm64: 1.13.3 dependenciesMeta: turbo-darwin-64: optional: true @@ -35656,7 +35655,7 @@ __metadata: optional: true bin: turbo: bin/turbo - checksum: ac74531c9a249bc9e06cae42d76fabed7d2bbd168b9c7a65f657f0f902ef83d0fe93977a1b42973714f05a019ad496a6e1c41237c2c2ff57c8257b6d6ab8dd13 + checksum: d00655987e5d2e714d5e5a8d5950624508fb69e8671ca17e8ac7b9316ce01e518308ec4eaa472306950782704caa2eaa3c4fb328192818fcd9fcc05423bc29e7 languageName: node linkType: hard From 2d308938dbd5f28c9ee8696da63814a7f1ae86ed Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 15:20:00 -0700 Subject: [PATCH 09/10] add back test:ci --- turbo.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/turbo.json b/turbo.json index 7fdc5c4944fa..0f82b8628676 100644 --- a/turbo.json +++ b/turbo.json @@ -19,8 +19,13 @@ "dependsOn": ["^format:check"] }, "test": { + "cache": false, "dependsOn": ["^build", "build"] }, + "test:ci": { + "outputs": [], + "dependsOn": ["test"] + }, "test:single": { "dependsOn": ["^build", "build"] }, From f4d4cba5ccbca57516dd8e642a40348aba99f722 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Fri, 24 May 2024 15:39:01 -0700 Subject: [PATCH 10/10] remove concurrency limits in tests & ignore non testable packages --- .github/workflows/unit-tests-langchain-community.yml | 7 +------ .github/workflows/unit-tests-langchain-core.yml | 7 +------ .github/workflows/unit-tests-langchain-integrations.yml | 7 +------ .github/workflows/unit-tests-langchain.yml | 7 +------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/.github/workflows/unit-tests-langchain-community.yml b/.github/workflows/unit-tests-langchain-community.yml index 009579afc3e8..09482539266a 100644 --- a/.github/workflows/unit-tests-langchain-community.yml +++ b/.github/workflows/unit-tests-langchain-community.yml @@ -53,9 +53,4 @@ jobs: - name: Build run: yarn run build --filter=@langchain/community - name: Test - run: yarn run test:unit:ci --filter=@langchain/community --concurrency=1 - # run: yarn run test:unit:ci -- --coverage - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: yarn run test:unit:ci --filter=@langchain/community diff --git a/.github/workflows/unit-tests-langchain-core.yml b/.github/workflows/unit-tests-langchain-core.yml index 74474c401983..22f2f0a56feb 100644 --- a/.github/workflows/unit-tests-langchain-core.yml +++ b/.github/workflows/unit-tests-langchain-core.yml @@ -52,9 +52,4 @@ jobs: - name: Build run: yarn run build --filter=@langchain/core - name: Test - run: yarn run test:unit:ci --filter=@langchain/core --concurrency=1 - # run: yarn run test:unit:ci -- --coverage - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: yarn run test:unit:ci --filter=@langchain/core diff --git a/.github/workflows/unit-tests-langchain-integrations.yml b/.github/workflows/unit-tests-langchain-integrations.yml index 774338b840d4..50fb479fdbd8 100644 --- a/.github/workflows/unit-tests-langchain-integrations.yml +++ b/.github/workflows/unit-tests-langchain-integrations.yml @@ -54,9 +54,4 @@ jobs: - name: Build run: yarn run build --filter=!@langchain/community --filter=!@langchain/core --filter=!langchain --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration --filter=!examples - name: Test - run: yarn run test:unit:ci --filter=!@langchain/community --filter=!@langchain/core --filter=!langchain --concurrency=1 - # run: yarn run test:unit:ci -- --coverage - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: yarn run test:unit:ci --filter=!@langchain/community --filter=!@langchain/core --filter=!langchain --filter=!api_refs --filter=!core_docs --filter=!create-langchain-integration --filter=!examples diff --git a/.github/workflows/unit-tests-langchain.yml b/.github/workflows/unit-tests-langchain.yml index 829ee8c09133..eb2c217067fe 100644 --- a/.github/workflows/unit-tests-langchain.yml +++ b/.github/workflows/unit-tests-langchain.yml @@ -53,11 +53,6 @@ jobs: - name: Build run: yarn run build --filter=langchain - name: Test - run: yarn run test:unit:ci --filter=langchain --concurrency=1 + run: yarn run test:unit:ci --filter=langchain env: COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }} - # run: yarn run test:unit:ci -- --coverage - # - name: Upload coverage reports to Codecov - # uses: codecov/codecov-action@v3 - # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}