From c24e1f80d43ec5042e6ec137f996b3b8e4f40c6a Mon Sep 17 00:00:00 2001 From: pooya parsa Date: Fri, 16 Jun 2023 11:40:07 +0200 Subject: [PATCH] fix(bun): resolve internal dependencies with `bun` export condition (#1313) * chore: increase timeout * resolve with `bun` condition --- package.json | 1 + pnpm-lock.yaml | 51 ++++++++++++++++++++++++---------------------- src/presets/bun.ts | 9 ++++++++ test/tests.ts | 2 +- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 5f7688ba88..952c3731d1 100644 --- a/package.json +++ b/package.json @@ -109,6 +109,7 @@ "source-map-support": "^0.5.21", "std-env": "^3.3.3", "ufo": "^1.1.2", + "uncrypto": "^0.1.3", "unenv": "^1.5.1", "unimport": "^3.0.8", "unstorage": "^1.6.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aa5b2c2249..5f62fe9578 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -185,6 +185,9 @@ importers: ufo: specifier: ^1.1.2 version: 1.1.2 + uncrypto: + specifier: ^0.1.3 + version: 0.1.3 unenv: specifier: ^1.5.1 version: 1.5.1 @@ -371,7 +374,7 @@ packages: '@babel/compat-data': 7.22.5 '@babel/core': 7.22.5 '@babel/helper-validator-option': 7.22.5 - browserslist: 4.21.8 + browserslist: 4.21.9 lru-cache: 5.1.1 semver: 6.3.0 dev: true @@ -1443,7 +1446,7 @@ packages: dependencies: '@mapbox/node-pre-gyp': 1.0.10 '@rollup/pluginutils': 4.2.1 - acorn: 8.8.2 + acorn: 8.9.0 async-sema: 3.1.1 bindings: 1.5.0 estree-walker: 2.0.2 @@ -1521,12 +1524,12 @@ packages: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} dev: false - /acorn-jsx@5.3.2(acorn@8.8.2): + /acorn-jsx@5.3.2(acorn@8.9.0): resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - acorn: 8.8.2 + acorn: 8.9.0 dev: true /acorn-walk@8.2.0: @@ -1534,8 +1537,8 @@ packages: engines: {node: '>=0.4.0'} dev: true - /acorn@8.8.2: - resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} + /acorn@8.9.0: + resolution: {integrity: sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==} engines: {node: '>=0.4.0'} hasBin: true @@ -1765,15 +1768,15 @@ packages: dependencies: fill-range: 7.0.1 - /browserslist@4.21.8: - resolution: {integrity: sha512-j+7xYe+v+q2Id9qbBeCI8WX5NmZSRe8es1+0xntD/+gaWXznP8tFEkv5IgSaHf5dS1YwVMbX/4W6m937mj+wQw==} + /browserslist@4.21.9: + resolution: {integrity: sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: caniuse-lite: 1.0.30001503 - electron-to-chromium: 1.4.430 + electron-to-chromium: 1.4.432 node-releases: 2.0.12 - update-browserslist-db: 1.0.11(browserslist@4.21.8) + update-browserslist-db: 1.0.11(browserslist@4.21.9) dev: true /buffer-crc32@0.2.13: @@ -1818,7 +1821,7 @@ packages: dependencies: chokidar: 3.5.3 defu: 6.1.2 - dotenv: 16.1.4 + dotenv: 16.2.0 giget: 1.1.2 jiti: 1.18.2 mlly: 1.3.0 @@ -2257,8 +2260,8 @@ packages: engines: {node: '>=10'} dev: true - /dotenv@16.1.4: - resolution: {integrity: sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==} + /dotenv@16.2.0: + resolution: {integrity: sha512-jcq2vR1DY1+QA+vH58RIrWLDZOifTGmyQJWzP9arDUbgZcySdzuBb1WvhWZzZtiXgfm+GW2pjBqStqlfpzq7wQ==} engines: {node: '>=12'} /duplexer@0.1.2: @@ -2285,8 +2288,8 @@ packages: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} dev: false - /electron-to-chromium@1.4.430: - resolution: {integrity: sha512-FytjTbGwz///F+ToZ5XSeXbbSaXalsVRXsz2mHityI5gfxft7ieW3HqFLkU5V1aIrY42aflICqbmFoDxW10etg==} + /electron-to-chromium@1.4.432: + resolution: {integrity: sha512-yz3U/khQgAFT2HURJA3/F4fKIyO2r5eK09BQzBZFd6BvBSSaRuzKc2ZNBHtJcO75/EKiRYbVYJZ2RB0P4BuD2g==} dev: true /emoji-regex@8.0.0: @@ -2752,8 +2755,8 @@ packages: resolution: {integrity: sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: - acorn: 8.8.2 - acorn-jsx: 5.3.2(acorn@8.8.2) + acorn: 8.9.0 + acorn-jsx: 5.3.2(acorn@8.9.0) eslint-visitor-keys: 3.4.1 dev: true @@ -3979,7 +3982,7 @@ packages: /mlly@1.3.0: resolution: {integrity: sha512-HT5mcgIQKkOrZecOjOX3DJorTikWXwsBfpcr/MGBkhfWcjiqvnaL/9ppxvIUXfjT6xt4DVIAsN9fMUz1ev4bIw==} dependencies: - acorn: 8.8.2 + acorn: 8.9.0 pathe: 1.1.1 pkg-types: 1.0.3 ufo: 1.1.2 @@ -4902,7 +4905,7 @@ packages: /strip-literal@1.0.1: resolution: {integrity: sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==} dependencies: - acorn: 8.8.2 + acorn: 8.9.0 /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -4968,7 +4971,7 @@ packages: hasBin: true dependencies: '@jridgewell/source-map': 0.3.3 - acorn: 8.8.2 + acorn: 8.9.0 commander: 2.20.3 source-map-support: 0.5.21 dev: false @@ -5201,7 +5204,7 @@ packages: /unplugin@1.3.1: resolution: {integrity: sha512-h4uUTIvFBQRxUKS2Wjys6ivoeofGhxzTe2sRWlooyjHXVttcVfV/JiavNd3d4+jty0SVV0dxGw9AkY9MwiaCEw==} dependencies: - acorn: 8.8.2 + acorn: 8.9.0 chokidar: 3.5.3 webpack-sources: 3.2.3 webpack-virtual-modules: 0.5.0 @@ -5274,13 +5277,13 @@ packages: - supports-color dev: true - /update-browserslist-db@1.0.11(browserslist@4.21.8): + /update-browserslist-db@1.0.11(browserslist@4.21.9): resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' dependencies: - browserslist: 4.21.8 + browserslist: 4.21.9 escalade: 3.1.1 picocolors: 1.0.0 dev: true @@ -5415,7 +5418,7 @@ packages: '@vitest/snapshot': 0.32.0 '@vitest/spy': 0.32.0 '@vitest/utils': 0.32.0 - acorn: 8.8.2 + acorn: 8.9.0 acorn-walk: 8.2.0 cac: 6.7.14 chai: 4.3.7 diff --git a/src/presets/bun.ts b/src/presets/bun.ts index e9b21c073b..ef4c982ace 100644 --- a/src/presets/bun.ts +++ b/src/presets/bun.ts @@ -1,8 +1,17 @@ +import { resolvePathSync } from "mlly"; import { defineNitroPreset } from "../preset"; export const bun = defineNitroPreset({ extends: "node-server", entry: "#internal/nitro/entries/bun", + externals: { + traceInclude: ["ofetch", "uncrypto", "node-fetch-native"].map((id) => + resolvePathSync(id, { + url: import.meta.url, + conditions: ["bun"], + }) + ), + }, commands: { preview: "bun run ./server/index.mjs", }, diff --git a/test/tests.ts b/test/tests.ts index fb11d7156f..0183e10386 100644 --- a/test/tests.ts +++ b/test/tests.ts @@ -131,7 +131,7 @@ export function testNitro( beforeAll(async () => { _handler = await getHandler(); - }); + }, 5000); it("API Works", async () => { const { data: helloData } = await callHandler({ url: "/api/hello" });