-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
layer:
prefix to ESZIP loader (#201)
* feat: add `layer:` prefix to ESZIP loader * feat: add layer support to ESZIP loader * refactor: ensure ESZIP path exists Co-authored-by: Karin Hendrikse <[email protected]>
- Loading branch information
1 parent
a314063
commit 4d0e8dd
Showing
5 changed files
with
50 additions
and
6 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const PUBLIC_SPECIFIER = "netlify:edge"; | ||
export const STAGE1_SPECIFIER = "netlify:bootstrap-stage1"; | ||
export const STAGE2_SPECIFIER = "netlify:bootstrap-stage2"; | ||
export const virtualRoot = "file:///root/"; | ||
export const CUSTOM_LAYER_PREFIX = 'layer:' | ||
export const PUBLIC_SPECIFIER = 'netlify:edge' | ||
export const STAGE1_SPECIFIER = 'netlify:bootstrap-stage1' | ||
export const STAGE2_SPECIFIER = 'netlify:bootstrap-stage2' | ||
export const virtualRoot = 'file:///root/' |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ import { build, LoadResponse } from 'https://deno.land/x/[email protected]/mod.ts' | |
import * as path from 'https://deno.land/[email protected]/path/mod.ts' | ||
|
||
import type { InputFunction, WriteStage2Options } from '../../shared/stage2.ts' | ||
import { PUBLIC_SPECIFIER, STAGE2_SPECIFIER, virtualRoot } from './consts.ts' | ||
import { CUSTOM_LAYER_PREFIX, PUBLIC_SPECIFIER, STAGE2_SPECIFIER, virtualRoot } from './consts.ts' | ||
import { inlineModule, loadFromVirtualRoot, loadWithRetry } from './common.ts' | ||
|
||
interface FunctionReference { | ||
|
@@ -70,7 +70,7 @@ const stage2Loader = (basePath: string, functions: InputFunction[]) => { | |
return inlineModule(specifier, stage2Entry) | ||
} | ||
|
||
if (specifier === PUBLIC_SPECIFIER) { | ||
if (specifier === PUBLIC_SPECIFIER || specifier.startsWith(CUSTOM_LAYER_PREFIX)) { | ||
return { | ||
kind: 'external', | ||
specifier, | ||
|
@@ -88,6 +88,9 @@ const stage2Loader = (basePath: string, functions: InputFunction[]) => { | |
const writeStage2 = async ({ basePath, destPath, functions, importMapURL }: WriteStage2Options) => { | ||
const loader = stage2Loader(basePath, functions) | ||
const bytes = await build([STAGE2_SPECIFIER], loader, importMapURL) | ||
const directory = path.dirname(destPath) | ||
|
||
await Deno.mkdir(directory, { recursive: true }) | ||
|
||
return await Deno.writeFile(destPath, bytes) | ||
} | ||
|
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,3 @@ | ||
import { handleRequest } from 'layer:test' | ||
|
||
export default (req: Request) => handleRequest(req) |