@sveltejs/kit 1.0.0-next.36 → 1.0.0-next.362
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/README.md +12 -9
- package/assets/app/env.js +28 -0
- package/assets/app/navigation.js +24 -0
- package/assets/app/paths.js +1 -0
- package/assets/app/stores.js +97 -0
- package/assets/client/singletons.js +13 -0
- package/assets/client/start.js +1793 -0
- package/assets/components/error.svelte +18 -2
- package/assets/env.js +8 -0
- package/assets/paths.js +13 -0
- package/assets/server/index.js +3460 -0
- package/dist/chunks/_commonjsHelpers.js +3 -0
- package/dist/chunks/error.js +661 -0
- package/dist/chunks/index.js +15744 -0
- package/dist/chunks/index2.js +210 -0
- package/dist/chunks/multipart-parser.js +445 -0
- package/dist/chunks/sync.js +980 -0
- package/dist/chunks/write_tsconfig.js +274 -0
- package/dist/cli.js +64 -117
- package/dist/hooks.js +28 -0
- package/dist/node/polyfills.js +12237 -0
- package/dist/node.js +5855 -0
- package/dist/vite.js +3141 -0
- package/package.json +100 -55
- package/types/ambient.d.ts +345 -0
- package/types/index.d.ts +293 -0
- package/types/internal.d.ts +318 -0
- package/types/private.d.ts +235 -0
- package/CHANGELOG.md +0 -377
- package/assets/runtime/app/navigation.js +0 -23
- package/assets/runtime/app/navigation.js.map +0 -1
- package/assets/runtime/app/paths.js +0 -2
- package/assets/runtime/app/paths.js.map +0 -1
- package/assets/runtime/app/stores.js +0 -78
- package/assets/runtime/app/stores.js.map +0 -1
- package/assets/runtime/internal/singletons.js +0 -15
- package/assets/runtime/internal/singletons.js.map +0 -1
- package/assets/runtime/internal/start.js +0 -614
- package/assets/runtime/internal/start.js.map +0 -1
- package/assets/runtime/utils-85ebcc60.js +0 -18
- package/assets/runtime/utils-85ebcc60.js.map +0 -1
- package/dist/api.js +0 -28
- package/dist/api.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/create_app.js +0 -502
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -327
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -3497
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -296
- package/dist/index3.js.map +0 -1
- package/dist/index4.js +0 -311
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -221
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -730
- package/dist/index6.js.map +0 -1
- package/dist/renderer.js +0 -2429
- package/dist/renderer.js.map +0 -1
- package/dist/standard.js +0 -100
- package/dist/standard.js.map +0 -1
- package/dist/utils.js +0 -61
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import fs__default from 'fs';
|
|
2
|
+
import path__default from 'path';
|
|
3
|
+
import { $ } from './error.js';
|
|
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
|
+
}
|
|
110
|
+
|
|
111
|
+
/** @type {Map<string, string>} */
|
|
112
|
+
const previous_contents = new Map();
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {string} file
|
|
116
|
+
* @param {string} code
|
|
117
|
+
*/
|
|
118
|
+
function write_if_changed(file, code) {
|
|
119
|
+
if (code !== previous_contents.get(file)) {
|
|
120
|
+
write(file, code);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} file
|
|
126
|
+
* @param {string} code
|
|
127
|
+
*/
|
|
128
|
+
function write(file, code) {
|
|
129
|
+
previous_contents.set(file, code);
|
|
130
|
+
mkdirp(path__default.dirname(file));
|
|
131
|
+
fs__default.writeFileSync(file, code);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** @param {string} str */
|
|
135
|
+
function trim(str) {
|
|
136
|
+
const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
|
|
137
|
+
const pattern = new RegExp(`^${indentation}`, 'gm');
|
|
138
|
+
return str.replace(pattern, '').trim();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** @param {string} file */
|
|
142
|
+
const exists = (file) => fs__default.existsSync(file) && file;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Writes the tsconfig that the user's tsconfig inherits from.
|
|
146
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
147
|
+
*/
|
|
148
|
+
function write_tsconfig(config, cwd = process.cwd()) {
|
|
149
|
+
const out = path__default.join(config.outDir, 'tsconfig.json');
|
|
150
|
+
const user_file =
|
|
151
|
+
exists(path__default.resolve(cwd, 'tsconfig.json')) || exists(path__default.resolve(cwd, 'jsconfig.json'));
|
|
152
|
+
|
|
153
|
+
if (user_file) validate(config, cwd, out, user_file);
|
|
154
|
+
|
|
155
|
+
/** @param {string} file */
|
|
156
|
+
const project_relative = (file) => posixify(path__default.relative('.', file));
|
|
157
|
+
|
|
158
|
+
/** @param {string} file */
|
|
159
|
+
const config_relative = (file) => posixify(path__default.relative(config.outDir, file));
|
|
160
|
+
|
|
161
|
+
const dirs = new Set([
|
|
162
|
+
project_relative(path__default.dirname(config.files.routes)),
|
|
163
|
+
project_relative(path__default.dirname(config.files.lib))
|
|
164
|
+
]);
|
|
165
|
+
|
|
166
|
+
/** @type {string[]} */
|
|
167
|
+
const include = [];
|
|
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
|
+
});
|
|
173
|
+
|
|
174
|
+
/** @type {Record<string, string[]>} */
|
|
175
|
+
const paths = {};
|
|
176
|
+
const alias = {
|
|
177
|
+
$lib: project_relative(config.files.lib),
|
|
178
|
+
...config.alias
|
|
179
|
+
};
|
|
180
|
+
for (const [key, value] of Object.entries(alias)) {
|
|
181
|
+
if (fs__default.existsSync(project_relative(value))) {
|
|
182
|
+
paths[key] = [project_relative(value)];
|
|
183
|
+
paths[key + '/*'] = [project_relative(value) + '/*'];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
write_if_changed(
|
|
188
|
+
out,
|
|
189
|
+
JSON.stringify(
|
|
190
|
+
{
|
|
191
|
+
compilerOptions: {
|
|
192
|
+
// generated options
|
|
193
|
+
baseUrl: config_relative('.'),
|
|
194
|
+
paths,
|
|
195
|
+
rootDirs: [config_relative('.'), './types'],
|
|
196
|
+
|
|
197
|
+
// essential options
|
|
198
|
+
// svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
|
|
199
|
+
// to enforce using \`import type\` instead of \`import\` for Types.
|
|
200
|
+
importsNotUsedAsValues: 'error',
|
|
201
|
+
// Vite compiles modules one at a time
|
|
202
|
+
isolatedModules: true,
|
|
203
|
+
// TypeScript doesn't know about import usages in the template because it only sees the
|
|
204
|
+
// script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
|
|
205
|
+
preserveValueImports: true,
|
|
206
|
+
|
|
207
|
+
// This is required for svelte-kit package to work as expected
|
|
208
|
+
// Can be overwritten
|
|
209
|
+
lib: ['esnext', 'DOM'],
|
|
210
|
+
moduleResolution: 'node',
|
|
211
|
+
module: 'esnext',
|
|
212
|
+
target: 'esnext'
|
|
213
|
+
},
|
|
214
|
+
include,
|
|
215
|
+
exclude: [config_relative('node_modules/**'), './**']
|
|
216
|
+
},
|
|
217
|
+
null,
|
|
218
|
+
'\t'
|
|
219
|
+
)
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {import('types').ValidatedKitConfig} config
|
|
225
|
+
* @param {string} cwd
|
|
226
|
+
* @param {string} out
|
|
227
|
+
* @param {string} user_file
|
|
228
|
+
*/
|
|
229
|
+
function validate(config, cwd, out, user_file) {
|
|
230
|
+
// we have to eval the file, since it's not parseable as JSON (contains comments)
|
|
231
|
+
const user_tsconfig_json = fs__default.readFileSync(user_file, 'utf-8');
|
|
232
|
+
const user_tsconfig = (0, eval)(`(${user_tsconfig_json})`);
|
|
233
|
+
|
|
234
|
+
// we need to check that the user's tsconfig extends the framework config
|
|
235
|
+
const extend = user_tsconfig.extends;
|
|
236
|
+
const extends_framework_config = extend && path__default.resolve(cwd, extend) === out;
|
|
237
|
+
|
|
238
|
+
const kind = path__default.basename(user_file);
|
|
239
|
+
|
|
240
|
+
if (extends_framework_config) {
|
|
241
|
+
const { paths: user_paths } = user_tsconfig.compilerOptions || {};
|
|
242
|
+
|
|
243
|
+
if (user_paths && fs__default.existsSync(config.files.lib)) {
|
|
244
|
+
/** @type {string[]} */
|
|
245
|
+
const lib = user_paths['$lib'] || [];
|
|
246
|
+
/** @type {string[]} */
|
|
247
|
+
const lib_ = user_paths['$lib/*'] || [];
|
|
248
|
+
|
|
249
|
+
const missing_lib_paths =
|
|
250
|
+
!lib.some((relative) => path__default.resolve(cwd, relative) === config.files.lib) ||
|
|
251
|
+
!lib_.some((relative) => path__default.resolve(cwd, relative) === path__default.join(config.files.lib, '/*'));
|
|
252
|
+
|
|
253
|
+
if (missing_lib_paths) {
|
|
254
|
+
console.warn(
|
|
255
|
+
$
|
|
256
|
+
.bold()
|
|
257
|
+
.yellow(`Your compilerOptions.paths in ${kind} should include the following:`)
|
|
258
|
+
);
|
|
259
|
+
const relative = posixify(path__default.relative('.', config.files.lib));
|
|
260
|
+
console.warn(`{\n "$lib":["${relative}"],\n "$lib/*":["${relative}/*"]\n}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
let relative = posixify(path__default.relative('.', out));
|
|
265
|
+
if (!relative.startsWith('./')) relative = './' + relative;
|
|
266
|
+
|
|
267
|
+
console.warn(
|
|
268
|
+
$.bold().yellow(`Your ${kind} should extend the configuration generated by SvelteKit:`)
|
|
269
|
+
);
|
|
270
|
+
console.warn(`{\n "extends": "${relative}"\n}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { write as a, write_tsconfig as b, copy as c, walk as d, mkdirp as m, posixify as p, rimraf as r, trim as t, write_if_changed as w };
|
package/dist/cli.js
CHANGED
|
@@ -1,151 +1,98 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs__default from 'fs';
|
|
2
|
+
import { l as load_config, $, c as coalesce_to_error } from './chunks/error.js';
|
|
2
3
|
import sade from 'sade';
|
|
3
|
-
import { $, l as load_config } from './index.js';
|
|
4
|
-
import 'url';
|
|
5
4
|
import 'path';
|
|
5
|
+
import 'url';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// TODO this is temporary, for the benefit of early adopters
|
|
11
|
-
if (existsSync('snowpack.config.js') || existsSync('snowpack.config.cjs')) {
|
|
12
|
-
// prettier-ignore
|
|
13
|
-
console.error($.bold().red(
|
|
14
|
-
'SvelteKit now uses https://vitejs.dev. Please replace snowpack.config.js with vite.config.js:'
|
|
15
|
-
));
|
|
16
|
-
|
|
17
|
-
// prettier-ignore
|
|
18
|
-
console.error(`
|
|
19
|
-
import { resolve } from 'path';
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
$components: resolve('src/components')
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
`.replace(/^\t{3}/gm, '').replace(/\t/gm, ' ').trim());
|
|
29
|
-
}
|
|
7
|
+
/** @param {unknown} e */
|
|
8
|
+
function handle_error(e) {
|
|
9
|
+
const error = coalesce_to_error(e);
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
return await load_config();
|
|
33
|
-
} catch (error) {
|
|
34
|
-
let message = error.message;
|
|
35
|
-
|
|
36
|
-
if (error.code === 'MODULE_NOT_FOUND') {
|
|
37
|
-
if (existsSync('svelte.config.js')) {
|
|
38
|
-
// TODO this is temporary, for the benefit of early adopters
|
|
39
|
-
message =
|
|
40
|
-
'You must rename svelte.config.js to svelte.config.cjs, and snowpack.config.js to snowpack.config.cjs';
|
|
41
|
-
} else {
|
|
42
|
-
message = 'Missing svelte.config.cjs';
|
|
43
|
-
}
|
|
44
|
-
} else if (error.name === 'SyntaxError') {
|
|
45
|
-
message = 'Malformed svelte.config.cjs';
|
|
46
|
-
}
|
|
11
|
+
if (error.name === 'SyntaxError') throw error;
|
|
47
12
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
13
|
+
console.error($.bold().red(`> ${error.message}`));
|
|
14
|
+
if (error.stack) {
|
|
15
|
+
console.error($.gray(error.stack.split('\n').slice(1).join('\n')));
|
|
51
16
|
}
|
|
52
|
-
}
|
|
53
17
|
|
|
54
|
-
function handle_error(error) {
|
|
55
|
-
console.log($.bold().red(`> ${error.message}`));
|
|
56
|
-
console.log($.gray(error.stack));
|
|
57
18
|
process.exit(1);
|
|
58
19
|
}
|
|
59
20
|
|
|
60
|
-
|
|
61
|
-
const { exec } = await import('child_process');
|
|
62
|
-
exec(`${process.platform == 'win32' ? 'start' : 'open'} http://localhost:${port}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const prog = sade('svelte-kit').version(version);
|
|
21
|
+
const prog = sade('svelte-kit').version('1.0.0-next.362');
|
|
66
22
|
|
|
67
23
|
prog
|
|
68
|
-
.command('
|
|
69
|
-
.describe('
|
|
70
|
-
.option('-
|
|
71
|
-
.
|
|
72
|
-
.action(async ({ port, open }) => {
|
|
73
|
-
process.env.NODE_ENV = 'development';
|
|
74
|
-
const config = await get_config();
|
|
75
|
-
|
|
76
|
-
const { dev } = await import('./index2.js');
|
|
77
|
-
|
|
24
|
+
.command('package')
|
|
25
|
+
.describe('Create a package')
|
|
26
|
+
.option('-w, --watch', 'Rerun when files change', false)
|
|
27
|
+
.action(async ({ watch }) => {
|
|
78
28
|
try {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
watcher.on('stdout', (data) => {
|
|
82
|
-
process.stdout.write(data);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
watcher.on('stderr', (data) => {
|
|
86
|
-
process.stderr.write(data);
|
|
87
|
-
});
|
|
29
|
+
const config = await load_config();
|
|
30
|
+
const packaging = await import('./chunks/index.js');
|
|
88
31
|
|
|
89
|
-
|
|
90
|
-
if (open) launch(watcher.port);
|
|
32
|
+
await (watch ? packaging.watch(config) : packaging.build(config));
|
|
91
33
|
} catch (error) {
|
|
92
34
|
handle_error(error);
|
|
93
35
|
}
|
|
94
36
|
});
|
|
95
37
|
|
|
96
38
|
prog
|
|
97
|
-
.command('
|
|
98
|
-
.describe('
|
|
39
|
+
.command('sync')
|
|
40
|
+
.describe('Synchronise generated files')
|
|
99
41
|
.action(async () => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
42
|
+
if (!fs__default.existsSync('svelte.config.js')) {
|
|
43
|
+
console.warn('Missing svelte.config.js — skipping');
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
104
46
|
|
|
105
47
|
try {
|
|
106
|
-
await
|
|
48
|
+
const config = await load_config();
|
|
49
|
+
const sync = await import('./chunks/sync.js').then(function (n) { return n.c; });
|
|
50
|
+
sync.all(config);
|
|
107
51
|
} catch (error) {
|
|
108
52
|
handle_error(error);
|
|
109
53
|
}
|
|
110
54
|
});
|
|
111
55
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
.option('-o, --open', 'Open a browser tab', false)
|
|
117
|
-
.action(async ({ port, open }) => {
|
|
118
|
-
process.env.NODE_ENV = 'production';
|
|
119
|
-
const config = await get_config();
|
|
120
|
-
|
|
121
|
-
const { start } = await import('./index4.js');
|
|
56
|
+
// TODO remove for 1.0
|
|
57
|
+
replace('dev');
|
|
58
|
+
replace('build');
|
|
59
|
+
replace('preview');
|
|
122
60
|
|
|
123
|
-
|
|
124
|
-
await start({ port, config });
|
|
61
|
+
prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
|
|
125
62
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
63
|
+
/** @param {string} command */
|
|
64
|
+
function replace(command) {
|
|
65
|
+
prog
|
|
66
|
+
.command(command)
|
|
67
|
+
.describe(`No longer available — use vite ${command} instead`)
|
|
68
|
+
.action(async () => {
|
|
69
|
+
const message = `\n> svelte-kit ${command} is no longer available — use vite ${command} instead`;
|
|
70
|
+
console.error($.bold().red(message));
|
|
71
|
+
|
|
72
|
+
const steps = [
|
|
73
|
+
'Install vite as a devDependency with npm/pnpm/etc',
|
|
74
|
+
'Create a vite.config.js with the @sveltejs/kit/vite plugin (see below)',
|
|
75
|
+
`Update your package.json scripts to reference \`vite ${command}\` instead of \`svelte-kit ${command}\``
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
steps.forEach((step, i) => {
|
|
79
|
+
console.error(` ${i + 1}. ${$.cyan(step)}`);
|
|
80
|
+
});
|
|
132
81
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.action(async ({ verbose }) => {
|
|
138
|
-
process.env.NODE_ENV = 'production';
|
|
139
|
-
const config = await get_config();
|
|
82
|
+
console.error(
|
|
83
|
+
`
|
|
84
|
+
${$.grey('// vite.config.js')}
|
|
85
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
140
86
|
|
|
141
|
-
|
|
87
|
+
/** @type {import('vite').UserConfig} */
|
|
88
|
+
const config = {
|
|
89
|
+
plugins: [sveltekit()]
|
|
90
|
+
};
|
|
142
91
|
|
|
143
|
-
|
|
144
|
-
await adapt(config, { verbose });
|
|
145
|
-
} catch (error) {
|
|
146
|
-
handle_error(error);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
92
|
+
export default config;
|
|
149
93
|
|
|
150
|
-
|
|
151
|
-
|
|
94
|
+
`.replace(/^\t{4}/gm, '')
|
|
95
|
+
);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
});
|
|
98
|
+
}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {...import('types').Handle} handlers
|
|
3
|
+
* @returns {import('types').Handle}
|
|
4
|
+
*/
|
|
5
|
+
function sequence(...handlers) {
|
|
6
|
+
const length = handlers.length;
|
|
7
|
+
if (!length) return ({ event, resolve }) => resolve(event);
|
|
8
|
+
|
|
9
|
+
return ({ event, resolve }) => {
|
|
10
|
+
return apply_handle(0, event);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {number} i
|
|
14
|
+
* @param {import('types').RequestEvent} event
|
|
15
|
+
* @returns {import('types').MaybePromise<Response>}
|
|
16
|
+
*/
|
|
17
|
+
function apply_handle(i, event) {
|
|
18
|
+
const handle = handlers[i];
|
|
19
|
+
|
|
20
|
+
return handle({
|
|
21
|
+
event,
|
|
22
|
+
resolve: i < length - 1 ? (event) => apply_handle(i + 1, event) : resolve
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { sequence };
|