Skip to content

Commit

Permalink
fix: fix module not found errors in Vercel edge (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored and rattrayalex committed Sep 12, 2023
1 parent 80948cb commit 2ecc0de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
32 changes: 7 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"license": "MIT",
"private": false,
"exports": {
"./_shims/*.mjs": {
"./_shims/*": {
"deno": {
"types": "./dist/_shims/*.d.ts",
"require": "./dist/_shims/*.js",
"default": "./dist/_shims/*.mjs"
},
"bun": {
Expand All @@ -22,47 +23,28 @@
},
"browser": {
"types": "./dist/_shims/*.d.ts",
"require": "./dist/_shims/*.js",
"default": "./dist/_shims/*.mjs"
},
"worker": {
"types": "./dist/_shims/*.d.ts",
"require": "./dist/_shims/*.js",
"default": "./dist/_shims/*.mjs"
},
"workerd": {
"types": "./dist/_shims/*.d.ts",
"require": "./dist/_shims/*.js",
"default": "./dist/_shims/*.mjs"
},
"node": {
"types": "./dist/_shims/*-node.d.ts",
"require": "./dist/_shims/*-node.js",
"default": "./dist/_shims/*-node.mjs"
},
"types": "./dist/_shims/*.d.ts",
"require": "./dist/_shims/*.js",
"default": "./dist/_shims/*.mjs"
},
"./_shims/*.js": {
"deno": {
"types": "./dist/_shims/*.d.ts",
"default": "./dist/_shims/*.js"
},
"browser": {
"types": "./dist/_shims/*.d.ts",
"default": "./dist/_shims/*.js"
},
"worker": {
"types": "./dist/_shims/*.d.ts",
"default": "./dist/_shims/*.js"
},
"workerd": {
"types": "./dist/_shims/*.d.ts",
"default": "./dist/_shims/*.js"
},
"node": {
"types": "./dist/_shims/*-node.d.ts",
"default": "./dist/_shims/*-node.js"
},
"types": "./dist/_shims/*.d.ts",
"default": "./dist/_shims/*.js"
},
".": {
"require": {
"types": "./dist/index.d.ts",
Expand Down
6 changes: 1 addition & 5 deletions scripts/replace-self-referencing-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ function replaceSelfReferencingImports({ orig, file, config }) {

return orig.replace(/['"]([^"'\r\n]+)['"]/, (match, importPath) => {
if (!importPath.startsWith('@anthropic-ai/sdk/')) return match;
if (!file.startsWith(distSrcDir)) {
const ext = file.endsWith('.d.ts') ? '' : path.extname(file);
const { dir, base } = path.parse(importPath);
return JSON.stringify(`${dir}/${base}${ext}`);
}
if (!file.startsWith(distSrcDir)) return match;
let relativePath = path.relative(
path.dirname(file),
path.join(distSrcDir, importPath.substring('@anthropic-ai/sdk/'.length)),
Expand Down

0 comments on commit 2ecc0de

Please sign in to comment.