@sveltejs/kit 1.0.0-next.392 → 1.0.0-next.395
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/assets/client/start.js +9 -2
- package/assets/env/dynamic/private.js +1 -0
- package/assets/env/dynamic/public.js +1 -0
- package/assets/env-private.js +9 -0
- package/assets/env-public.js +9 -0
- package/assets/server/index.js +4 -1
- package/dist/chunks/error.js +1 -671
- package/dist/chunks/filesystem.js +110 -0
- package/dist/chunks/index.js +574 -15643
- package/dist/chunks/index2.js +15705 -177
- package/dist/chunks/index3.js +218 -0
- package/dist/chunks/sync.js +377 -70
- package/dist/chunks/utils.js +66 -0
- package/dist/chunks/write_tsconfig.js +64 -121
- package/dist/cli.js +8 -6
- package/dist/prerender.js +788 -0
- package/dist/vite.js +194 -971
- package/package.json +1 -1
- package/types/ambient.d.ts +58 -12
- package/types/index.d.ts +8 -0
- package/types/internal.d.ts +8 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path__default from 'path';
|
|
2
|
+
import { $ } from './index.js';
|
|
3
|
+
import 'url';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the prefix for the `runtime` directory, for use with import declarations
|
|
7
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
8
|
+
*/
|
|
9
|
+
function get_runtime_prefix(config) {
|
|
10
|
+
{
|
|
11
|
+
return posixify_path(path__default.join(config.outDir, 'runtime'));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get the resolved path of the `runtime` directory
|
|
17
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
18
|
+
*/
|
|
19
|
+
function get_runtime_directory(config) {
|
|
20
|
+
{
|
|
21
|
+
return path__default.join(config.outDir, 'runtime');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @param {string} str */
|
|
26
|
+
function posixify_path(str) {
|
|
27
|
+
const parsed = path__default.parse(str);
|
|
28
|
+
return `/${parsed.dir.slice(parsed.root.length).split(path__default.sep).join('/')}/${parsed.base}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function noop() {}
|
|
32
|
+
|
|
33
|
+
/** @param {{ verbose: boolean }} opts */
|
|
34
|
+
function logger({ verbose }) {
|
|
35
|
+
/** @type {import('types').Logger} */
|
|
36
|
+
const log = (msg) => console.log(msg.replace(/^/gm, ' '));
|
|
37
|
+
|
|
38
|
+
/** @param {string} msg */
|
|
39
|
+
const err = (msg) => console.error(msg.replace(/^/gm, ' '));
|
|
40
|
+
|
|
41
|
+
log.success = (msg) => log($.green(`✔ ${msg}`));
|
|
42
|
+
log.error = (msg) => err($.bold().red(msg));
|
|
43
|
+
log.warn = (msg) => log($.bold().yellow(msg));
|
|
44
|
+
|
|
45
|
+
log.minor = verbose ? (msg) => log($.grey(msg)) : noop;
|
|
46
|
+
log.info = verbose ? log : noop;
|
|
47
|
+
|
|
48
|
+
return log;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @param {import('types').ManifestData} manifest_data */
|
|
52
|
+
function get_mime_lookup(manifest_data) {
|
|
53
|
+
/** @type {Record<string, string>} */
|
|
54
|
+
const mime = {};
|
|
55
|
+
|
|
56
|
+
manifest_data.assets.forEach((asset) => {
|
|
57
|
+
if (asset.type) {
|
|
58
|
+
const ext = path__default.extname(asset.file);
|
|
59
|
+
mime[ext] = asset.type;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return mime;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { get_runtime_prefix as a, get_mime_lookup as b, get_runtime_directory as g, logger as l };
|
|
@@ -1,112 +1,7 @@
|
|
|
1
1
|
import fs__default from 'fs';
|
|
2
2
|
import path__default from 'path';
|
|
3
|
-
import { $ } from './
|
|
4
|
-
|
|
5
|
-
/** @param {string} dir */
|
|
6
|
-
function mkdirp(dir) {
|
|
7
|
-
try {
|
|
8
|
-
fs__default.mkdirSync(dir, { recursive: true });
|
|
9
|
-
} catch (/** @type {any} */ e) {
|
|
10
|
-
if (e.code === 'EEXIST') return;
|
|
11
|
-
throw e;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/** @param {string} path */
|
|
16
|
-
function rimraf(path) {
|
|
17
|
-
fs__default.rmSync(path, { force: true, recursive: true });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @param {string} source
|
|
22
|
-
* @param {string} target
|
|
23
|
-
* @param {{
|
|
24
|
-
* filter?: (basename: string) => boolean;
|
|
25
|
-
* replace?: Record<string, string>;
|
|
26
|
-
* }} opts
|
|
27
|
-
*/
|
|
28
|
-
function copy(source, target, opts = {}) {
|
|
29
|
-
if (!fs__default.existsSync(source)) return [];
|
|
30
|
-
|
|
31
|
-
/** @type {string[]} */
|
|
32
|
-
const files = [];
|
|
33
|
-
|
|
34
|
-
const prefix = posixify(target) + '/';
|
|
35
|
-
|
|
36
|
-
const regex = opts.replace
|
|
37
|
-
? new RegExp(`\\b(${Object.keys(opts.replace).join('|')})\\b`, 'g')
|
|
38
|
-
: null;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @param {string} from
|
|
42
|
-
* @param {string} to
|
|
43
|
-
*/
|
|
44
|
-
function go(from, to) {
|
|
45
|
-
if (opts.filter && !opts.filter(path__default.basename(from))) return;
|
|
46
|
-
|
|
47
|
-
const stats = fs__default.statSync(from);
|
|
48
|
-
|
|
49
|
-
if (stats.isDirectory()) {
|
|
50
|
-
fs__default.readdirSync(from).forEach((file) => {
|
|
51
|
-
go(path__default.join(from, file), path__default.join(to, file));
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
mkdirp(path__default.dirname(to));
|
|
55
|
-
|
|
56
|
-
if (opts.replace) {
|
|
57
|
-
const data = fs__default.readFileSync(from, 'utf-8');
|
|
58
|
-
fs__default.writeFileSync(
|
|
59
|
-
to,
|
|
60
|
-
data.replace(
|
|
61
|
-
/** @type {RegExp} */ (regex),
|
|
62
|
-
(match, key) => /** @type {Record<string, string>} */ (opts.replace)[key]
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
|
-
} else {
|
|
66
|
-
fs__default.copyFileSync(from, to);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
files.push(to === target ? posixify(path__default.basename(to)) : posixify(to).replace(prefix, ''));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
go(source, target);
|
|
74
|
-
|
|
75
|
-
return files;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get a list of all files in a directory
|
|
80
|
-
* @param {string} cwd - the directory to walk
|
|
81
|
-
* @param {boolean} [dirs] - whether to include directories in the result
|
|
82
|
-
*/
|
|
83
|
-
function walk(cwd, dirs = false) {
|
|
84
|
-
/** @type {string[]} */
|
|
85
|
-
const all_files = [];
|
|
86
|
-
|
|
87
|
-
/** @param {string} dir */
|
|
88
|
-
function walk_dir(dir) {
|
|
89
|
-
const files = fs__default.readdirSync(path__default.join(cwd, dir));
|
|
90
|
-
|
|
91
|
-
for (const file of files) {
|
|
92
|
-
const joined = path__default.join(dir, file);
|
|
93
|
-
const stats = fs__default.statSync(path__default.join(cwd, joined));
|
|
94
|
-
if (stats.isDirectory()) {
|
|
95
|
-
if (dirs) all_files.push(joined);
|
|
96
|
-
walk_dir(joined);
|
|
97
|
-
} else {
|
|
98
|
-
all_files.push(joined);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return walk_dir(''), all_files;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** @param {string} str */
|
|
107
|
-
function posixify(str) {
|
|
108
|
-
return str.replace(/\\/g, '/');
|
|
109
|
-
}
|
|
3
|
+
import { $ } from './index.js';
|
|
4
|
+
import { m as mkdirp, p as posixify } from './filesystem.js';
|
|
110
5
|
|
|
111
6
|
/** @type {Map<string, string>} */
|
|
112
7
|
const previous_contents = new Map();
|
|
@@ -138,6 +33,59 @@ function trim(str) {
|
|
|
138
33
|
return str.replace(pattern, '').trim();
|
|
139
34
|
}
|
|
140
35
|
|
|
36
|
+
const reserved = new Set([
|
|
37
|
+
'do',
|
|
38
|
+
'if',
|
|
39
|
+
'in',
|
|
40
|
+
'for',
|
|
41
|
+
'let',
|
|
42
|
+
'new',
|
|
43
|
+
'try',
|
|
44
|
+
'var',
|
|
45
|
+
'case',
|
|
46
|
+
'else',
|
|
47
|
+
'enum',
|
|
48
|
+
'eval',
|
|
49
|
+
'null',
|
|
50
|
+
'this',
|
|
51
|
+
'true',
|
|
52
|
+
'void',
|
|
53
|
+
'with',
|
|
54
|
+
'await',
|
|
55
|
+
'break',
|
|
56
|
+
'catch',
|
|
57
|
+
'class',
|
|
58
|
+
'const',
|
|
59
|
+
'false',
|
|
60
|
+
'super',
|
|
61
|
+
'throw',
|
|
62
|
+
'while',
|
|
63
|
+
'yield',
|
|
64
|
+
'delete',
|
|
65
|
+
'export',
|
|
66
|
+
'import',
|
|
67
|
+
'public',
|
|
68
|
+
'return',
|
|
69
|
+
'static',
|
|
70
|
+
'switch',
|
|
71
|
+
'typeof',
|
|
72
|
+
'default',
|
|
73
|
+
'extends',
|
|
74
|
+
'finally',
|
|
75
|
+
'package',
|
|
76
|
+
'private',
|
|
77
|
+
'continue',
|
|
78
|
+
'debugger',
|
|
79
|
+
'function',
|
|
80
|
+
'arguments',
|
|
81
|
+
'interface',
|
|
82
|
+
'protected',
|
|
83
|
+
'implements',
|
|
84
|
+
'instanceof'
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
const valid_identifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
|
|
88
|
+
|
|
141
89
|
/** @param {string} file */
|
|
142
90
|
const exists = (file) => fs__default.existsSync(file) && file;
|
|
143
91
|
|
|
@@ -158,18 +106,13 @@ function write_tsconfig(config, cwd = process.cwd()) {
|
|
|
158
106
|
/** @param {string} file */
|
|
159
107
|
const config_relative = (file) => posixify(path__default.relative(config.outDir, file));
|
|
160
108
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
project_relative(path__default.dirname(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
dirs.forEach((dir) => {
|
|
169
|
-
include.push(config_relative(`${dir}/**/*.js`));
|
|
170
|
-
include.push(config_relative(`${dir}/**/*.ts`));
|
|
171
|
-
include.push(config_relative(`${dir}/**/*.svelte`));
|
|
172
|
-
});
|
|
109
|
+
const include = ['ambient.d.ts'];
|
|
110
|
+
for (const dir of [config.files.routes, config.files.lib]) {
|
|
111
|
+
const relative = project_relative(path__default.dirname(dir));
|
|
112
|
+
include.push(config_relative(`${relative}/**/*.js`));
|
|
113
|
+
include.push(config_relative(`${relative}/**/*.ts`));
|
|
114
|
+
include.push(config_relative(`${relative}/**/*.svelte`));
|
|
115
|
+
}
|
|
173
116
|
|
|
174
117
|
/** @type {Record<string, string[]>} */
|
|
175
118
|
const paths = {};
|
|
@@ -212,7 +155,7 @@ function write_tsconfig(config, cwd = process.cwd()) {
|
|
|
212
155
|
target: 'esnext'
|
|
213
156
|
},
|
|
214
157
|
include,
|
|
215
|
-
exclude: [config_relative('node_modules/**'), '
|
|
158
|
+
exclude: [config_relative('node_modules/**'), './[!ambient.d.ts]**']
|
|
216
159
|
},
|
|
217
160
|
null,
|
|
218
161
|
'\t'
|
|
@@ -271,4 +214,4 @@ function validate(config, cwd, out, user_file) {
|
|
|
271
214
|
}
|
|
272
215
|
}
|
|
273
216
|
|
|
274
|
-
export {
|
|
217
|
+
export { write as a, write_tsconfig as b, reserved as r, trim as t, valid_identifier as v, write_if_changed as w };
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs__default from 'fs';
|
|
2
|
-
import { l as load_config,
|
|
2
|
+
import { l as load_config, $ } from './chunks/index.js';
|
|
3
3
|
import sade from 'sade';
|
|
4
|
+
import { c as coalesce_to_error } from './chunks/error.js';
|
|
4
5
|
import 'path';
|
|
5
6
|
import 'url';
|
|
6
7
|
|
|
@@ -18,7 +19,7 @@ function handle_error(e) {
|
|
|
18
19
|
process.exit(1);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
22
|
+
const prog = sade('svelte-kit').version('1.0.0-next.395');
|
|
22
23
|
|
|
23
24
|
prog
|
|
24
25
|
.command('package')
|
|
@@ -27,7 +28,7 @@ prog
|
|
|
27
28
|
.action(async ({ watch }) => {
|
|
28
29
|
try {
|
|
29
30
|
const config = await load_config();
|
|
30
|
-
const packaging = await import('./chunks/
|
|
31
|
+
const packaging = await import('./chunks/index2.js');
|
|
31
32
|
|
|
32
33
|
await (watch ? packaging.watch(config) : packaging.build(config));
|
|
33
34
|
} catch (error) {
|
|
@@ -38,7 +39,8 @@ prog
|
|
|
38
39
|
prog
|
|
39
40
|
.command('sync')
|
|
40
41
|
.describe('Synchronise generated files')
|
|
41
|
-
.
|
|
42
|
+
.option('--mode', 'Specify a mode for loading environment variables', 'development')
|
|
43
|
+
.action(async ({ mode }) => {
|
|
42
44
|
if (!fs__default.existsSync('svelte.config.js')) {
|
|
43
45
|
console.warn('Missing svelte.config.js — skipping');
|
|
44
46
|
return;
|
|
@@ -46,8 +48,8 @@ prog
|
|
|
46
48
|
|
|
47
49
|
try {
|
|
48
50
|
const config = await load_config();
|
|
49
|
-
const sync = await import('./chunks/sync.js').then(function (n) { return n.
|
|
50
|
-
sync.all(config);
|
|
51
|
+
const sync = await import('./chunks/sync.js').then(function (n) { return n.f; });
|
|
52
|
+
sync.all(config, mode);
|
|
51
53
|
} catch (error) {
|
|
52
54
|
handle_error(error);
|
|
53
55
|
}
|