diff --git a/package.json b/package.json index 07d0f51..8ef31bb 100644 --- a/package.json +++ b/package.json @@ -44,13 +44,15 @@ }, "type": "module", "dependencies": { - "@langchain/anthropic": "^0.3.25", - "@langchain/community": "^0.3.49", - "@langchain/google-genai": "^0.2.16", - "@langchain/mistralai": "^0.2.1", - "@langchain/ollama": "^0.2.3", - "@langchain/openai": "^0.6.3", - "langchain": "^0.3.30", + "@langchain/anthropic": "^1.0.0", + "@langchain/classic": "^1.0.0", + "@langchain/community": "^1.0.0", + "@langchain/core": "^1.0.1", + "@langchain/google-genai": "^1.0.0", + "@langchain/mistralai": "^1.0.0", + "@langchain/ollama": "^1.0.0", + "@langchain/openai": "^1.0.0", + "langchain": "^1.0.1", "uuid": "^13.0.0" }, "peerDependencies": { diff --git a/src/docFillerCore/engines/gptEngine.ts b/src/docFillerCore/engines/gptEngine.ts index 6317931..e38d7ef 100644 --- a/src/docFillerCore/engines/gptEngine.ts +++ b/src/docFillerCore/engines/gptEngine.ts @@ -1,4 +1,5 @@ import { ChatAnthropic } from '@langchain/anthropic'; +import { DatetimeOutputParser } from '@langchain/classic/output_parsers'; import { ChromeAI } from '@langchain/community/experimental/llms/chrome_ai'; import { StringOutputParser, @@ -24,7 +25,6 @@ import { getSelectedProfileKey, loadProfiles, } from '@utils/storage/profiles/profileManager'; -import { DatetimeOutputParser } from 'langchain/output_parsers'; import { z } from 'zod'; import browser from 'webextension-polyfill'; diff --git a/tools/builder.ts b/tools/builder.ts index 9da8bfe..b32b647 100644 --- a/tools/builder.ts +++ b/tools/builder.ts @@ -4,6 +4,28 @@ import copyContents from './copier'; import entryPoints from './entrypoints'; import { writeManifest } from './manifestWriter'; +// Plugin to stub Node.js built-in modules for browser builds +const nodeBuiltinsPlugin: esbuild.Plugin = { + name: 'node-builtins', + setup(build) { + // Stub out node:* imports + build.onResolve({ filter: /^node:/ }, (args) => { + return { + path: args.path, + namespace: 'node-builtins-stub', + }; + }); + + build.onLoad({ filter: /.*/, namespace: 'node-builtins-stub' }, () => { + return { + contents: + 'export default {}; export const createRequire = () => () => {};', + loader: 'js', + }; + }); + }, +}; + const cleanBuildFolder = async () => { try { await fs.remove('./build'); @@ -25,6 +47,8 @@ const build = async (watch: boolean) => { bundle: true, // minify: true, outdir: './build/src', + platform: 'browser', + plugins: [nodeBuiltinsPlugin], }); await buildContext.watch(); } else { @@ -33,6 +57,8 @@ const build = async (watch: boolean) => { bundle: true, // minify: true, outdir: './build/src', + platform: 'browser', + plugins: [nodeBuiltinsPlugin], }); if (buildStatus.errors.length > 0) {