Skip to content

Commit ac78f21

Browse files
authored
feat: upgrade to unenv v2 (#3072)
1 parent 0f7c3ea commit ac78f21

14 files changed

Lines changed: 56 additions & 45 deletions

File tree

docs/3.config/0.index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ If enabled, will analyze server bundle after build using [rollup-plugin-visualiz
547547

548548
### `moduleSideEffects`
549549

550-
Default: `['unenv/runtime/polyfill/', 'node-fetch-native/polyfill']`
550+
Default: `['unenv/polyfill/', 'node-fetch-native/polyfill']`
551551

552552
Rollup specific option. Specifies module imports that have side-effects
553553

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default unjs({
55
"**/.output",
66
"**/.nitro",
77
"**/.netlify",
8+
"**/.vercel",
89
"**/.nuxt",
910
"**/*.gen.*",
1011
"**/dist",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"fs-extra": "^11.3.0",
130130
"globby": "^14.0.2",
131131
"gzip-size": "^7.0.0",
132-
"h3": "^1.14.0",
132+
"h3": "^1.15.0",
133133
"hookable": "^5.5.3",
134134
"httpxy": "^0.1.7",
135135
"ioredis": "^5.4.2",
@@ -163,7 +163,7 @@
163163
"ultrahtml": "^1.5.3",
164164
"uncrypto": "^0.1.3",
165165
"unctx": "^2.4.1",
166-
"unenv": "^1.10.0",
166+
"unenv": "2.0.0-rc.2",
167167
"unimport": "^4.0.0",
168168
"unstorage": "^1.14.4",
169169
"untyped": "^1.5.2",

pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtime-meta.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const runtimeDependencies = [
1515
"iron-webcrypto",
1616
"klona",
1717
"node-fetch-native",
18+
"node-mock-http",
1819
"ofetch",
1920
"ohash",
2021
"pathe",

src/core/config/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const NitroDefaults: NitroConfig = {
7676
unenv: {},
7777
analyze: false,
7878
moduleSideEffects: [
79-
"unenv/runtime/polyfill/",
79+
"unenv/polyfill/",
8080
"node-fetch-native/polyfill",
8181
"node-fetch-native/dist/polyfill",
8282
resolve(runtimeDir, "polyfill/"),

src/core/config/resolvers/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function resolveFetchOptions(options: NitroOptions) {
1313
}
1414
if (!options.experimental.nodeFetchCompat) {
1515
options.alias = {
16-
"node-fetch-native/polyfill": "unenv/runtime/mock/empty",
16+
"node-fetch-native/polyfill": "unenv/mock/empty",
1717
"node-fetch-native": "node-fetch-native/native",
1818
...options.alias,
1919
};

src/presets/cloudflare/unenv/preset.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export const unenvCfPreset: Preset = {
5757
),
5858
sys: resolvePresetRuntime("util"),
5959
"node:sys": resolvePresetRuntime("util"),
60+
"node-mock-http/_polyfill/events": "node:events",
61+
"node-mock-http/_polyfill/buffer": "node:buffer",
6062
},
6163
inject: {
6264
"globalThis.Buffer": ["node:buffer", "Buffer"],

src/presets/cloudflare/unenv/runtime/async_hooks.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
import workerdAsyncHooks from "#workerd/node:async_hooks";
44

55
import {
6-
// asyncWrapProviders,
6+
asyncWrapProviders,
77
createHook,
88
executionAsyncId,
99
executionAsyncResource,
1010
triggerAsyncId,
11-
} from "unenv/runtime/node/async_hooks/index";
11+
} from "unenv/node/async_hooks";
1212

1313
export {
14-
// asyncWrapProviders,
14+
asyncWrapProviders,
1515
createHook,
1616
executionAsyncId,
1717
executionAsyncResource,
1818
triggerAsyncId,
19-
} from "unenv/runtime/node/async_hooks/index";
19+
} from "unenv/node/async_hooks";
2020

2121
export const { AsyncLocalStorage, AsyncResource } = workerdAsyncHooks;
2222

2323
export default {
24+
asyncWrapProviders,
2425
createHook,
2526
executionAsyncId,
2627
executionAsyncResource,

src/presets/cloudflare/unenv/runtime/crypto.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
diffieHellman,
1919
ECDH,
2020
getCipherInfo,
21-
// hash,
21+
hash,
2222
privateDecrypt,
2323
privateEncrypt,
2424
pseudoRandomBytes,
@@ -29,7 +29,7 @@ import {
2929
webcrypto as unenvCryptoWebcrypto,
3030
Verify,
3131
verify,
32-
} from "unenv/runtime/node/crypto/index";
32+
} from "unenv/node/crypto";
3333

3434
export {
3535
Cipher,
@@ -47,14 +47,14 @@ export {
4747
createVerify,
4848
diffieHellman,
4949
getCipherInfo,
50-
// hash,
50+
hash,
5151
privateDecrypt,
5252
privateEncrypt,
5353
publicDecrypt,
5454
publicEncrypt,
5555
sign,
5656
verify,
57-
} from "unenv/runtime/node/crypto/index";
57+
} from "unenv/node/crypto";
5858

5959
export const {
6060
Certificate,
@@ -133,7 +133,7 @@ export default {
133133
createVerify,
134134
diffieHellman,
135135
getCipherInfo,
136-
// hash,
136+
hash,
137137
privateDecrypt,
138138
privateEncrypt,
139139
publicDecrypt,

0 commit comments

Comments
 (0)