Skip to content

Commit 64deae5

Browse files
authored
fix: use node: imports in adapter-node to support Deno (#12785)
1 parent 3b89463 commit 64deae5

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

.changeset/breezy-poems-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/adapter-node': patch
3+
---
4+
5+
fix: use `node:` imports to support Deno

packages/adapter-node/rollup.config.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,34 @@ import commonjs from '@rollup/plugin-commonjs';
33
import json from '@rollup/plugin-json';
44
import { builtinModules } from 'node:module';
55

6+
function prefixBuiltinModules() {
7+
return {
8+
resolveId(source) {
9+
if (builtinModules.includes(source)) {
10+
return { id: 'node:' + source, external: true };
11+
}
12+
}
13+
};
14+
}
15+
616
export default [
717
{
818
input: 'src/index.js',
919
output: {
1020
file: 'files/index.js',
1121
format: 'esm'
1222
},
13-
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json()],
14-
external: ['ENV', 'HANDLER', ...builtinModules]
23+
plugins: [nodeResolve({ preferBuiltins: true }), commonjs(), json(), prefixBuiltinModules()],
24+
external: ['ENV', 'HANDLER']
1525
},
1626
{
1727
input: 'src/env.js',
1828
output: {
1929
file: 'files/env.js',
2030
format: 'esm'
2131
},
22-
plugins: [nodeResolve(), commonjs(), json()],
23-
external: ['HANDLER', ...builtinModules]
32+
plugins: [nodeResolve(), commonjs(), json(), prefixBuiltinModules()],
33+
external: ['HANDLER']
2434
},
2535
{
2636
input: 'src/handler.js',
@@ -29,16 +39,15 @@ export default [
2939
format: 'esm',
3040
inlineDynamicImports: true
3141
},
32-
plugins: [nodeResolve(), commonjs(), json()],
33-
external: ['ENV', 'MANIFEST', 'SERVER', 'SHIMS', ...builtinModules]
42+
plugins: [nodeResolve(), commonjs(), json(), prefixBuiltinModules()],
43+
external: ['ENV', 'MANIFEST', 'SERVER', 'SHIMS']
3444
},
3545
{
3646
input: 'src/shims.js',
3747
output: {
3848
file: 'files/shims.js',
3949
format: 'esm'
4050
},
41-
plugins: [nodeResolve(), commonjs()],
42-
external: builtinModules
51+
plugins: [nodeResolve(), commonjs(), prefixBuiltinModules()]
4352
}
4453
];

0 commit comments

Comments
 (0)