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: vendor deno dependencies #2302

Merged
merged 14 commits into from
Sep 29, 2023
Merged
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lib
demos
packages/runtime/src/templates/edge
packages/runtime/src/templates/edge-shared
packages/runtime/src/templates/vendor
packages/runtime/lib
packages/runtime/dist-types
jestSetup.js
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ test/e2e

**/CHANGELOG.md
packages/runtime/lib
packages/runtime/dist-types
packages/runtime/dist-types
packages/runtime/src/templates/vendor
1 change: 1 addition & 0 deletions packages/runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/templates/vendor
4 changes: 3 additions & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
"publish:install": "npm ci",
"publish:test": "cd .. && npm ci && npm test",
"clean": "rimraf lib dist-types",
"build": "tsc",
"build": "run-s build:*",
"build:vendor": "rimraf src/templates/vendor && deno vendor src/templates/edge/shims.js src/templates/edge-shared/next-utils.ts https://deno.land/x/[email protected]/index.ts --output=src/templates/vendor",
"build:tsc": "tsc",
"watch": "tsc --watch",
"prepare": "npm run build"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/runtime/src/helpers/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const getEdgeFunctionPatternForPage = ({
export const writeEdgeFunctions = async ({
netlifyConfig,
routesManifest,
constants: { PACKAGE_PATH = '' },
constants: { PACKAGE_PATH = '', INTERNAL_EDGE_FUNCTIONS_SRC },
}: {
netlifyConfig: NetlifyConfig
routesManifest: RoutesManifest
Expand All @@ -378,6 +378,11 @@ export const writeEdgeFunctions = async ({
const nextConfig = nextConfigFile.config
const usesAppDir = nextConfig.experimental?.appDir

await copy(getEdgeTemplatePath('../vendor'), join(edgeFunctionRoot, 'vendor'))
netlifyConfig.functions['*'] = {
deno_import_map: join(INTERNAL_EDGE_FUNCTIONS_SRC, 'vendor', 'import_map.json'),
Copy link
Contributor

Choose a reason for hiding this comment

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

This gives a TypeScript error as deno_import_map doesn't exist in FunctionsObject. Do we need to update the type to support import maps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, good catch! doing that in netlify/build#5305

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me know when it's released and when this PR is updated. We'll get this merged. 👍🏻

}

await copy(getEdgeTemplatePath('../edge-shared'), join(edgeFunctionRoot, 'edge-shared'))
await writeJSON(join(edgeFunctionRoot, 'edge-shared', 'nextConfig.json'), nextConfig)
await copy(join(publish, 'prerender-manifest.json'), join(edgeFunctionRoot, 'edge-shared', 'prerender-manifest.json'))
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
],
"exclude": [
"src/templates/edge/*",
"src/templates/edge-shared/*"
"src/templates/edge-shared/*",
"src/templates/vendor/*"
]
}