@sveltejs/kit 1.0.0-next.357 → 1.0.0-next.358

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.
@@ -137,35 +137,6 @@ function logger({ verbose }) {
137
137
  return log;
138
138
  }
139
139
 
140
- /**
141
- * Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
142
- * @param {string} entry
143
- * @returns {string|null}
144
- */
145
- function resolve_entry(entry) {
146
- if (fs__default.existsSync(entry)) {
147
- const stats = fs__default.statSync(entry);
148
- if (stats.isDirectory()) {
149
- return resolve_entry(path__default.join(entry, 'index'));
150
- }
151
-
152
- return entry;
153
- } else {
154
- const dir = path__default.dirname(entry);
155
-
156
- if (fs__default.existsSync(dir)) {
157
- const base = path__default.basename(entry);
158
- const files = fs__default.readdirSync(dir);
159
-
160
- const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base);
161
-
162
- if (found) return path__default.join(dir, found);
163
- }
164
- }
165
-
166
- return null;
167
- }
168
-
169
140
  /** @param {import('types').ManifestData} manifest_data */
170
141
  function get_mime_lookup(manifest_data) {
171
142
  /** @type {Record<string, string>} */
@@ -181,25 +152,6 @@ function get_mime_lookup(manifest_data) {
181
152
  return mime;
182
153
  }
183
154
 
184
- /** @param {import('types').ValidatedKitConfig} config */
185
- function get_aliases(config) {
186
- /** @type {Record<string, string>} */
187
- const alias = {
188
- __GENERATED__: path__default.posix.join(config.outDir, 'generated'),
189
- $app: `${get_runtime_path(config)}/app`,
190
-
191
- // For now, we handle `$lib` specially here rather than make it a default value for
192
- // `config.kit.alias` since it has special meaning for packaging, etc.
193
- $lib: config.files.lib
194
- };
195
-
196
- for (const [key, value] of Object.entries(config.alias)) {
197
- alias[key] = path__default.resolve(value);
198
- }
199
-
200
- return alias;
201
- }
202
-
203
155
  const param_pattern = /^(\.\.\.)?(\w+)(?:=(\w+))?$/;
204
156
 
205
157
  /** @param {string} id */
@@ -1025,4 +977,4 @@ var sync = /*#__PURE__*/Object.freeze({
1025
977
  all: all
1026
978
  });
1027
979
 
1028
- export { get_runtime_path as a, get_mime_lookup as b, all as c, sync as d, get_aliases as g, init as i, logger as l, parse_route_id as p, resolve_entry as r, s, update as u };
980
+ export { get_mime_lookup as a, all as b, sync as c, get_runtime_path as g, init as i, logger as l, parse_route_id as p, s, update as u };
package/dist/cli.js CHANGED
@@ -41,7 +41,7 @@ async function launch(port, https, base) {
41
41
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
42
42
  }
43
43
 
44
- const prog = sade('svelte-kit').version('1.0.0-next.357');
44
+ const prog = sade('svelte-kit').version('1.0.0-next.358');
45
45
 
46
46
  prog
47
47
  .command('dev')
@@ -218,7 +218,7 @@ prog
218
218
 
219
219
  try {
220
220
  const config = await load_config();
221
- const sync = await import('./chunks/sync.js').then(function (n) { return n.d; });
221
+ const sync = await import('./chunks/sync.js').then(function (n) { return n.c; });
222
222
  sync.all(config);
223
223
  } catch (error) {
224
224
  handle_error(error);
@@ -242,7 +242,7 @@ prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
242
242
  function welcome({ port, host, https, open, base, loose, allow, cwd }) {
243
243
  if (open) launch(port, https, base);
244
244
 
245
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.357'}\n`));
245
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.358'}\n`));
246
246
 
247
247
  const protocol = https ? 'https:' : 'http:';
248
248
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/dist/vite.js CHANGED
@@ -6,7 +6,7 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
6
6
  import * as vite from 'vite';
7
7
  import { searchForWorkspaceRoot } from 'vite';
8
8
  import { p as posixify, m as mkdirp, r as rimraf } from './chunks/write_tsconfig.js';
9
- import { g as get_aliases, r as resolve_entry, a as get_runtime_path, s, i as init, u as update, b as get_mime_lookup, p as parse_route_id, c as all, l as logger } from './chunks/sync.js';
9
+ import { g as get_runtime_path, s, i as init, u as update, a as get_mime_lookup, p as parse_route_id, b as all, l as logger } from './chunks/sync.js';
10
10
  import { pathToFileURL, URL as URL$1 } from 'url';
11
11
  import { installPolyfills } from './node/polyfills.js';
12
12
  import * as qs from 'querystring';
@@ -110,6 +110,54 @@ function merge_into(a, b) {
110
110
  }
111
111
  }
112
112
 
113
+ /** @param {import('types').ValidatedKitConfig} config */
114
+ function get_aliases(config) {
115
+ /** @type {Record<string, string>} */
116
+ const alias = {
117
+ __GENERATED__: path__default.posix.join(config.outDir, 'generated'),
118
+ $app: `${get_runtime_path(config)}/app`,
119
+
120
+ // For now, we handle `$lib` specially here rather than make it a default value for
121
+ // `config.kit.alias` since it has special meaning for packaging, etc.
122
+ $lib: config.files.lib
123
+ };
124
+
125
+ for (const [key, value] of Object.entries(config.alias)) {
126
+ alias[key] = path__default.resolve(value);
127
+ }
128
+
129
+ return alias;
130
+ }
131
+
132
+ /**
133
+ * Given an entry point like [cwd]/src/hooks, returns a filename like [cwd]/src/hooks.js or [cwd]/src/hooks/index.js
134
+ * @param {string} entry
135
+ * @returns {string|null}
136
+ */
137
+ function resolve_entry(entry) {
138
+ if (fs__default.existsSync(entry)) {
139
+ const stats = fs__default.statSync(entry);
140
+ if (stats.isDirectory()) {
141
+ return resolve_entry(path__default.join(entry, 'index'));
142
+ }
143
+
144
+ return entry;
145
+ } else {
146
+ const dir = path__default.dirname(entry);
147
+
148
+ if (fs__default.existsSync(dir)) {
149
+ const base = path__default.basename(entry);
150
+ const files = fs__default.readdirSync(dir);
151
+
152
+ const found = files.find((file) => file.replace(/\.[^.]+$/, '') === base);
153
+
154
+ if (found) return path__default.join(dir, found);
155
+ }
156
+ }
157
+
158
+ return null;
159
+ }
160
+
113
161
  /**
114
162
  * @typedef {import('rollup').RollupOutput} RollupOutput
115
163
  * @typedef {import('rollup').OutputChunk} OutputChunk
@@ -2683,6 +2731,7 @@ function scoped(scope, handler) {
2683
2731
 
2684
2732
  const cwd = process.cwd();
2685
2733
 
2734
+ /** @type {Record<string, any>} */
2686
2735
  const enforced_config = {
2687
2736
  base: true,
2688
2737
  build: {
@@ -2752,15 +2801,6 @@ function kit() {
2752
2801
  name: 'vite-plugin-svelte-kit',
2753
2802
 
2754
2803
  async config(config, { command }) {
2755
- const overridden = find_overridden_config(config, enforced_config);
2756
-
2757
- if (overridden.length > 0) {
2758
- console.log(
2759
- $.bold().red('The following Vite config options will be overridden by SvelteKit:')
2760
- );
2761
- console.log(overridden.map((key) => ` - ${key}`).join('\n'));
2762
- }
2763
-
2764
2804
  vite_user_config = config;
2765
2805
  svelte_config = await load_config();
2766
2806
 
@@ -2795,16 +2835,19 @@ function kit() {
2795
2835
  input[name] = resolved;
2796
2836
  });
2797
2837
 
2798
- return get_default_config({
2838
+ const result = get_default_config({
2799
2839
  config: svelte_config,
2800
2840
  input,
2801
2841
  ssr: false,
2802
2842
  outDir: `${paths.client_out_dir}/immutable`
2803
2843
  });
2844
+
2845
+ warn_overridden_config(config, result);
2846
+ return result;
2804
2847
  }
2805
2848
 
2806
2849
  // dev and preview config can be shared
2807
- return {
2850
+ const result = {
2808
2851
  base: '/',
2809
2852
  build: {
2810
2853
  rollupOptions: {
@@ -2820,6 +2863,7 @@ function kit() {
2820
2863
  resolve: {
2821
2864
  alias: get_aliases(svelte_config.kit)
2822
2865
  },
2866
+ root: cwd,
2823
2867
  server: {
2824
2868
  fs: {
2825
2869
  allow: [
@@ -2843,6 +2887,8 @@ function kit() {
2843
2887
  }
2844
2888
  }
2845
2889
  };
2890
+ warn_overridden_config(config, result);
2891
+ return result;
2846
2892
  },
2847
2893
 
2848
2894
  buildStart() {
@@ -2971,17 +3017,22 @@ function kit() {
2971
3017
  if (svelte_config.kit.adapter) {
2972
3018
  const { adapt } = await import('./chunks/index2.js');
2973
3019
  await adapt(svelte_config, build_data, prerendered, { log });
3020
+ } else {
3021
+ console.log($.bold().yellow('\nNo adapter specified'));
3022
+ // prettier-ignore
3023
+ console.log(
3024
+ `See ${$.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
3025
+ );
3026
+ }
3027
+ },
2974
3028
 
2975
- // this is necessary to close any open db connections, etc
3029
+ closeBundle() {
3030
+ if (svelte_config.kit.prerender.enabled) {
3031
+ // this is necessary to close any open db connections, etc.
3032
+ // TODO: prerender in a subprocess so we can exit in isolation
3033
+ // https://github.com/sveltejs/kit/issues/5306
2976
3034
  process.exit(0);
2977
3035
  }
2978
-
2979
- console.log($.bold().yellow('\nNo adapter specified'));
2980
-
2981
- // prettier-ignore
2982
- console.log(
2983
- `See ${$.bold().cyan('https://kit.svelte.dev/docs/adapters')} to learn how to configure your app to run on the platform of your choosing`
2984
- );
2985
3036
  },
2986
3037
 
2987
3038
  async configureServer(vite) {
@@ -2997,17 +3048,33 @@ function kit() {
2997
3048
 
2998
3049
  /**
2999
3050
  * @param {Record<string, any>} config
3000
- * @param {Record<string, any>} enforced_config
3051
+ * @param {Record<string, any>} resolved_config
3001
3052
  * @param {string} [path]
3002
3053
  * @param {string[]} [out] used locally to compute the return value
3003
3054
  */
3004
- function find_overridden_config(config, enforced_config, path = '', out = []) {
3055
+ function warn_overridden_config(config, resolved_config, path = '', out = []) {
3056
+ const overridden = find_overridden_config(config, resolved_config, path, out);
3057
+ if (overridden.length > 0) {
3058
+ console.log(
3059
+ $.bold().red('The following Vite config options will be overridden by SvelteKit:')
3060
+ );
3061
+ console.log(overridden.map((key) => ` - ${key}`).join('\n'));
3062
+ }
3063
+ }
3064
+
3065
+ /**
3066
+ * @param {Record<string, any>} config
3067
+ * @param {Record<string, any>} resolved_config
3068
+ * @param {string} path
3069
+ * @param {string[]} out used locally to compute the return value
3070
+ */
3071
+ function find_overridden_config(config, resolved_config, path, out) {
3005
3072
  for (const key in enforced_config) {
3006
3073
  if (key in config) {
3007
- if (enforced_config[key] === true) {
3074
+ if (enforced_config[key] === true && config[key] !== resolved_config[key]) {
3008
3075
  out.push(path + key);
3009
3076
  } else {
3010
- find_overridden_config(config[key], enforced_config[key], path + key + '.', out);
3077
+ find_overridden_config(config[key], resolved_config[key], path + key + '.', out);
3011
3078
  }
3012
3079
  }
3013
3080
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.357",
3
+ "version": "1.0.0-next.358",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -34,7 +34,7 @@
34
34
  "marked": "^4.0.16",
35
35
  "mime": "^3.0.0",
36
36
  "node-fetch": "^3.2.4",
37
- "port-authority": "^1.2.0",
37
+ "port-authority": "^2.0.1",
38
38
  "rollup": "^2.75.3",
39
39
  "selfsigned": "^2.0.1",
40
40
  "set-cookie-parser": "^2.4.8",