@sveltejs/kit 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/prerender/prerender.js +5 -2
- package/src/exports/node/polyfills.js +1 -0
- package/src/exports/vite/dev/index.js +4 -1
- package/src/exports/vite/preview/index.js +5 -2
- package/src/utils/platform.js +1 -0
- package/types/index.d.ts +1 -1
- package/types/internal.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync, writeFileSync } from 'fs';
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { pathToFileURL, URL } from 'url';
|
|
4
|
-
import { mkdirp, posixify, walk } from '../../utils/filesystem.js';
|
|
5
4
|
import { installPolyfills } from '../../exports/node/polyfills.js';
|
|
5
|
+
import { mkdirp, posixify, walk } from '../../utils/filesystem.js';
|
|
6
|
+
import { should_polyfill } from '../../utils/platform.js';
|
|
6
7
|
import { is_root_relative, resolve } from '../../utils/url.js';
|
|
7
8
|
import { queue } from './queue.js';
|
|
8
9
|
import { crawl } from './crawl.js';
|
|
@@ -89,7 +90,9 @@ export async function prerender() {
|
|
|
89
90
|
verbose: verbose === 'true'
|
|
90
91
|
});
|
|
91
92
|
|
|
92
|
-
|
|
93
|
+
if (should_polyfill) {
|
|
94
|
+
installPolyfills();
|
|
95
|
+
}
|
|
93
96
|
|
|
94
97
|
const server_root = join(config.outDir, 'output');
|
|
95
98
|
|
|
@@ -16,6 +16,7 @@ const globals = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
// exported for dev/preview and node environments
|
|
19
|
+
// TODO: remove this once we only support Node 18.11+ (the version multipart/form-data was added)
|
|
19
20
|
export function installPolyfills() {
|
|
20
21
|
for (const name in globals) {
|
|
21
22
|
Object.defineProperty(globalThis, name, {
|
|
@@ -8,6 +8,7 @@ import { getRequest, setResponse } from '../../../exports/node/index.js';
|
|
|
8
8
|
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
9
9
|
import { coalesce_to_error } from '../../../utils/error.js';
|
|
10
10
|
import { posixify, resolve_entry, to_fs } from '../../../utils/filesystem.js';
|
|
11
|
+
import { should_polyfill } from '../../../utils/platform.js';
|
|
11
12
|
import { load_error_page, load_template } from '../../../core/config/index.js';
|
|
12
13
|
import { SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
13
14
|
import * as sync from '../../../core/sync/sync.js';
|
|
@@ -24,7 +25,9 @@ const cwd = process.cwd();
|
|
|
24
25
|
* @return {Promise<Promise<() => void>>}
|
|
25
26
|
*/
|
|
26
27
|
export async function dev(vite, vite_config, svelte_config) {
|
|
27
|
-
|
|
28
|
+
if (should_polyfill) {
|
|
29
|
+
installPolyfills();
|
|
30
|
+
}
|
|
28
31
|
|
|
29
32
|
sync.init(svelte_config, vite_config.mode);
|
|
30
33
|
|
|
@@ -2,10 +2,11 @@ import fs from 'fs';
|
|
|
2
2
|
import { join } from 'path';
|
|
3
3
|
import sirv from 'sirv';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
+
import { loadEnv, normalizePath } from 'vite';
|
|
5
6
|
import { getRequest, setResponse } from '../../../exports/node/index.js';
|
|
6
7
|
import { installPolyfills } from '../../../exports/node/polyfills.js';
|
|
7
8
|
import { SVELTE_KIT_ASSETS } from '../../../constants.js';
|
|
8
|
-
import {
|
|
9
|
+
import { should_polyfill } from '../../../utils/platform.js';
|
|
9
10
|
import { not_found } from '../utils.js';
|
|
10
11
|
|
|
11
12
|
/** @typedef {import('http').IncomingMessage} Req */
|
|
@@ -21,7 +22,9 @@ import { not_found } from '../utils.js';
|
|
|
21
22
|
* @param {import('types').ValidatedConfig} svelte_config
|
|
22
23
|
*/
|
|
23
24
|
export async function preview(vite, vite_config, svelte_config) {
|
|
24
|
-
|
|
25
|
+
if (should_polyfill) {
|
|
26
|
+
installPolyfills();
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
const { paths } = svelte_config.kit;
|
|
27
30
|
const base = paths.base;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const should_polyfill = typeof Deno === 'undefined' && typeof Bun === 'undefined';
|
package/types/index.d.ts
CHANGED