@sveltejs/kit 1.0.0-next.343 → 1.0.0-next.344

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.
@@ -7,7 +7,7 @@ import fs__default from 'fs';
7
7
  import { URL } from 'url';
8
8
  import { S as SVELTE_KIT_ASSETS, s as sirv } from './constants.js';
9
9
  import { installPolyfills } from '../node/polyfills.js';
10
- import { update, init } from './sync.js';
10
+ import { init, update } from './sync.js';
11
11
  import { getRequest, setResponse } from '../node.js';
12
12
  import { p as posixify } from './filesystem.js';
13
13
  import { p as parse_route_id } from './misc.js';
@@ -38,19 +38,21 @@ const cwd$1 = process.cwd();
38
38
  * @returns {Promise<import('vite').Plugin>}
39
39
  */
40
40
  async function create_plugin(config) {
41
- const runtime = get_runtime_path(config);
42
-
43
- process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
44
-
45
- /** @type {import('types').Respond} */
46
- const respond = (await import(`${runtime}/server/index.js`)).respond;
47
-
48
41
  return {
49
42
  name: 'vite-plugin-svelte-kit',
50
43
 
51
- configureServer(vite) {
44
+ async configureServer(vite) {
52
45
  installPolyfills();
53
46
 
47
+ init(config);
48
+
49
+ const runtime = get_runtime_path(config);
50
+
51
+ process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = '0';
52
+
53
+ /** @type {import('types').Respond} */
54
+ const respond = (await import(`${runtime}/server/index.js`)).respond;
55
+
54
56
  /** @type {import('types').SSRManifest} */
55
57
  let manifest;
56
58
 
@@ -460,8 +462,6 @@ async function dev({ port, host, https }) {
460
462
  /** @type {import('types').ValidatedConfig} */
461
463
  const config = await load_config();
462
464
 
463
- init(config);
464
-
465
465
  const [vite_config] = deep_merge(
466
466
  {
467
467
  server: {
@@ -118,7 +118,7 @@ async function build_service_worker(
118
118
 
119
119
  export const build = [
120
120
  ${Array.from(build)
121
- .map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/${file}`)}`)
121
+ .map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/immutable/${file}`)}`)
122
122
  .join(',\n\t\t\t\t')}
123
123
  ];
124
124
 
@@ -267,7 +267,7 @@ async function build_client({
267
267
  build: {
268
268
  cssCodeSplit: true,
269
269
  manifest: true,
270
- outDir: client_out_dir,
270
+ outDir: `${client_out_dir}/immutable`,
271
271
  polyfillDynamicImport: false,
272
272
  rollupOptions: {
273
273
  input,
@@ -303,7 +303,9 @@ async function build_client({
303
303
  const { chunks, assets } = await create_build(merged_config);
304
304
 
305
305
  /** @type {import('vite').Manifest} */
306
- const vite_manifest = JSON.parse(fs__default.readFileSync(`${client_out_dir}/manifest.json`, 'utf-8'));
306
+ const vite_manifest = JSON.parse(
307
+ fs__default.readFileSync(`${client_out_dir}/immutable/manifest.json`, 'utf-8')
308
+ );
307
309
 
308
310
  const entry = posixify(client_entry_file);
309
311
  const entry_js = new Set();
@@ -388,7 +390,7 @@ export class Server {
388
390
  manifest,
389
391
  method_override: ${s(config.kit.methodOverride)},
390
392
  paths: { base, assets },
391
- prefix: assets + '/${config.kit.appDir}/',
393
+ prefix: assets + '/${config.kit.appDir}/immutable/',
392
394
  prerender: {
393
395
  default: ${config.kit.prerender.default},
394
396
  enabled: ${config.kit.prerender.enabled}
@@ -1312,15 +1314,18 @@ async function build(config, { log }) {
1312
1314
 
1313
1315
  const { manifest_data } = all(config);
1314
1316
 
1317
+ // TODO this is so that Vite's preloading works. Unfortunately, it fails
1318
+ // during `svelte-kit preview`, because we use a local asset path. If Vite
1319
+ // used relative paths, I _think_ this could get fixed. Issue here:
1320
+ // https://github.com/vitejs/vite/issues/2009
1321
+ const { base, assets } = config.kit.paths;
1322
+ const assets_base = `${assets || base}/${config.kit.appDir}/immutable/`;
1323
+
1315
1324
  const options = {
1316
1325
  cwd,
1317
1326
  config,
1318
1327
  build_dir,
1319
- // TODO this is so that Vite's preloading works. Unfortunately, it fails
1320
- // during `svelte-kit preview`, because we use a local asset path. If Vite
1321
- // used relative paths, I _think_ this could get fixed. Issue here:
1322
- // https://github.com/vitejs/vite/issues/2009
1323
- assets_base: `${config.kit.paths.assets || config.kit.paths.base}/${config.kit.appDir}/`,
1328
+ assets_base,
1324
1329
  manifest_data,
1325
1330
  output_dir,
1326
1331
  client_entry_file: path__default.relative(cwd, `${get_runtime_path(config)}/client/start.js`),
@@ -1351,8 +1356,8 @@ async function build(config, { log }) {
1351
1356
 
1352
1357
  const files = new Set([
1353
1358
  ...static_files,
1354
- ...client.chunks.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`),
1355
- ...client.assets.map((chunk) => `${config.kit.appDir}/${chunk.fileName}`)
1359
+ ...client.chunks.map((chunk) => `${config.kit.appDir}/immutable/${chunk.fileName}`),
1360
+ ...client.assets.map((chunk) => `${config.kit.appDir}/immutable/${chunk.fileName}`)
1356
1361
  ]);
1357
1362
 
1358
1363
  // TODO is this right?
@@ -80,8 +80,12 @@ async function preview({ port, host, https: use_https = false }) {
80
80
  scoped(
81
81
  assets,
82
82
  sirv(join(config.kit.outDir, 'output/client'), {
83
- maxAge: 31536000,
84
- immutable: true
83
+ setHeaders: (res, pathname) => {
84
+ // only apply to build directory, not e.g. version.json
85
+ if (pathname.startsWith(`/${config.kit.appDir}/immutable`)) {
86
+ res.setHeader('cache-control', 'public,max-age=31536000,immutable');
87
+ }
88
+ }
85
89
  })
86
90
  ),
87
91
 
@@ -5,7 +5,7 @@ import { $ } from '../cli.js';
5
5
  import chokidar from 'chokidar';
6
6
  import { w as walk$1, m as mkdirp, p as posixify, r as rimraf, c as copy } from './filesystem.js';
7
7
  import { createRequire } from 'module';
8
- import { a as write_tsconfig } from './write_tsconfig.js';
8
+ import { b as write_tsconfig } from './write_tsconfig.js';
9
9
  import 'sade';
10
10
  import 'child_process';
11
11
  import 'net';
@@ -4,7 +4,7 @@ import { g as get_runtime_path } from '../cli.js';
4
4
  import { p as posixify, c as copy, r as rimraf } from './filesystem.js';
5
5
  import { p as parse_route_id, s } from './misc.js';
6
6
  import { fileURLToPath } from 'url';
7
- import { w as write_if_changed, t as trim, a as write_tsconfig } from './write_tsconfig.js';
7
+ import { w as write_if_changed, t as trim, a as write, b as write_tsconfig } from './write_tsconfig.js';
8
8
  import 'sade';
9
9
  import 'child_process';
10
10
  import 'net';
@@ -821,10 +821,7 @@ function write_types(config, manifest_data) {
821
821
  const parts = (key || 'index').split('/');
822
822
  parts.push('__types', /** @type {string} */ (parts.pop()));
823
823
 
824
- write_if_changed(
825
- `${config.kit.outDir}/types/${parts.join('/')}.d.ts`,
826
- content.join('\n').trim()
827
- );
824
+ write(`${config.kit.outDir}/types/${parts.join('/')}.d.ts`, content.join('\n').trim());
828
825
  });
829
826
  }
830
827
 
@@ -12,12 +12,20 @@ const previous_contents = new Map();
12
12
  */
13
13
  function write_if_changed(file, code) {
14
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);
15
+ write(file, code);
18
16
  }
19
17
  }
20
18
 
19
+ /**
20
+ * @param {string} file
21
+ * @param {string} code
22
+ */
23
+ function write(file, code) {
24
+ previous_contents.set(file, code);
25
+ mkdirp(path__default.dirname(file));
26
+ fs__default.writeFileSync(file, code);
27
+ }
28
+
21
29
  /** @param {string} str */
22
30
  function trim(str) {
23
31
  const indentation = /** @type {RegExpExecArray} */ (/\n?(\s*)/.exec(str))[1];
@@ -157,4 +165,4 @@ function validate(config, cwd, out, user_file) {
157
165
  }
158
166
  }
159
167
 
160
- export { write_tsconfig as a, trim as t, write_if_changed as w };
168
+ export { write as a, write_tsconfig as b, trim as t, write_if_changed as w };
package/dist/cli.js CHANGED
@@ -904,7 +904,7 @@ async function launch(port, https, base) {
904
904
  exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}${base}`);
905
905
  }
906
906
 
907
- const prog = sade('svelte-kit').version('1.0.0-next.343');
907
+ const prog = sade('svelte-kit').version('1.0.0-next.344');
908
908
 
909
909
  prog
910
910
  .command('dev')
@@ -1123,7 +1123,7 @@ async function check_port(port) {
1123
1123
  function welcome({ port, host, https, open, base, loose, allow, cwd }) {
1124
1124
  if (open) launch(port, https, base);
1125
1125
 
1126
- console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.343'}\n`));
1126
+ console.log($.bold().cyan(`\n SvelteKit v${'1.0.0-next.344'}\n`));
1127
1127
 
1128
1128
  const protocol = https ? 'https:' : 'http:';
1129
1129
  const exposed = typeof host !== 'undefined' && host !== 'localhost' && host !== '127.0.0.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.343",
3
+ "version": "1.0.0-next.344",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "types": "types/index.d.ts",
63
63
  "engines": {
64
- "node": ">=16"
64
+ "node": ">=16.7"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "rollup -c && node scripts/cp.js src/runtime/components assets/components && npm run types",