-
Notifications
You must be signed in to change notification settings - Fork 5k
jsc: let get_optional::<JSValue> replace the Terminal and bake get_optional_value shims #39150
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e95c234
jsc: let get_optional::<JSValue> replace the Terminal and bake get_op…
robobun df32382
test: pin null handling of the optional app and Terminal size options
robobun c6a26e8
test: wait for the whole size token, ConPTY output also contains ]
robobun 0043e7c
Merge branch 'main' into farm/0dfb4353/dedupe-get-optional-value
alii 556ee32
Merge branch 'main' into farm/0dfb4353/dedupe-get-optional-value
alii 4ca91e1
test: reject with the captured output if the terminal exits before re…
robobun 9060c66
test: give the size helper an inline terminal so its exit callback ca…
robobun 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,68 @@ | ||
| // Parsing of the `app` option shared by `Bun.serve({ app })` and `bun build --app` | ||
| // (src/runtime/bake/bake_body.rs). The optional keys read here treat `null` the | ||
| // same as a missing key, while any other value, including `false`, is validated. | ||
| import { expect, test } from "bun:test"; | ||
| import { bunEnv, bunExe, tempDir } from "harness"; | ||
|
|
||
| test("optional app keys treat null as absent", async () => { | ||
| using dir = tempDir("bake-app-options", { | ||
| "server.ts": `export function render() { return new Response("unused"); }`, | ||
| "check.ts": ` | ||
| import path from "node:path"; | ||
| const framework = { | ||
| fileSystemRouterTypes: [ | ||
| { root: path.join(import.meta.dir, "routes"), style: "nextjs-pages", serverEntryPoint: "./server.ts" }, | ||
| ], | ||
| }; | ||
| const serverComponents = value => ({ framework: { ...framework, serverComponents: { separateSSRGraph: value } } }); | ||
| const apps = { | ||
| "bundlerOptions: null": { framework, bundlerOptions: null }, | ||
| "bundlerOptions.{server,client,ssr}: null": { framework, bundlerOptions: { server: null, client: null, ssr: null } }, | ||
| "bundlerOptions.client.sourcemap: null": { framework, bundlerOptions: { client: { sourcemap: null } } }, | ||
| "bundlerOptions.client.sourcemap: 0": { framework, bundlerOptions: { client: { sourcemap: 0 } } }, | ||
| "bundlerOptions.client.minify: null": { framework, bundlerOptions: { client: { minify: null } } }, | ||
| "framework.plugins: null": { framework: { ...framework, plugins: null } }, | ||
| "serverComponents.separateSSRGraph: null": serverComponents(null), | ||
| "serverComponents.separateSSRGraph: 0": serverComponents(0), | ||
| // false is a value, not "absent": parsing moves on to the next required key. | ||
| "serverComponents.separateSSRGraph: false": serverComponents(false), | ||
| }; | ||
|
|
||
| const results = {}; | ||
| for (const [name, app] of Object.entries(apps)) { | ||
| try { | ||
| const server = Bun.serve({ port: 0, development: true, app, fetch: () => new Response("") }); | ||
| server.stop(true); | ||
| results[name] = "accepted"; | ||
| } catch (e) { | ||
| results[name] = e.message; | ||
| } | ||
| } | ||
| console.log(JSON.stringify(results)); | ||
| `, | ||
| }); | ||
|
|
||
| await using proc = Bun.spawn({ | ||
| cmd: [bunExe(), "check.ts"], | ||
| env: bunEnv, | ||
| cwd: String(dir), | ||
| stdout: "pipe", | ||
| stderr: "pipe", | ||
| }); | ||
| const [stdout, stderr, exitCode] = await Promise.all([proc.stdout.text(), proc.stderr.text(), proc.exited]); | ||
|
|
||
| expect(stderr).toBe(""); | ||
| expect(JSON.parse(stdout)).toEqual({ | ||
| "bundlerOptions: null": "accepted", | ||
| "bundlerOptions.{server,client,ssr}: null": "accepted", | ||
| "bundlerOptions.client.sourcemap: null": "accepted", | ||
| "bundlerOptions.client.sourcemap: 0": | ||
| 'The "sourcemap" property must be of type "inline" | "external" | "linked", got number', | ||
| "bundlerOptions.client.minify: null": "accepted", | ||
| "framework.plugins: null": "accepted", | ||
| "serverComponents.separateSSRGraph: null": "Missing 'framework.serverComponents.separateSSRGraph'", | ||
| "serverComponents.separateSSRGraph: 0": "'framework.serverComponents.separateSSRGraph' must be a boolean", | ||
| "serverComponents.separateSSRGraph: false": "Missing 'framework.serverComponents.serverRuntimeImportSource'", | ||
| }); | ||
| expect(exitCode).toBe(0); | ||
| }); |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.