-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move must have template changes to example
- Loading branch information
Showing
10 changed files
with
157 additions
and
7 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 @@ | ||
.shopify |
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,45 @@ | ||
import type {EntryContext} from '@shopify/remix-oxygen'; | ||
import {RemixServer} from '@remix-run/react'; | ||
import isbot from 'isbot'; | ||
import {renderToReadableStream} from 'react-dom/server'; | ||
import {createContentSecurityPolicy} from '@shopify/hydrogen'; | ||
|
||
export default async function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext, | ||
) { | ||
const {nonce, header, NonceProvider} = createContentSecurityPolicy(); | ||
|
||
const body = await renderToReadableStream( | ||
<NonceProvider> | ||
{/***********************************************/ | ||
/********** EXAMPLE UPDATE STARTS ************/} | ||
<RemixServer context={remixContext} url={request.url} nonce={nonce} /> | ||
{/********** EXAMPLE UPDATE END ************/ | ||
/***********************************************/} | ||
</NonceProvider>, | ||
{ | ||
nonce, | ||
signal: request.signal, | ||
onError(error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
responseStatusCode = 500; | ||
}, | ||
}, | ||
); | ||
|
||
if (isbot(request.headers.get('user-agent'))) { | ||
await body.allReady; | ||
} | ||
|
||
responseHeaders.set('Content-Type', 'text/html'); | ||
responseHeaders.set('Content-Security-Policy', header); | ||
|
||
return new Response(body, { | ||
headers: responseHeaders, | ||
status: responseStatusCode, | ||
}); | ||
} |
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,16 @@ | ||
{ | ||
"name": "example-single-fetch", | ||
"private": true, | ||
"prettier": "@shopify/prettier-config", | ||
"scripts": { | ||
"build": "shopify hydrogen build --diff", | ||
"dev": "shopify hydrogen dev --codegen --diff", | ||
"preview": "shopify hydrogen preview --build --diff", | ||
"lint": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx .", | ||
"typecheck": "tsc --noEmit", | ||
"codegen": "shopify hydrogen codegen" | ||
}, | ||
"dependencies": { | ||
"@shopify/cli-hydrogen": "*" | ||
} | ||
} |
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,30 @@ | ||
{ | ||
"include": ["./**/*.d.ts", "./**/*.ts", "./**/*.tsx"], | ||
"compilerOptions": { | ||
"lib": ["DOM", "DOM.Iterable", "ES2022"], | ||
"isolatedModules": true, | ||
"esModuleInterop": true, | ||
"jsx": "react-jsx", | ||
"moduleResolution": "Bundler", | ||
"resolveJsonModule": true, | ||
"module": "ES2022", | ||
"target": "ES2022", | ||
"strict": true, | ||
"allowJs": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"skipLibCheck": true, | ||
"baseUrl": ".", | ||
"types": [ | ||
"@shopify/oxygen-workers-types", | ||
/***********************************************/ | ||
/********** EXAMPLE UPDATE STARTS ************/ | ||
"@remix-run/react/future/single-fetch.d.ts" | ||
/********** EXAMPLE UPDATE END ************/ | ||
/***********************************************/ | ||
], | ||
"paths": { | ||
"~/*": ["app/*"] | ||
}, | ||
"noEmit": true | ||
} | ||
} |
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,46 @@ | ||
import {defineConfig} from 'vite'; | ||
import {hydrogen} from '@shopify/hydrogen/vite'; | ||
import {oxygen} from '@shopify/mini-oxygen/vite'; | ||
import {vitePlugin as remix} from '@remix-run/dev'; | ||
import tsconfigPaths from 'vite-tsconfig-paths'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
hydrogen(), | ||
oxygen(), | ||
remix({ | ||
presets: [hydrogen.preset()], | ||
future: { | ||
v3_fetcherPersist: true, | ||
v3_relativeSplatPath: true, | ||
v3_throwAbortReason: true, | ||
/***********************************************/ | ||
/********** EXAMPLE UPDATE STARTS ************/ | ||
unstable_singleFetch: true, | ||
/********** EXAMPLE UPDATE END ************/ | ||
/***********************************************/ | ||
}, | ||
}), | ||
tsconfigPaths(), | ||
], | ||
build: { | ||
// Allow a strict Content-Security-Policy | ||
// withtout inlining assets as base64: | ||
assetsInlineLimit: 0, | ||
}, | ||
ssr: { | ||
optimizeDeps: { | ||
/** | ||
* Include dependencies here if they throw CJS<>ESM errors. | ||
* For example, for the following error: | ||
* | ||
* > ReferenceError: module is not defined | ||
* > at /Users/.../node_modules/example-dep/index.js:1:1 | ||
* | ||
* Include 'example-dep' in the array below. | ||
* @see https://vitejs.dev/config/dep-optimization-options | ||
*/ | ||
include: [], | ||
}, | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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