Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

Commit

Permalink
chore(netlify): support node: prefixed imports (#286)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Kane <[email protected]>
Co-authored-by: Alexander Niebuhr <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2024
1 parent a45eb36 commit e2ecf64
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-snails-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---

Allows support for `node:` prefixed imports if using the Adapter with `edgeMiddleware: true`
12 changes: 12 additions & 0 deletions packages/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ export default function netlifyIntegration(
// taking over bundling, because Netlify bundling trips over NPM modules
await build({
entryPoints: [fileURLToPath(new URL('./entry.mjs', middlewareOutputDir()))],
// allow `node:` prefixed imports, which are valid in netlify's deno edge runtime
plugins: [
{
name: 'allowNodePrefixedImports',
setup(build) {
build.onResolve({ filter: /^node:.*$/ }, (args) => ({
path: args.path,
external: true,
}));
},
},
],
target: 'es2022',
platform: 'neutral',
mainFields: ['module', 'main'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import https from 'node:https';

export const onRequest = (context, next) => {
context.locals.title = 'Middleware';
context.locals.nodePrefixedImportExists = !!https;

return next();
};

0 comments on commit e2ecf64

Please sign in to comment.