@sveltejs/kit 1.0.0-next.34 → 1.0.0-next.342
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 +16 -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 +1782 -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 +3367 -0
- package/dist/chunks/cert.js +28154 -0
- package/dist/chunks/constants.js +663 -0
- package/dist/chunks/filesystem.js +110 -0
- package/dist/chunks/index.js +549 -0
- package/dist/chunks/index2.js +1385 -0
- package/dist/chunks/index3.js +118 -0
- package/dist/chunks/index4.js +183 -0
- package/dist/chunks/index5.js +253 -0
- package/dist/chunks/index6.js +15749 -0
- package/dist/chunks/misc.js +78 -0
- package/dist/chunks/multipart-parser.js +450 -0
- package/dist/chunks/object.js +83 -0
- package/dist/chunks/sync.js +858 -0
- package/dist/chunks/write_tsconfig.js +160 -0
- package/dist/cli.js +1097 -64
- package/dist/hooks.js +28 -0
- package/dist/node/polyfills.js +6514 -0
- package/dist/node.js +301 -0
- package/package.json +80 -62
- package/svelte-kit.js +0 -1
- package/types/ambient.d.ts +307 -0
- package/types/index.d.ts +292 -0
- package/types/internal.d.ts +321 -0
- package/types/private.d.ts +235 -0
- package/CHANGELOG.md +0 -362
- 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 -591
- 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 -32
- package/dist/api.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/create_app.js +0 -577
- package/dist/create_app.js.map +0 -1
- package/dist/index.js +0 -329
- package/dist/index.js.map +0 -1
- package/dist/index2.js +0 -14368
- package/dist/index2.js.map +0 -1
- package/dist/index3.js +0 -545
- package/dist/index3.js.map +0 -1
- package/dist/index4.js +0 -71
- package/dist/index4.js.map +0 -1
- package/dist/index5.js +0 -465
- package/dist/index5.js.map +0 -1
- package/dist/index6.js +0 -729
- package/dist/index6.js.map +0 -1
- package/dist/renderer.js +0 -2413
- 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 -57
- package/dist/utils.js.map +0 -1
- package/dist/vite.js +0 -317
- package/dist/vite.js.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import fs__default from 'fs';
|
|
2
|
+
import path__default from 'path';
|
|
3
|
+
import { $ } from '../cli.js';
|
|
4
|
+
import { m as mkdirp, p as posixify } from './filesystem.js';
|
|
5
|
+
|
|
6
|
+
/** @type {Map<string, string>} */
|
|
7
|
+
const previous_contents = new Map();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} file
|
|
11
|
+
* @param {string} code
|
|
12
|
+
*/
|
|
13
|
+
function write_if_changed(file, code) {
|
|
14
|
+
if (code !== previous_contents.get(file)) {
|
|
15
|
+
previous_contents.set(file, code);
|
|
16
|
+
mkdirp(path__default.dirname(file));
|
|
17
|
+
fs__default.writeFileSync(file, code);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** @param {string} str */
|
|
22
|
+
function trim(str) {
|
|
23
|
+
const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
|
|
24
|
+
const pattern = new RegExp(`^${indentation}`, 'gm');
|
|
25
|
+
return str.replace(pattern, '').trim();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** @param {string} file */
|
|
29
|
+
const exists = (file) => fs__default.existsSync(file) && file;
|
|
30
|
+
|
|
31
|
+
/** @param {import('types').ValidatedConfig} config */
|
|
32
|
+
function write_tsconfig(config, cwd = process.cwd()) {
|
|
33
|
+
const out = path__default.join(config.kit.outDir, 'tsconfig.json');
|
|
34
|
+
const user_file =
|
|
35
|
+
exists(path__default.resolve(cwd, 'tsconfig.json')) || exists(path__default.resolve(cwd, 'jsconfig.json'));
|
|
36
|
+
|
|
37
|
+
if (user_file) validate(config, cwd, out, user_file);
|
|
38
|
+
|
|
39
|
+
/** @param {string} file */
|
|
40
|
+
const project_relative = (file) => posixify(path__default.relative('.', file));
|
|
41
|
+
|
|
42
|
+
/** @param {string} file */
|
|
43
|
+
const config_relative = (file) => posixify(path__default.relative(config.kit.outDir, file));
|
|
44
|
+
|
|
45
|
+
const dirs = new Set([
|
|
46
|
+
project_relative(path__default.dirname(config.kit.files.routes)),
|
|
47
|
+
project_relative(path__default.dirname(config.kit.files.lib))
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
/** @type {string[]} */
|
|
51
|
+
const include = [];
|
|
52
|
+
dirs.forEach((dir) => {
|
|
53
|
+
include.push(config_relative(`${dir}/**/*.js`));
|
|
54
|
+
include.push(config_relative(`${dir}/**/*.ts`));
|
|
55
|
+
include.push(config_relative(`${dir}/**/*.svelte`));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
/** @type {Record<string, string[]>} */
|
|
59
|
+
const paths = {};
|
|
60
|
+
const alias = {
|
|
61
|
+
$lib: project_relative(config.kit.files.lib),
|
|
62
|
+
...config.kit.alias
|
|
63
|
+
};
|
|
64
|
+
for (const [key, value] of Object.entries(alias)) {
|
|
65
|
+
if (fs__default.existsSync(project_relative(value))) {
|
|
66
|
+
paths[key] = [project_relative(value)];
|
|
67
|
+
paths[key + '/*'] = [project_relative(value) + '/*'];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
write_if_changed(
|
|
72
|
+
out,
|
|
73
|
+
JSON.stringify(
|
|
74
|
+
{
|
|
75
|
+
compilerOptions: {
|
|
76
|
+
// generated options
|
|
77
|
+
baseUrl: config_relative('.'),
|
|
78
|
+
paths,
|
|
79
|
+
rootDirs: [config_relative('.'), './types'],
|
|
80
|
+
|
|
81
|
+
// essential options
|
|
82
|
+
// svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
|
|
83
|
+
// to enforce using \`import type\` instead of \`import\` for Types.
|
|
84
|
+
importsNotUsedAsValues: 'error',
|
|
85
|
+
// Vite compiles modules one at a time
|
|
86
|
+
isolatedModules: true,
|
|
87
|
+
// TypeScript doesn't know about import usages in the template because it only sees the
|
|
88
|
+
// script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
|
|
89
|
+
preserveValueImports: true,
|
|
90
|
+
|
|
91
|
+
// This is required for svelte-kit package to work as expected
|
|
92
|
+
// Can be overwritten
|
|
93
|
+
lib: ['esnext', 'DOM'],
|
|
94
|
+
moduleResolution: 'node',
|
|
95
|
+
module: 'esnext',
|
|
96
|
+
target: 'esnext'
|
|
97
|
+
},
|
|
98
|
+
include,
|
|
99
|
+
exclude: [config_relative('node_modules/**'), './**']
|
|
100
|
+
},
|
|
101
|
+
null,
|
|
102
|
+
'\t'
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* @param {import('types').ValidatedConfig} config
|
|
109
|
+
* @param {string} cwd
|
|
110
|
+
* @param {string} out
|
|
111
|
+
* @param {string} user_file
|
|
112
|
+
*/
|
|
113
|
+
function validate(config, cwd, out, user_file) {
|
|
114
|
+
// we have to eval the file, since it's not parseable as JSON (contains comments)
|
|
115
|
+
const user_tsconfig_json = fs__default.readFileSync(user_file, 'utf-8');
|
|
116
|
+
const user_tsconfig = (0, eval)(`(${user_tsconfig_json})`);
|
|
117
|
+
|
|
118
|
+
// we need to check that the user's tsconfig extends the framework config
|
|
119
|
+
const extend = user_tsconfig.extends;
|
|
120
|
+
const extends_framework_config = extend && path__default.resolve(cwd, extend) === out;
|
|
121
|
+
|
|
122
|
+
const kind = path__default.basename(user_file);
|
|
123
|
+
|
|
124
|
+
if (extends_framework_config) {
|
|
125
|
+
const { paths: user_paths } = user_tsconfig.compilerOptions || {};
|
|
126
|
+
|
|
127
|
+
if (user_paths && fs__default.existsSync(config.kit.files.lib)) {
|
|
128
|
+
/** @type {string[]} */
|
|
129
|
+
const lib = user_paths['$lib'] || [];
|
|
130
|
+
/** @type {string[]} */
|
|
131
|
+
const lib_ = user_paths['$lib/*'] || [];
|
|
132
|
+
|
|
133
|
+
const missing_lib_paths =
|
|
134
|
+
!lib.some((relative) => path__default.resolve(cwd, relative) === config.kit.files.lib) ||
|
|
135
|
+
!lib_.some(
|
|
136
|
+
(relative) => path__default.resolve(cwd, relative) === path__default.join(config.kit.files.lib, '/*')
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
if (missing_lib_paths) {
|
|
140
|
+
console.warn(
|
|
141
|
+
$
|
|
142
|
+
.bold()
|
|
143
|
+
.yellow(`Your compilerOptions.paths in ${kind} should include the following:`)
|
|
144
|
+
);
|
|
145
|
+
const relative = posixify(path__default.relative('.', config.kit.files.lib));
|
|
146
|
+
console.warn(`{\n "$lib":["${relative}"],\n "$lib/*":["${relative}/*"]\n}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
let relative = posixify(path__default.relative('.', out));
|
|
151
|
+
if (!relative.startsWith('./')) relative = './' + relative;
|
|
152
|
+
|
|
153
|
+
console.warn(
|
|
154
|
+
$.bold().yellow(`Your ${kind} should extend the configuration generated by SvelteKit:`)
|
|
155
|
+
);
|
|
156
|
+
console.warn(`{\n "extends": "${relative}"\n}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export { write_tsconfig as a, trim as t, write_if_changed as w };
|