Skip to content

Commit

Permalink
fix: use node: imports in adapter-node to support Deno (#12785)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry authored Oct 10, 2024
1 parent 3b89463 commit 64deae5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-poems-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

fix: use `node:` imports to support Deno
25 changes: 17 additions & 8 deletions packages/adapter-node/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,34 @@ import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { builtinModules } from 'node:module';

function prefixBuiltinModules() {
return {
resolveId(source) {
if (builtinModules.includes(source)) {
return { id: 'node:' + source, external: true };
}
}
};
}

export default [
{
input: 'src/index.js',
output: {
file: 'files/index.js',
format: 'esm'
},
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()],
external: ['ENV', 'HANDLER', ...builtinModules]
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json(), prefixBuiltinModules()],
external: ['ENV', 'HANDLER']
},
{
input: 'src/env.js',
output: {
file: 'files/env.js',
format: 'esm'
},
plugins: [nodeResolve(), commonjs(), json()],
external: ['HANDLER', ...builtinModules]
plugins: [nodeResolve(), commonjs(), json(), prefixBuiltinModules()],
external: ['HANDLER']
},
{
input: 'src/handler.js',
Expand All @@ -29,16 +39,15 @@ export default [
format: 'esm',
inlineDynamicImports: true
},
plugins: [nodeResolve(), commonjs(), json()],
external: ['ENV', 'MANIFEST', 'SERVER', 'SHIMS', ...builtinModules]
plugins: [nodeResolve(), commonjs(), json(), prefixBuiltinModules()],
external: ['ENV', 'MANIFEST', 'SERVER', 'SHIMS']
},
{
input: 'src/shims.js',
output: {
file: 'files/shims.js',
format: 'esm'
},
plugins: [nodeResolve(), commonjs()],
external: builtinModules
plugins: [nodeResolve(), commonjs(), prefixBuiltinModules()]
}
];

0 comments on commit 64deae5

Please sign in to comment.