@ai-sdk/provider-utils 4.0.42 → 4.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/safe-node-fetch.ts +11 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.44",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@standard-schema/spec": "^1.1.0",
|
|
37
37
|
"eventsource-parser": "^3.0.8",
|
|
38
38
|
"undici": "^5.29.0",
|
|
39
|
-
"@ai-sdk/provider": "3.0.
|
|
39
|
+
"@ai-sdk/provider": "3.0.15"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.17.24",
|
package/src/safe-node-fetch.ts
CHANGED
|
@@ -140,8 +140,8 @@ function isNodeDefaultFetch(fetch: FetchFunction): boolean {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
async function createSafeNodeFetch(): Promise<FetchFunction> {
|
|
143
|
-
// Node
|
|
144
|
-
//
|
|
143
|
+
// Load Node-only modules indirectly so browser bundlers do not pull undici
|
|
144
|
+
// and Node built-ins into the browser-facing provider-utils entry point.
|
|
145
145
|
const [{ createRequire }, { lookup }] = await Promise.all([
|
|
146
146
|
loadNodeModule<NodeModule>('node:module'),
|
|
147
147
|
loadNodeModule<NodeDns>('node:dns'),
|
|
@@ -174,23 +174,16 @@ async function loadNodeModule<T>(id: string): Promise<T> {
|
|
|
174
174
|
| undefined;
|
|
175
175
|
const builtinModule = processWithBuiltins?.getBuiltinModule?.(id);
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
// Metro rejects non-static dynamic imports while parsing, even though this
|
|
186
|
-
// Node-only fallback is never executed in React Native. Construct the import
|
|
187
|
-
// function lazily so the distributed module contains no import expression for
|
|
188
|
-
// Metro to analyze and runtimes with process.getBuiltinModule avoid it.
|
|
189
|
-
dynamicImport ??= Function('specifier', 'return import(specifier)') as (
|
|
190
|
-
specifier: string,
|
|
191
|
-
) => Promise<unknown>;
|
|
177
|
+
if (builtinModule == null) {
|
|
178
|
+
// There is no bundle-safe way to load Node built-ins without
|
|
179
|
+
// process.getBuiltinModule (Node <20.16): Metro rejects non-static
|
|
180
|
+
// import() expressions while parsing, and Next.js Edge Runtime rejects
|
|
181
|
+
// the Function-constructor shim during static analysis. Throw rather
|
|
182
|
+
// than ship either, matching the v7 implementation. See #18545, #18559.
|
|
183
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
184
|
+
}
|
|
192
185
|
|
|
193
|
-
return
|
|
186
|
+
return builtinModule as T;
|
|
194
187
|
}
|
|
195
188
|
|
|
196
189
|
function getCurrentModulePath(): string {
|