Skip to content

Commit

Permalink
fix: copy vendor over for local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Oct 18, 2023
1 parent 2fca7b3 commit 5d71bfb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"publish:test": "cd .. && npm ci && npm test",
"clean": "rimraf lib dist-types",
"build": "run-s build:*",
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/vendor.ts --output=src/templates/vendor && patch src/templates/vendor/deno.land/x/[email protected]/index.ts html_rewriter.patch",
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/vendor.ts --output=src/templates/vendor && node patch-import-map.mjs && patch src/templates/vendor/deno.land/x/[email protected]/index.ts html_rewriter.patch",
"build:tsc": "tsc",
"watch": "tsc --watch",
"prepare": "npm run build"
Expand Down
13 changes: 13 additions & 0 deletions packages/runtime/patch-import-map.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { readFile, writeFile } from "fs/promises"

const importMapPath = new URL("src/templates/vendor/import_map.json", import.meta.url)
const importMap = JSON.parse(await readFile(importMapPath, "utf8"))

const newMap = {
scopes: {
"../": importMap.imports,
...importMap.scopes
}
}

await writeFile(importMapPath, JSON.stringify(newMap, null, 2))
2 changes: 2 additions & 0 deletions packages/runtime/src/helpers/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,12 @@ export const writeDevEdgeFunction = async ({
},
],
version: 1,
import_map: 'vendor/import_map.json',
}
const edgeFunctionRoot = resolve(INTERNAL_EDGE_FUNCTIONS_SRC)
await emptyDir(edgeFunctionRoot)
await writeJson(join(edgeFunctionRoot, 'manifest.json'), manifest)
await copy(getEdgeTemplatePath('../vendor'), join(edgeFunctionRoot, 'vendor'))
await copy(getEdgeTemplatePath('../edge-shared'), join(edgeFunctionRoot, 'edge-shared'))

const edgeFunctionDir = join(edgeFunctionRoot, 'next-dev')
Expand Down

0 comments on commit 5d71bfb

Please sign in to comment.