Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sveltejs/kit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @sveltejs/kit@1.0.0-next.426
Choose a base ref
...
head repository: sveltejs/kit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @sveltejs/kit@1.0.0-next.427
Choose a head ref
  • 3 commits
  • 7 files changed
  • 4 contributors

Commits on Aug 19, 2022

  1. Copy the full SHA
    51b20ea View commit details
  2. [fix] Throw on invalid browser options (#6086)

    * [fix] Throw on invalid browser options
    
    Throw error if browser.hydrate is false and brower.router is true. The router needs at least the router component to be hydrated, and we currently can't dynamically compile Svelte components as hydratable or not on case-by-case basis
    Closes #4382
    
    * typo
    dummdidumm authored Aug 19, 2022
    Copy the full SHA
    02c7a68 View commit details
  3. Version Packages (next) (#6092)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Aug 19, 2022
    Copy the full SHA
    0467aea View commit details
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -1010,6 +1010,7 @@
"tasty-zebras-guess",
"ten-apricots-admire",
"ten-berries-develop",
"ten-gorillas-itch",
"ten-hairs-perform",
"ten-mice-kneel",
"ten-plants-sleep",
5 changes: 5 additions & 0 deletions .changeset/ten-gorillas-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Throw error if browser.hydrate is false and browser.router is true
22 changes: 14 additions & 8 deletions packages/create-svelte/test/check.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import fs from 'fs';
import { execSync } from 'child_process';
import path from 'path';
import { test } from 'uvu';
import { Writable } from 'stream';
import * as assert from 'uvu/assert';
import { create } from '../index.js';
import { fileURLToPath } from 'url';
@@ -43,7 +44,8 @@ test.before(() => {
fs.writeFileSync(path.join(test_workspace_dir, 'pnpm-workspace.yaml'), 'packages:\n - ./*\n');

// force creation of pnpm-lock.yaml in test workspace
execSync('pnpm install --no-frozen-lockfile', { dir: test_workspace_dir, stdio: 'inherit' });
console.log(`running pnpm install in .test-tmp/create-svelte`);
execSync('pnpm install --no-frozen-lockfile', { dir: test_workspace_dir, stdio: 'ignore' });
} catch (e) {
console.error('failed to setup create-svelte test workspace', e);
throw e;
@@ -84,7 +86,8 @@ for (const template of fs.readdirSync('templates')) {
fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, '\t') + '\n');

// this pnpm install works in the test workspace, which redirects to our local packages again
execSync('pnpm install --no-frozen-lockfile', { cwd, stdio: 'inherit' });
console.log(`running pnpm install in ${cwd}`);
execSync('pnpm install --no-frozen-lockfile', { cwd, stdio: 'ignore' });

// run provided scripts that are non-blocking. All of them should exit with 0
const scripts_to_test = ['prepare', 'check', 'lint', 'build', 'sync'];
@@ -95,17 +98,20 @@ for (const template of fs.readdirSync('templates')) {
}

// not all templates have all scripts
console.group(`${template}-${types}`);
for (const script of Object.keys(pkg.scripts).filter((s) => scripts_to_test.includes(s))) {
const command = `pnpm run ${script}`;
try {
console.log(`executing ${command} in ${cwd}`);
execSync(command, { cwd, stdio: 'inherit' });
execSync(`pnpm run ${script}`, { cwd, stdio: 'pipe' });
console.log(`✅ ${script}`);
} catch (e) {
const msg = `${command} failed in ${cwd}`;
console.error(msg, e);
assert.unreachable(msg);
console.error(`❌ ${script}`);
console.error(`---\nstdout:\n${e.stdout}`);
console.error(`---\nstderr:\n${e.stderr}`);
console.groupEnd();
assert.unreachable(e.message);
}
}
console.groupEnd();
});
}
}
6 changes: 6 additions & 0 deletions packages/kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sveltejs/kit

## 1.0.0-next.427

### Patch Changes

- Throw error if browser.hydrate is false and browser.router is true ([#6086](https://github.com/sveltejs/kit/pull/6086))

## 1.0.0-next.426

### Patch Changes
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/kit",
"version": "1.0.0-next.426",
"version": "1.0.0-next.427",
"repository": {
"type": "git",
"url": "https://github.com/sveltejs/kit",
13 changes: 13 additions & 0 deletions packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
@@ -246,6 +246,19 @@ test('fails if kit.appDir ends with slash', () => {
}, /^config\.kit\.appDir cannot start or end with '\/'. See https:\/\/kit\.svelte\.dev\/docs\/configuration$/);
});

test('fails if browser.hydrate is false and browser.router is true', () => {
assert.throws(() => {
validate_config({
kit: {
browser: {
hydrate: false,
router: true
}
}
});
}, /^config\.kit\.browser\.router cannot be true if config\.kit\.browser\.hydrate is false$/);
});

test('fails if paths.base is not root-relative', () => {
assert.throws(() => {
validate_config({
11 changes: 8 additions & 3 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
@@ -107,9 +107,14 @@ const options = object(
return input;
}),

browser: object({
hydrate: boolean(true),
router: boolean(true)
browser: validate({ hydrate: true, router: true }, (input, keypath) => {
const value = object({ hydrate: boolean(true), router: boolean(true) })(input, keypath);
if (!value.hydrate && value.router) {
throw new Error(
'config.kit.browser.router cannot be true if config.kit.browser.hydrate is false'
);
}
return value;
}),

csp: object({