@sveltejs/kit 1.0.0-next.170 → 1.0.0-next.171
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/dist/chunks/index5.js +3 -0
- package/dist/chunks/index6.js +50 -6
- package/dist/cli.js +2 -2
- package/package.json +1 -1
package/dist/chunks/index5.js
CHANGED
|
@@ -360,6 +360,9 @@ async function preview({
|
|
|
360
360
|
render_handler();
|
|
361
361
|
}
|
|
362
362
|
} else {
|
|
363
|
+
if (initial_url.startsWith(config.kit.paths.base)) {
|
|
364
|
+
req.url = initial_url.slice(config.kit.paths.base.length);
|
|
365
|
+
}
|
|
363
366
|
assets_handler(req, res, () => {
|
|
364
367
|
static_handler(req, res, render_handler);
|
|
365
368
|
});
|
package/dist/chunks/index6.js
CHANGED
|
@@ -19202,11 +19202,19 @@ const essential_files = ['README', 'LICENSE', 'CHANGELOG', '.gitignore', '.npmig
|
|
|
19202
19202
|
* @param {string} cwd
|
|
19203
19203
|
*/
|
|
19204
19204
|
async function make_package(config, cwd = process.cwd()) {
|
|
19205
|
-
|
|
19205
|
+
const abs_package_dir = path$2.join(cwd, config.kit.package.dir);
|
|
19206
|
+
rimraf(abs_package_dir);
|
|
19206
19207
|
|
|
19207
19208
|
if (config.kit.package.emitTypes) {
|
|
19208
19209
|
// Generate type definitions first so hand-written types can overwrite generated ones
|
|
19209
19210
|
await emit_dts(config);
|
|
19211
|
+
// Resolve aliases, TS leaves them as-is
|
|
19212
|
+
const files = walk$1(abs_package_dir);
|
|
19213
|
+
for (const file of files) {
|
|
19214
|
+
const filename = path$2.join(abs_package_dir, file);
|
|
19215
|
+
const source = fs.readFileSync(filename, 'utf8');
|
|
19216
|
+
fs.writeFileSync(filename, resolve_$lib_alias(file, source, config));
|
|
19217
|
+
}
|
|
19210
19218
|
}
|
|
19211
19219
|
|
|
19212
19220
|
const files_filter = create_filter(config.kit.package.files);
|
|
@@ -19235,7 +19243,7 @@ async function make_package(config, cwd = process.cwd()) {
|
|
|
19235
19243
|
|
|
19236
19244
|
if (!files_filter(file.replace(/\\/g, '/'))) {
|
|
19237
19245
|
const dts_file = (svelte_ext ? file : file.slice(0, -ext.length)) + '.d.ts';
|
|
19238
|
-
const dts_path = path$2.join(
|
|
19246
|
+
const dts_path = path$2.join(abs_package_dir, dts_file);
|
|
19239
19247
|
if (fs.existsSync(dts_path)) fs.unlinkSync(dts_path);
|
|
19240
19248
|
continue;
|
|
19241
19249
|
}
|
|
@@ -19260,7 +19268,7 @@ async function make_package(config, cwd = process.cwd()) {
|
|
|
19260
19268
|
// TypeScript's declaration emit won't copy over the d.ts files, so we do it here
|
|
19261
19269
|
out_file = file;
|
|
19262
19270
|
out_contents = source;
|
|
19263
|
-
if (fs.existsSync(path$2.join(
|
|
19271
|
+
if (fs.existsSync(path$2.join(abs_package_dir, out_file))) {
|
|
19264
19272
|
console.warn(
|
|
19265
19273
|
'Found already existing file from d.ts generation for ' +
|
|
19266
19274
|
out_file +
|
|
@@ -19274,8 +19282,9 @@ async function make_package(config, cwd = process.cwd()) {
|
|
|
19274
19282
|
out_file = file;
|
|
19275
19283
|
out_contents = source;
|
|
19276
19284
|
}
|
|
19285
|
+
out_contents = resolve_$lib_alias(out_file, out_contents, config);
|
|
19277
19286
|
|
|
19278
|
-
write(path$2.join(
|
|
19287
|
+
write(path$2.join(abs_package_dir, out_file), out_contents);
|
|
19279
19288
|
|
|
19280
19289
|
if (exports_filter(file)) {
|
|
19281
19290
|
const original = `$lib/${file.replace(/\\/g, '/')}`;
|
|
@@ -19322,7 +19331,7 @@ async function make_package(config, cwd = process.cwd()) {
|
|
|
19322
19331
|
}
|
|
19323
19332
|
}
|
|
19324
19333
|
|
|
19325
|
-
write(path$2.join(
|
|
19334
|
+
write(path$2.join(abs_package_dir, 'package.json'), JSON.stringify(pkg, null, ' '));
|
|
19326
19335
|
|
|
19327
19336
|
const whitelist = fs.readdirSync(cwd).filter((file) => {
|
|
19328
19337
|
const lowercased = file.toLowerCase();
|
|
@@ -19332,11 +19341,46 @@ async function make_package(config, cwd = process.cwd()) {
|
|
|
19332
19341
|
const full_path = path$2.join(cwd, pathname);
|
|
19333
19342
|
if (fs.lstatSync(full_path).isDirectory()) continue; // just to be sure
|
|
19334
19343
|
|
|
19335
|
-
const package_path = path$2.join(
|
|
19344
|
+
const package_path = path$2.join(abs_package_dir, pathname);
|
|
19336
19345
|
if (!fs.existsSync(package_path)) fs.copyFileSync(full_path, package_path);
|
|
19337
19346
|
}
|
|
19338
19347
|
}
|
|
19339
19348
|
|
|
19349
|
+
/**
|
|
19350
|
+
* Resolves the `$lib` alias.
|
|
19351
|
+
*
|
|
19352
|
+
* TODO: make this more generic to also handle other aliases the user could have defined
|
|
19353
|
+
* via `kit.vite.resolve.alias`. Also investage how to do this in a more robust way
|
|
19354
|
+
* (right now regex string replacement is used).
|
|
19355
|
+
* For more discussion see https://github.com/sveltejs/kit/pull/2453
|
|
19356
|
+
*
|
|
19357
|
+
* @param {string} file Relative to the lib root
|
|
19358
|
+
* @param {string} content
|
|
19359
|
+
* @param {import('types/config').ValidatedConfig} config
|
|
19360
|
+
* @returns {string}
|
|
19361
|
+
*/
|
|
19362
|
+
function resolve_$lib_alias(file, content, config) {
|
|
19363
|
+
/**
|
|
19364
|
+
* @param {string} match
|
|
19365
|
+
* @param {string} _
|
|
19366
|
+
* @param {string} import_path
|
|
19367
|
+
*/
|
|
19368
|
+
const replace_import_path = (match, _, import_path) => {
|
|
19369
|
+
if (!import_path.startsWith('$lib/')) {
|
|
19370
|
+
return match;
|
|
19371
|
+
}
|
|
19372
|
+
|
|
19373
|
+
const full_path = path$2.join(config.kit.files.lib, file);
|
|
19374
|
+
const full_import_path = path$2.join(config.kit.files.lib, import_path.slice('$lib/'.length));
|
|
19375
|
+
let resolved = path$2.relative(path$2.dirname(full_path), full_import_path).replace(/\\/g, '/');
|
|
19376
|
+
resolved = resolved.startsWith('.') ? resolved : './' + resolved;
|
|
19377
|
+
return match.replace(import_path, resolved);
|
|
19378
|
+
};
|
|
19379
|
+
content = content.replace(/from\s+('|")([^"';,]+?)\1/g, replace_import_path);
|
|
19380
|
+
content = content.replace(/import\s*\(\s*('|")([^"';,]+?)\1\s*\)/g, replace_import_path);
|
|
19381
|
+
return content;
|
|
19382
|
+
}
|
|
19383
|
+
|
|
19340
19384
|
/**
|
|
19341
19385
|
* @param {string} filename
|
|
19342
19386
|
* @param {string} source
|
package/dist/cli.js
CHANGED
|
@@ -822,7 +822,7 @@ async function launch(port, https) {
|
|
|
822
822
|
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
-
const prog = sade('svelte-kit').version('1.0.0-next.
|
|
825
|
+
const prog = sade('svelte-kit').version('1.0.0-next.171');
|
|
826
826
|
|
|
827
827
|
prog
|
|
828
828
|
.command('dev')
|
|
@@ -965,7 +965,7 @@ async function check_port(port) {
|
|
|
965
965
|
function welcome({ port, host, https, open }) {
|
|
966
966
|
if (open) launch(port, https);
|
|
967
967
|
|
|
968
|
-
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.
|
|
968
|
+
console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.171'}\n`));
|
|
969
969
|
|
|
970
970
|
const protocol = https ? 'https:' : 'http:';
|
|
971
971
|
const exposed = host !== 'localhost' && host !== '127.0.0.1';
|