@sveltejs/kit 1.3.7 → 1.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -32,8 +32,6 @@
32
32
  "@types/node": "^16.18.6",
33
33
  "@types/sade": "^1.7.4",
34
34
  "@types/set-cookie-parser": "^2.4.2",
35
- "eslint": "^8.33.0",
36
- "eslint-plugin-unicorn": "^45.0.2",
37
35
  "marked": "^4.2.3",
38
36
  "rollup": "^3.7.0",
39
37
  "svelte": "^3.55.1",
@@ -88,7 +86,8 @@
88
86
  "format": "pnpm lint --write",
89
87
  "test": "pnpm test:unit && pnpm test:integration",
90
88
  "test:integration": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test",
91
- "test:cross-platform": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform",
89
+ "test:cross-platform:dev": "pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:dev",
90
+ "test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build",
92
91
  "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
93
92
  "postinstall": "node postinstall.js"
94
93
  }
@@ -139,8 +139,13 @@ export async function sveltekit() {
139
139
  return [...svelte(vite_plugin_svelte_options), ...kit({ svelte_config })];
140
140
  }
141
141
 
142
+ // These variables live outside the `kit()` function because it is re-invoked by each Vite build
143
+
142
144
  let secondary_build_started = false;
143
145
 
146
+ /** @type {import('types').ManifestData} */
147
+ let manifest_data;
148
+
144
149
  /**
145
150
  * Returns the SvelteKit Vite plugin. Vite executes Rollup hooks as well as some of its own.
146
151
  * Background reading is available at:
@@ -164,9 +169,6 @@ function kit({ svelte_config }) {
164
169
  /** @type {import('vite').ConfigEnv} */
165
170
  let vite_config_env;
166
171
 
167
- /** @type {import('types').ManifestData} */
168
- let manifest_data;
169
-
170
172
  /** @type {boolean} */
171
173
  let is_build;
172
174
 
@@ -270,6 +272,10 @@ function kit({ svelte_config }) {
270
272
  'esm-env'
271
273
  ]
272
274
  };
275
+
276
+ if (!secondary_build_started) {
277
+ manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data;
278
+ }
273
279
  } else {
274
280
  new_config.define = {
275
281
  __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: '0',
@@ -386,13 +392,11 @@ function kit({ svelte_config }) {
386
392
  * Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.
387
393
  * @see https://vitejs.dev/guide/api-plugin.html#config
388
394
  */
389
- async config(config, config_env) {
395
+ async config(config) {
390
396
  /** @type {import('vite').UserConfig} */
391
397
  let new_config;
392
398
 
393
399
  if (is_build) {
394
- manifest_data = (await sync.all(svelte_config, config_env.mode)).manifest_data;
395
-
396
400
  const ssr = /** @type {boolean} */ (config.build?.ssr);
397
401
  const prefix = `${kit.appDir}/immutable`;
398
402
 
@@ -554,8 +558,8 @@ function kit({ svelte_config }) {
554
558
 
555
559
  /**
556
560
  * Vite builds a single bundle. We need three bundles: client, server, and service worker.
557
- * The user's package.json scripts will invoke the Vite CLI to execute the client build. We
558
- * then use this hook to kick off builds for the server and service worker.
561
+ * The user's package.json scripts will invoke the Vite CLI to execute the server build. We
562
+ * then use this hook to kick off builds for the client and service worker.
559
563
  */
560
564
  writeBundle: {
561
565
  sequential: true,
@@ -693,6 +697,10 @@ function kit({ svelte_config }) {
693
697
  .cyan('npm run preview')} to preview your production build locally.`
694
698
  );
695
699
 
700
+ // avoid making the manifest available to users
701
+ fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
702
+ fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);
703
+
696
704
  if (kit.adapter) {
697
705
  const { adapt } = await import('../../core/adapt/index.js');
698
706
  await adapt(svelte_config, build_data, metadata, prerendered, prerender_map, log);
@@ -705,9 +713,7 @@ function kit({ svelte_config }) {
705
713
  );
706
714
  }
707
715
 
708
- // avoid making the manifest available to users
709
- fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
710
- fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);
716
+ secondary_build_started = false;
711
717
  };
712
718
  }
713
719
  },
@@ -723,23 +723,22 @@ export function create_client({ target, base }) {
723
723
  const url_changed = current.url ? id !== current.url.pathname + current.url.search : false;
724
724
  const route_changed = current.route ? route.id !== current.route.id : false;
725
725
 
726
- const invalid_server_nodes = loaders.reduce((acc, loader, i) => {
726
+ let parent_invalid = false;
727
+ const invalid_server_nodes = loaders.map((loader, i) => {
727
728
  const previous = current.branch[i];
728
729
 
729
730
  const invalid =
730
731
  !!loader?.[0] &&
731
732
  (previous?.loader !== loader[1] ||
732
- has_changed(
733
- acc.some(Boolean),
734
- route_changed,
735
- url_changed,
736
- previous.server?.uses,
737
- params
738
- ));
739
-
740
- acc.push(invalid);
741
- return acc;
742
- }, /** @type {boolean[]} */ ([]));
733
+ has_changed(parent_invalid, route_changed, url_changed, previous.server?.uses, params));
734
+
735
+ if (invalid) {
736
+ // For the next one
737
+ parent_invalid = true;
738
+ }
739
+
740
+ return invalid;
741
+ });
743
742
 
744
743
  if (invalid_server_nodes.some(Boolean)) {
745
744
  try {
@@ -75,8 +75,8 @@ export type CSRRoute = {
75
75
  id: string;
76
76
  exec(path: string): undefined | Record<string, string>;
77
77
  errors: Array<CSRPageNodeLoader | undefined>;
78
- layouts: Array<[boolean, CSRPageNodeLoader] | undefined>;
79
- leaf: [boolean, CSRPageNodeLoader];
78
+ layouts: Array<[has_server_load: boolean, node_loader: CSRPageNodeLoader] | undefined>;
79
+ leaf: [has_server_load: boolean, node_loader: CSRPageNodeLoader];
80
80
  };
81
81
 
82
82
  export type GetParams = (match: RegExpExecArray) => Record<string, string>;