@sveltejs/adapter-node
Advanced tools
Comparing version 3.0.1 to 4.0.0
import 'SHIMS'; | ||
import fs$1 from 'node:fs'; | ||
import fs$1, { createReadStream } from 'node:fs'; | ||
import path from 'node:path'; | ||
@@ -9,4 +9,5 @@ import * as fs from 'fs'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { Readable } from 'node:stream'; | ||
import { Server } from 'SERVER'; | ||
import { manifest, prerendered } from 'MANIFEST'; | ||
import { manifest, prerendered, base } from 'MANIFEST'; | ||
import { env } from 'ENV'; | ||
@@ -1132,6 +1133,16 @@ | ||
/** | ||
* Converts a file on disk to a readable stream | ||
* @param {string} file | ||
* @returns {ReadableStream} | ||
* @since 2.4.0 | ||
*/ | ||
function createReadableStream(file) { | ||
return /** @type {ReadableStream} */ (Readable.toWeb(createReadStream(file))); | ||
} | ||
/* global ENV_PREFIX */ | ||
const server = new Server(manifest); | ||
await server.init({ env: process.env }); | ||
const origin = env('ORIGIN', undefined); | ||
@@ -1153,2 +1164,9 @@ const xff_depth = parseInt(env('XFF_DEPTH', '1')); | ||
const asset_dir = `${dir}/client${base}`; | ||
await server.init({ | ||
env: process.env, | ||
read: (file) => createReadableStream(`${asset_dir}/${file}`) | ||
}); | ||
/** | ||
@@ -1155,0 +1173,0 @@ * @param {string} path |
11
index.js
@@ -42,4 +42,7 @@ import { readFileSync, writeFileSync } from 'node:fs'; | ||
`${tmp}/manifest.js`, | ||
`export const manifest = ${builder.generateManifest({ relativePath: './' })};\n\n` + | ||
`export const prerendered = new Set(${JSON.stringify(builder.prerendered.paths)});\n` | ||
[ | ||
`export const manifest = ${builder.generateManifest({ relativePath: './' })};`, | ||
`export const prerendered = new Set(${JSON.stringify(builder.prerendered.paths)});`, | ||
`export const base = ${JSON.stringify(builder.config.kit.paths.base)};` | ||
].join('\n\n') | ||
); | ||
@@ -90,4 +93,8 @@ | ||
}); | ||
}, | ||
supports: { | ||
read: () => true | ||
} | ||
}; | ||
} |
{ | ||
"name": "@sveltejs/adapter-node", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "Adapter for SvelteKit apps that generates a standalone Node server", | ||
@@ -35,3 +35,3 @@ "repository": { | ||
"vitest": "^1.2.0", | ||
"@sveltejs/kit": "^2.3.3" | ||
"@sveltejs/kit": "^2.4.0" | ||
}, | ||
@@ -45,3 +45,3 @@ "dependencies": { | ||
"peerDependencies": { | ||
"@sveltejs/kit": "^2.0.0" | ||
"@sveltejs/kit": "^2.4.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50133
1543