-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Bun Adapter #5129
Merged
Merged
feat: Bun Adapter #5129
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
19f3246
Bun Adapter
EamonHeffernan 646a268
Bun types
EamonHeffernan bc43441
Update docs
EamonHeffernan 69591c4
Improved installation instructions for bun
EamonHeffernan 139a027
cli cleanup
zanettin 1102f4f
Merge branch 'main' into bun-adapter
zanettin f0ab3c5
✨
zanettin eb82650
Match the changes in the other pr
EamonHeffernan 54cf790
Update index.mdx
EamonHeffernan 44a4c84
Update index.mdx
EamonHeffernan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare const Bun: { | ||
fileURLToPath: (url: string) => string; | ||
env: any; | ||
file: (path: string) => { | ||
text: () => Promise<string>; | ||
stream: () => Promise<ReadableStream<Uint8Array>>; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/docs/src/routes/api/qwik-city-vite-bun-server/api.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"id": "qwik-city-vite-bun-server", | ||
"package": "@builder.io/qwik-city/vite/bun-server", | ||
"members": [] | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/docs/src/routes/api/qwik-city-vite-bun-server/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
title: \@builder.io/qwik-city/vite/bun-server API Reference | ||
--- | ||
|
||
# [API](/api) › @builder.io/qwik-city/vite/bun-server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: Bun Middleware | Deployments | ||
contributors: | ||
- EamonHeffernan | ||
--- | ||
|
||
# Bun Middleware | ||
|
||
Qwik City Bun middleware allows you to hook up Qwik City to a Bun server which uses the Bun Http API. | ||
|
||
## Installation | ||
|
||
To install `bun` on Linux, OSX or WSL run the following command in your terminal | ||
|
||
```shell | ||
curl -fsSL https://bun.sh/install | bash | ||
``` | ||
|
||
For other platforms or if you run into issues with installation, up to date `bun` installation instructions can be found [on the bun website](https://bun.sh/docs/installation). | ||
|
||
There currently is an issue with using `bun` as the package manager. | ||
If you see the error `Something went wrong installing the "sharp" module` when using `bun` add the following code to your package.json, then remove the node_modules folder and any lockfiles such as bun.lockb or package-lock.json. You may then run `bun install`. | ||
|
||
```json | ||
"trustedDependencies": [ | ||
"sharp" | ||
] | ||
``` | ||
This issue is currently being tracked [on the bun repository](https://github.com/oven-sh/bun/issues/3783). | ||
|
||
To integrate the `bun` adapter, use the `add` command: | ||
|
||
- For the [integrated HTTP server](https://bun.sh/docs/api/http): | ||
|
||
```shell | ||
bun run qwik add bun | ||
``` | ||
|
||
## Production build | ||
|
||
To build the application for production, use the `build` command, this command will automatically run `bun run build.server` and `bun run build.client`: | ||
|
||
```shell | ||
bun run build | ||
``` | ||
|
||
## Serve | ||
|
||
To start the Bun server after a build: | ||
|
||
```shell | ||
bun run serve | ||
``` | ||
|
||
## Production deploy | ||
|
||
Since you are choosing Bun, here you are in your own, after running `bun run build`: | ||
|
||
- The `dist` folder will be created including all the static files. | ||
- The `server` folder will be created including all bun server files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## API Report File for "@builder.io/qwik-city" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
||
```ts | ||
|
||
import { ServerAdapterOptions } from '../../shared/vite'; | ||
import type { StaticGenerateRenderOptions } from '@builder.io/qwik-city/static'; | ||
|
||
// @alpha (undocumented) | ||
export function bunServerAdapter(opts?: bunServerAdapterOptions): any; | ||
|
||
// @alpha (undocumented) | ||
export interface bunServerAdapterOptions extends ServerAdapterOptions { | ||
// (undocumented) | ||
name?: string; | ||
} | ||
|
||
export { StaticGenerateRenderOptions } | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
19 changes: 19 additions & 0 deletions
19
packages/qwik-city/adapters/bun-server/vite/api-extractor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "../../../api-extractor.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist-dev/dts-out/packages/qwik-city/adapters/bun-server/vite/index.d.ts", | ||
"apiReport": { | ||
"enabled": true, | ||
"reportFileName": "api.md", | ||
"reportFolder": "<projectFolder>/packages/qwik-city/adapters/bun-server/", | ||
"reportTempFolder": "<projectFolder>/dist-dev/api-extractor/qwik-city/adapters/bun-server" | ||
}, | ||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "<projectFolder>/packages/qwik-city/lib/adapters/bun-server/vite/index.d.ts" | ||
}, | ||
"docModel": { | ||
"enabled": true, | ||
"apiJsonFilePath": "<projectFolder>/dist-dev/api/qwik-city/vite/bun-server/docs.api.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { StaticGenerateRenderOptions } from '@builder.io/qwik-city/static'; | ||
import { viteAdapter, type ServerAdapterOptions } from '../../shared/vite'; | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export function bunServerAdapter(opts: bunServerAdapterOptions = {}): any { | ||
const env = process?.env; | ||
return viteAdapter({ | ||
name: opts.name || 'bun-server', | ||
origin: env?.ORIGIN ?? env?.URL ?? 'https://yoursitename.qwik.builder.io', | ||
ssg: opts.ssg, | ||
cleanStaticGenerated: true, | ||
|
||
config() { | ||
return { | ||
ssr: { | ||
target: 'node', | ||
}, | ||
build: { | ||
ssr: true, | ||
}, | ||
publicDir: false, | ||
}; | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export interface bunServerAdapterOptions extends ServerAdapterOptions { | ||
name?: string; | ||
} | ||
|
||
/** | ||
* @alpha | ||
*/ | ||
export type { StaticGenerateRenderOptions }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
"extends": "../../api-extractor.json", | ||
"mainEntryPointFilePath": "<projectFolder>/dist-dev/dts-out/packages/qwik-city/middleware/bun/index.d.ts", | ||
"apiReport": { | ||
"enabled": true, | ||
"reportFileName": "api.md", | ||
"reportFolder": "<projectFolder>/packages/qwik-city/middleware/bun/", | ||
"reportTempFolder": "<projectFolder>/dist-dev/api-extractor/qwik-city/middleware/bun" | ||
}, | ||
"dtsRollup": { | ||
"enabled": true, | ||
"untrimmedFilePath": "<projectFolder>/packages/qwik-city/lib/middleware/bun/index.d.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## API Report File for "@builder.io/qwik-city" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
|
||
```ts | ||
|
||
import type { ClientConn } from '@builder.io/qwik-city/middleware/request-handler'; | ||
import type { ServerRenderOptions } from '@builder.io/qwik-city/middleware/request-handler'; | ||
|
||
// @public (undocumented) | ||
export function createQwikCity(opts: QwikCityBunOptions): { | ||
router: (request: Request) => Promise<Response | null>; | ||
notFound: (request: Request) => Promise<Response>; | ||
staticFile: (request: Request) => Promise<Response | null>; | ||
}; | ||
|
||
// @public (undocumented) | ||
export interface QwikCityBunOptions extends ServerRenderOptions { | ||
// (undocumented) | ||
getClientConn?: (request: Request) => ClientConn; | ||
static?: { | ||
root?: string; | ||
cacheControl?: string; | ||
}; | ||
} | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we provide a link to the install guide of bun?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I've added much more detailed information about both the installation and the current issue with using bun install.