@sveltejs/kit 1.0.0-next.348 → 1.0.0-next.350
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/server/index.js +3 -0
- package/dist/chunks/index.js +6 -3
- package/dist/chunks/index2.js +2 -0
- package/dist/chunks/index3.js +1 -2
- package/dist/chunks/index4.js +146 -198
- package/dist/chunks/index5.js +0 -2
- package/dist/chunks/plugin.js +0 -2
- package/dist/chunks/sync.js +2 -2
- package/dist/chunks/write_tsconfig.js +4 -1
- package/dist/cli.js +37 -135
- package/dist/node/polyfills.js +1 -1
- package/package.json +2 -2
- package/dist/chunks/cert.js +0 -28275
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import chokidar from 'chokidar';
|
|
2
2
|
import fs__default from 'fs';
|
|
3
3
|
import path__default, { join, relative } from 'path';
|
|
4
|
-
import { createConnection, createServer } from 'net';
|
|
5
|
-
import { exec as exec$1 } from 'child_process';
|
|
6
4
|
import sade from 'sade';
|
|
7
5
|
import * as vite from 'vite';
|
|
8
6
|
import * as url from 'url';
|
|
@@ -115,109 +113,6 @@ function init(open, close) {
|
|
|
115
113
|
};
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
const host = 'localhost';
|
|
119
|
-
|
|
120
|
-
let promise;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
function weird() {
|
|
124
|
-
if (!promise) {
|
|
125
|
-
promise = get_weird(9000);
|
|
126
|
-
}
|
|
127
|
-
return promise;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function get_weird(port) {
|
|
131
|
-
return new Promise(fulfil => {
|
|
132
|
-
const server = createServer();
|
|
133
|
-
|
|
134
|
-
server.unref();
|
|
135
|
-
|
|
136
|
-
server.on('error', () => {
|
|
137
|
-
fulfil(get_weird(port + 1));
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
server.listen({ host, port }, () => {
|
|
141
|
-
const server2 = createServer();
|
|
142
|
-
|
|
143
|
-
server2.unref();
|
|
144
|
-
|
|
145
|
-
server2.on('error', () => {
|
|
146
|
-
server.close(() => {
|
|
147
|
-
fulfil(false);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
server2.listen({ host, port }, () => {
|
|
152
|
-
server2.close(() => {
|
|
153
|
-
server.close(() => {
|
|
154
|
-
fulfil(true);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function check(port) {
|
|
163
|
-
return weird().then(weird => {
|
|
164
|
-
if (weird) {
|
|
165
|
-
return check_weird(port);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return new Promise(fulfil => {
|
|
169
|
-
const server = createServer();
|
|
170
|
-
|
|
171
|
-
server.unref();
|
|
172
|
-
|
|
173
|
-
server.on('error', () => {
|
|
174
|
-
fulfil(false);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
server.listen({ host, port }, () => {
|
|
178
|
-
server.close(() => {
|
|
179
|
-
fulfil(true);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function check_weird(port) {
|
|
187
|
-
return new Promise(fulfil => {
|
|
188
|
-
const client = createConnection({ host, port }, () => {
|
|
189
|
-
client.end();
|
|
190
|
-
fulfil(false);
|
|
191
|
-
})
|
|
192
|
-
.on('error', () => {
|
|
193
|
-
fulfil(true);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function exec(cmd) {
|
|
199
|
-
return new Promise((fulfil, reject) => {
|
|
200
|
-
exec$1(cmd, (error, stdout, stderr) => {
|
|
201
|
-
if (error) return reject(error);
|
|
202
|
-
fulfil({ stdout, stderr });
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async function blame(port) {
|
|
208
|
-
try {
|
|
209
|
-
const { stdout } = await exec(`lsof -i :${port} -sTCP:LISTEN -Fp`);
|
|
210
|
-
|
|
211
|
-
if (!stdout) return null;
|
|
212
|
-
const pid = parseInt(stdout.slice(1), 10);
|
|
213
|
-
if (isNaN(pid)) throw new Error(`Invalid stdout ${stdout}`);
|
|
214
|
-
|
|
215
|
-
return pid;
|
|
216
|
-
} catch (error) {
|
|
217
|
-
return null;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
116
|
const get_runtime_path = /** @param {import('types').ValidatedKitConfig} config */ (config) =>
|
|
222
117
|
posixify_path(path__default.join(config.outDir, 'runtime'))
|
|
223
118
|
;
|
|
@@ -780,6 +675,8 @@ function error(fn) {
|
|
|
780
675
|
}
|
|
781
676
|
|
|
782
677
|
/**
|
|
678
|
+
* Loads the template (src/app.html by default) and validates that it has the
|
|
679
|
+
* required content.
|
|
783
680
|
* @param {string} cwd
|
|
784
681
|
* @param {import('types').ValidatedConfig} config
|
|
785
682
|
*/
|
|
@@ -811,6 +708,11 @@ function load_template(cwd, config) {
|
|
|
811
708
|
return fs__default.readFileSync(template, 'utf-8');
|
|
812
709
|
}
|
|
813
710
|
|
|
711
|
+
/**
|
|
712
|
+
* Loads and validates svelte.config.js
|
|
713
|
+
* @param {{ cwd?: string }} options
|
|
714
|
+
* @returns {Promise<import('types').ValidatedConfig>}
|
|
715
|
+
*/
|
|
814
716
|
async function load_config({ cwd = process.cwd() } = {}) {
|
|
815
717
|
const config_file = path__default.join(cwd, 'svelte.config.js');
|
|
816
718
|
|
|
@@ -849,6 +751,7 @@ function validate_config(config) {
|
|
|
849
751
|
}
|
|
850
752
|
|
|
851
753
|
/**
|
|
754
|
+
* Ensures the user does not override any config values that SvelteKit must control.
|
|
852
755
|
* @param {string[]} conflicts - array of conflicts in dotted notation
|
|
853
756
|
* @param {string=} pathPrefix - prepended in front of the path
|
|
854
757
|
* @param {string=} scope - used to prefix the whole error message
|
|
@@ -908,7 +811,7 @@ async function launch(port, https, base) {
|
|
|
908
811
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
|
|
909
812
|
}
|
|
910
813
|
|
|
911
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
814
|
+
const prog = sade('svelte-kit').version('1.0.0-next.350');
|
|
912
815
|
|
|
913
816
|
prog
|
|
914
817
|
.command('dev')
|
|
@@ -927,15 +830,16 @@ prog
|
|
|
927
830
|
let close;
|
|
928
831
|
|
|
929
832
|
async function start() {
|
|
930
|
-
const svelte_config = await load_config();
|
|
931
833
|
const { plugins } = await import('./chunks/plugin.js');
|
|
834
|
+
const svelte_config = await load_config();
|
|
932
835
|
const vite_config = await svelte_config.kit.vite();
|
|
933
836
|
|
|
934
837
|
/** @type {import('vite').UserConfig} */
|
|
935
838
|
const config = {
|
|
839
|
+
...vite_config,
|
|
936
840
|
plugins: [...(vite_config.plugins || []), plugins(svelte_config)]
|
|
937
841
|
};
|
|
938
|
-
config.server = {};
|
|
842
|
+
config.server = config.server || {};
|
|
939
843
|
|
|
940
844
|
// optional config from command-line flags
|
|
941
845
|
// these should take precedence, but not print conflict warnings
|
|
@@ -1064,15 +968,34 @@ prog
|
|
|
1064
968
|
try {
|
|
1065
969
|
if (H) throw new Error('-H is no longer supported — use --https instead');
|
|
1066
970
|
|
|
1067
|
-
await check_port(port);
|
|
1068
|
-
|
|
1069
971
|
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
|
1070
972
|
|
|
1071
|
-
const {
|
|
973
|
+
const { sveltekit_plugin } = await import('./chunks/index4.js');
|
|
974
|
+
const svelte_config = await load_config();
|
|
975
|
+
const vite_config = await svelte_config.kit.vite();
|
|
976
|
+
|
|
977
|
+
/** @type {import('vite').UserConfig} */
|
|
978
|
+
const config = {
|
|
979
|
+
...vite_config,
|
|
980
|
+
plugins: [...(vite_config.plugins || []), sveltekit_plugin]
|
|
981
|
+
};
|
|
982
|
+
config.preview = config.preview || {};
|
|
983
|
+
|
|
984
|
+
// optional config from command-line flags
|
|
985
|
+
// these should take precedence, but not print conflict warnings
|
|
986
|
+
if (host) {
|
|
987
|
+
config.preview.host = host;
|
|
988
|
+
}
|
|
989
|
+
if (https) {
|
|
990
|
+
config.preview.https = https;
|
|
991
|
+
}
|
|
992
|
+
if (port) {
|
|
993
|
+
config.preview.port = port;
|
|
994
|
+
}
|
|
1072
995
|
|
|
1073
|
-
const
|
|
996
|
+
const preview_server = await vite.preview(config);
|
|
1074
997
|
|
|
1075
|
-
welcome({ port, host, https, open, base: config.
|
|
998
|
+
welcome({ port, host, https, open, base: preview_server.config.base });
|
|
1076
999
|
} catch (error) {
|
|
1077
1000
|
handle_error(error);
|
|
1078
1001
|
}
|
|
@@ -1113,27 +1036,6 @@ prog
|
|
|
1113
1036
|
|
|
1114
1037
|
prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
|
|
1115
1038
|
|
|
1116
|
-
/** @param {number} port */
|
|
1117
|
-
async function check_port(port) {
|
|
1118
|
-
if (await check(port)) {
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
console.error($.bold().red(`Port ${port} is occupied`));
|
|
1122
|
-
const n = await blame(port);
|
|
1123
|
-
if (n) {
|
|
1124
|
-
// prettier-ignore
|
|
1125
|
-
console.error(
|
|
1126
|
-
`Terminate process ${$.bold(n)} or specify a different port with ${$.bold('--port')}\n`
|
|
1127
|
-
);
|
|
1128
|
-
} else {
|
|
1129
|
-
// prettier-ignore
|
|
1130
|
-
console.error(
|
|
1131
|
-
`Terminate the process occupying the port or specify a different port with ${$.bold('--port')}\n`
|
|
1132
|
-
);
|
|
1133
|
-
}
|
|
1134
|
-
process.exit(1);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
1039
|
/**
|
|
1138
1040
|
* @param {{
|
|
1139
1041
|
* open: boolean;
|
|
@@ -1149,7 +1051,7 @@ async function check_port(port) {
|
|
|
1149
1051
|
function welcome({ port, host, https, open, base, loose, allow, cwd }) {
|
|
1150
1052
|
if (open) launch(port, https, base);
|
|
1151
1053
|
|
|
1152
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
1054
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.350'}\n`));
|
|
1153
1055
|
|
|
1154
1056
|
const protocol = https ? 'https:' : 'http:';
|
|
1155
1057
|
const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
|
package/dist/node/polyfills.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltejs/kit",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.350",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/sveltejs/kit",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.46",
|
|
14
14
|
"chokidar": "^3.5.3",
|
|
15
15
|
"sade": "^1.8.1",
|
|
16
|
-
"vite": "^2.9.
|
|
16
|
+
"vite": "^2.9.10"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@playwright/test": "^1.22.2",
|