-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract workerd logic in mini-oxygen package (#1891)
* Move Node sandbox code * Update imports * Extract common headers * Remove redundant values * Change dependencies * Extract workerd logic in MiniOxygen package * Adjust e2e tests for workerd in MiniOxygen * Fix sourcemaps * Simplify reload usage * Use @shopify/mini-oxygen in classic workerd dev process * Only show errors in Node runtime * Use @shopify/mini-oxygen in Vite dev process * Extract compat flags * Fix CLI deps * Only find open ports when flags are not specified * Move Node tests and avoid creating local folders * Ensure only 1 instance of MiniOxygen is created * Handle missing dependency better * Adjust dependencies * Make mini-oxygen an optional dep of CLI * Fix preview command * Make test more robust when running locally * Minor log fixes * Require direct mini-oxygen dependency in templates * Update MiniOxygen readme * Avoid depending on mini-oxygen directly from vite plugin * Changesets * Add dispatchFetch to Node sandbox runtime * Add example for Node sandbox to readme * Support wrappedBindings without compat flags * Fix extra lines in banners * Move unsafe outbound service condition to mini-oxygen * Enable verbose logs based on DEBUG variable * Fix TS auto-imports * Move CAA schema patch for graphiql back to CLI
- Loading branch information
Showing
51 changed files
with
1,369 additions
and
1,098 deletions.
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,32 @@ | ||
--- | ||
'@shopify/mini-oxygen': major | ||
--- | ||
|
||
The main runtime exported from `@shopify/mini-oxygen` is now based on workerd. | ||
The previous Node.js sandbox runtime has been moved to the `@shopify/mini-oxygen/node` export. | ||
|
||
Example usage: | ||
|
||
```js | ||
import {createMiniOxygen} from '@shopify/mini-oxygen'; | ||
|
||
const miniOxygen = createMiniOxygen({ | ||
workers: [ | ||
{ | ||
name: 'main', | ||
modules: true, | ||
script: `export default { | ||
async fetch() { | ||
const response = await fetch("https://hydrogen.shopify.dev"); | ||
return response; | ||
} | ||
}`, | ||
}, | ||
], | ||
}); | ||
|
||
const response = await miniOxygen.dispatchFetch('http://placeholder'); | ||
console.log(await response.text()); | ||
|
||
await miniOxygen.dispose(); | ||
``` |
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 @@ | ||
--- | ||
'skeleton': patch | ||
--- | ||
|
||
If you deploy to Oxygen, please add `@shopify/mini-oxygen` as a dev dependency in your project for local development: | ||
|
||
```diff | ||
"devDependencies": { | ||
"@remix-run/dev": "^2.8.0", | ||
"@remix-run/eslint-config": "^2.8.0", | ||
+ "@shopify/mini-oxygen": "^3.0.0", | ||
"@shopify/oxygen-workers-types": "^4.0.0", | ||
... | ||
}, | ||
``` |
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,7 @@ | ||
--- | ||
'@shopify/cli-hydrogen': major | ||
--- | ||
|
||
Hydrogen CLI now requires `@shopify/mini-oxygen` to be installed separately as a dev dependency. It is still used automatically under the hood so there is no need to change your application code aside from installing the dependency. | ||
|
||
Also, if a port provided via `--port` or `--inspector-port` flags is already in use, the CLI will now exit with an error message instead of finding a new open port. When the flags are not provided, the CLI will still find an open port. |
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
Oops, something went wrong.