Skip to content

Commit e43fcf2

Browse files
authored
fix: copy vendor over for local dev (#2341)
1 parent 2fca7b3 commit e43fcf2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/runtime/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"publish:test": "cd .. && npm ci && npm test",
5656
"clean": "rimraf lib dist-types",
5757
"build": "run-s build:*",
58-
"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",
58+
"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",
5959
"build:tsc": "tsc",
6060
"watch": "tsc --watch",
6161
"prepare": "npm run build"

packages/runtime/patch-import-map.mjs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { readFile, writeFile } from "fs/promises"
2+
3+
const importMapPath = new URL("src/templates/vendor/import_map.json", import.meta.url)
4+
const importMap = JSON.parse(await readFile(importMapPath, "utf8"))
5+
6+
const newMap = {
7+
scopes: {
8+
"../": importMap.imports,
9+
...importMap.scopes
10+
}
11+
}
12+
13+
await writeFile(importMapPath, JSON.stringify(newMap, null, 2))

packages/runtime/src/helpers/edge.ts

+2
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ export const writeDevEdgeFunction = async ({
260260
},
261261
],
262262
version: 1,
263+
import_map: 'vendor/import_map.json',
263264
}
264265
const edgeFunctionRoot = resolve(INTERNAL_EDGE_FUNCTIONS_SRC)
265266
await emptyDir(edgeFunctionRoot)
266267
await writeJson(join(edgeFunctionRoot, 'manifest.json'), manifest)
268+
await copy(getEdgeTemplatePath('../vendor'), join(edgeFunctionRoot, 'vendor'))
267269
await copy(getEdgeTemplatePath('../edge-shared'), join(edgeFunctionRoot, 'edge-shared'))
268270

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

0 commit comments

Comments
 (0)