Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: copy vendor over for local dev #2341

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're moving the imports field generated by Deno into the ../ scope, so it only applies to our Next code and not to other, Netlify-managed code like the bootstrap layer.

...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
Loading