Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Vite 3 #5005

Merged
merged 51 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
fa4ab63
Upgrade to Vite 3
benmccann Jul 5, 2022
be61e1c
Merge branch 'master' into vite-3
Rich-Harris Jul 5, 2022
5fe2ae7
this... seems to work?
Rich-Harris Jul 5, 2022
52afcb2
try this
Rich-Harris Jul 5, 2022
f98e13f
merge
Rich-Harris Jul 5, 2022
8852ce4
remove some more unneeded fixStacktrace options
Rich-Harris Jul 5, 2022
9e68461
Merge branch 'master' into vite-3
benmccann Jul 7, 2022
3aace45
merge master
benmccann Jul 11, 2022
c05dd5d
upgrade to 3.0.0-beta.9
benmccann Jul 11, 2022
4f6c759
update default port
benmccann Jul 12, 2022
400193b
merge master
benmccann Jul 12, 2022
aa787e9
3.0.0 final
benmccann Jul 13, 2022
ab34658
3.0.0 final for site
benmccann Jul 13, 2022
7ee5936
vite-plugin-svelte 1.0.1
benmccann Jul 13, 2022
2674271
bump rollup
benmccann Jul 13, 2022
2b51a0f
merge master
benmccann Jul 13, 2022
495fddc
update enforced_config
Rich-Harris Jul 13, 2022
c7a2e8b
add EnforcedConfig type
Rich-Harris Jul 13, 2022
bc6b112
merge master
benmccann Jul 13, 2022
03e7d40
Merge branch 'vite-3' of github.com:sveltejs/kit into vite-3
benmccann Jul 13, 2022
5c009d8
wow i did a terrible job of implementing this before
Rich-Harris Jul 13, 2022
df6d568
Merge branch 'vite-3' of github.com:sveltejs/kit into vite-3
Rich-Harris Jul 13, 2022
06de105
leave windows paths as-is
Rich-Harris Jul 13, 2022
743fbe8
Revert "leave windows paths as-is"
Rich-Harris Jul 13, 2022
8762468
try this
Rich-Harris Jul 13, 2022
c366895
actually if anything i guess it should be this
Rich-Harris Jul 13, 2022
639e2ac
ugh
Rich-Harris Jul 13, 2022
d9ff77b
merge master
Rich-Harris Jul 13, 2022
ddd4690
Merge branch 'master' into vite-3
Rich-Harris Jul 13, 2022
f1cfe98
merge master
benmccann Jul 13, 2022
0f2d34e
Merge branch 'vite-3' of github.com:sveltejs/kit into vite-3
benmccann Jul 13, 2022
a6033c9
fix firefox test
Rich-Harris Jul 13, 2022
3905374
Merge branch 'vite-3' of github.com:sveltejs/kit into vite-3
Rich-Harris Jul 13, 2022
eccfdcb
add some logging that might help diagnose windows failure
Rich-Harris Jul 13, 2022
a9c1de2
i think this might work
Rich-Harris Jul 13, 2022
24738b4
more logging
Rich-Harris Jul 13, 2022
602e023
maybe this
Rich-Harris Jul 13, 2022
2a975ec
try to simplify logging so that stuff is slightly easier to diagnose
Rich-Harris Jul 13, 2022
9e2d017
argh
Rich-Harris Jul 13, 2022
f91a711
Revert "argh"
benmccann Jul 14, 2022
fcf10cf
Revert "try to simplify logging so that stuff is slightly easier to d…
benmccann Jul 14, 2022
9a90c35
[docs] add JSDocs for Vite build process
benmccann Jul 14, 2022
4f8bbd1
format
benmccann Jul 14, 2022
d9a059c
loop over values instead with `Object.values`
ignatiusmb Jul 14, 2022
7496850
missed a closing bracket
ignatiusmb Jul 14, 2022
77f4abe
fix: ensure isolated testing of create-svelte with local packages (#5…
dominikg Jul 14, 2022
c75a4f7
Merge branch 'master' into vite-3
Rich-Harris Jul 14, 2022
902d730
Merge branch 'master' into vite-docs
Rich-Harris Jul 14, 2022
3be0e9a
merge vite-docs
Rich-Harris Jul 14, 2022
3f5eb6a
remove logging
Rich-Harris Jul 14, 2022
293d564
enforce vite 3
Rich-Harris Jul 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ yarn.lock
.netlify
.turbo
.vercel
.test-tmp
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"private": true,
"scripts": {
"build": "turbo run build --filter=./packages/*",
"test": "turbo run test --filter=./packages/*",
"test": "turbo run test --filter=./packages/* --force",
"check": "turbo run check",
"lint": "turbo run lint",
"format": "turbo run format",
Expand Down Expand Up @@ -37,7 +37,7 @@
"eslint-plugin-svelte3": "^4.0.0",
"playwright": "^1.23.3",
"prettier": "^2.6.2",
"rollup": "^2.75.3",
"rollup": "^2.75.7",
"svelte": "^3.48.0",
"tiny-glob": "^0.2.9",
"turbo": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare-workers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dependencies": {
"@cloudflare/workers-types": "^3.14.0",
"@iarna/toml": "^2.2.5",
"esbuild": "^0.14.42"
"esbuild": "^0.14.48"
},
"devDependencies": {
"@cloudflare/kv-asset-handler": "^0.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@cloudflare/workers-types": "^3.14.0",
"esbuild": "^0.14.42",
"esbuild": "^0.14.48",
"worktop": "0.8.0-next.14"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@iarna/toml": "^2.2.5",
"esbuild": "^0.14.42",
"esbuild": "^0.14.48",
"set-cookie-parser": "^2.4.8",
"tiny-glob": "^0.2.9"
},
Expand All @@ -47,7 +47,7 @@
"@types/node": "^16.11.36",
"@types/set-cookie-parser": "^2.4.2",
"rimraf": "^3.0.2",
"rollup": "^2.75.3",
"rollup": "^2.75.7",
"typescript": "^4.7.4",
"uvu": "^0.5.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"node-fetch": "^3.2.4",
"polka": "^1.0.0-next.22",
"rimraf": "^3.0.2",
"rollup": "^2.75.3",
"rollup": "^2.75.7",
"sirv": "^2.0.2",
"typescript": "^4.7.4",
"uvu": "^0.5.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"svelte": "^3.48.0",
"typescript": "^4.7.4",
"uvu": "^0.5.3",
"vite": "^2.9.13"
"vite": "^3.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/prerendered/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"svelte": "^3.48.0",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"type": "module"
}
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@sveltejs/kit": "workspace:*",
"sirv-cli": "^2.0.2",
"svelte": "^3.48.0",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"type": "module"
}
2 changes: 1 addition & 1 deletion packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@vercel/nft": "^0.20.0",
"esbuild": "^0.14.42"
"esbuild": "^0.14.48"
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"svelte": "^3.48.0",
"svelte-preprocess": "^4.10.6",
"typescript": "^4.7.4",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"type": "module",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@sveltejs/adapter-auto": "next",
"@sveltejs/kit": "next",
"svelte": "^3.46.0",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"type": "module",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@sveltejs/adapter-auto": "workspace:*",
"@sveltejs/kit": "workspace:*",
"svelte": "^3.44.0",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"type": "module"
}
65 changes: 58 additions & 7 deletions packages/create-svelte/test/check.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,81 @@
import fs from 'fs';
import { execSync } from 'child_process';
import path from 'path';
import { test } from 'uvu';
import { create } from '../index.js';
import { fileURLToPath } from 'url';
// use a directory outside of packages to ensure it isn't added to the pnpm workspace
const test_workspace_dir = fileURLToPath(
new URL('../../../.test-tmp/create-svelte/', import.meta.url)
);
const overrides = {};
['kit', 'adapter-auto', 'adapter-cloudflare', 'adapter-netlify', 'adapter-vercel'].forEach(
(pkg) => {
overrides[`@sveltejs/${pkg}`] = `${path.resolve(
test_workspace_dir,
'..',
'..',
'packages',
pkg
)}`; //'workspace:*';
}
);
test.before(() => {
try {
// prepare test pnpm workspace
fs.rmSync(test_workspace_dir, { recursive: true, force: true });
fs.mkdirSync(test_workspace_dir, { recursive: true });
const workspace = {
name: 'svelte-check-test-fake-pnpm-workspace',
private: true,
version: '0.0.0',
pnpm: { overrides },
devDependencies: overrides
};
fs.writeFileSync(
path.join(test_workspace_dir, 'package.json'),
JSON.stringify(workspace, null, '\t')
);
fs.writeFileSync(path.join(test_workspace_dir, 'pnpm-workspace.yaml'), 'packages:\n - ./*\n');

const dir = '.test-tmp';

test.after(() => {
fs.rmSync(dir, { recursive: true, force: true });
// force creation of pnpm-lock.yaml in test workspace
execSync('pnpm install --no-frozen-lockfile', { dir: test_workspace_dir, stdio: 'inherit' });
} catch (e) {
console.error('failed to setup create-svelte test workspace', e);
throw e;
}
});

for (const template of fs.readdirSync('templates')) {
for (const types of ['checkjs', 'typescript']) {
test(`${template}: ${types}`, () => {
const cwd = `${dir}/${template}-${types}`;
const cwd = path.join(test_workspace_dir, `${template}-${types}`);
fs.rmSync(cwd, { recursive: true, force: true });

create(cwd, {
name: 'test',
name: `create-svelte-test-${template}-${types}`,
template,
types,
prettier: false,
eslint: false,
playwright: false
});
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
Object.entries(overrides).forEach(([key, value]) => {
if (pkg.devDependencies?.[key]) {
pkg.devDependencies[key] = value;
}
if (pkg.dependencies?.[key]) {
pkg.dependencies[key] = value;
}
});
fs.writeFileSync(path.join(cwd, 'package.json'), JSON.stringify(pkg, null, '\t'));

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

execSync('npm i && npm run check', { cwd, stdio: 'inherit' });
// run check command separately
execSync('pnpm check', { cwd, stdio: 'inherit' });
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"homepage": "https://kit.svelte.dev",
"type": "module",
"dependencies": {
"@sveltejs/vite-plugin-svelte": "1.0.0-next.49",
"@sveltejs/vite-plugin-svelte": "^1.0.1",
"chokidar": "^3.5.3",
"sade": "^1.8.1"
},
Expand All @@ -33,7 +33,7 @@
"marked": "^4.0.16",
"mime": "^3.0.0",
"node-fetch": "^3.2.4",
"rollup": "^2.75.3",
"rollup": "^2.75.7",
"selfsigned": "^2.0.1",
"set-cookie-parser": "^2.4.8",
"sirv": "^2.0.2",
Expand All @@ -45,11 +45,11 @@
"typescript": "^4.7.4",
"undici": "^5.6.1",
"uvu": "^0.5.3",
"vite": "^2.9.13"
"vite": "^3.0.0"
},
"peerDependencies": {
"svelte": "^3.44.0",
"vite": "^2.9.10"
"vite": "^3.0.0"
},
"bin": {
"svelte-kit": "svelte-kit.js"
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/core/sync/create_manifest_data/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import mime from 'mime';
import { get_runtime_path } from '../../utils.js';
import { get_runtime_directory } from '../../utils.js';
import { posixify } from '../../../utils/filesystem.js';
import { parse_route_id } from '../../../utils/routing.js';

Expand Down Expand Up @@ -58,7 +58,7 @@ const DEFAULT = 'default';
*/
export default function create_manifest_data({
config,
fallback = `${get_runtime_path(config.kit)}/components`,
fallback = `${get_runtime_directory(config.kit)}/components`,
cwd = process.cwd()
}) {
/** @type {import('types').RouteData[]} */
Expand Down
27 changes: 23 additions & 4 deletions packages/kit/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,29 @@ import path from 'path';
import colors from 'kleur';
import { fileURLToPath } from 'url';

export const get_runtime_path = process.env.BUNDLED
? /** @param {import('types').ValidatedKitConfig} config */ (config) =>
posixify_path(path.join(config.outDir, 'runtime'))
: () => posixify_path(fileURLToPath(new URL('../runtime', import.meta.url)));
/**
* Get the prefix for the `runtime` directory, for use with import declarations
* @param {import('types').ValidatedKitConfig} config
*/
export function get_runtime_prefix(config) {
if (process.env.BUNDLED) {
return posixify_path(path.join(config.outDir, 'runtime'));
}

return posixify_path(fileURLToPath(new URL('../runtime', import.meta.url)));
}

/**
* Get the resolved path of the `runtime` directory
* @param {import('types').ValidatedKitConfig} config
*/
export function get_runtime_directory(config) {
if (process.env.BUNDLED) {
return path.join(config.outDir, 'runtime');
}

return fileURLToPath(new URL('../runtime', import.meta.url));
}

/** @param {string} str */
function posixify_path(str) {
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/vite/build/build_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import { mkdirp, posixify } from '../../utils/filesystem.js';
import { get_vite_config, merge_vite_configs, resolve_entry } from '../utils.js';
import { load_template } from '../../core/config/index.js';
import { get_runtime_path } from '../../core/utils.js';
import { get_runtime_directory } from '../../core/utils.js';
import { create_build, find_deps, get_default_config, remove_svelte_kit } from './utils.js';
import { s } from '../../utils/misc.js';

Expand Down Expand Up @@ -177,7 +177,7 @@ export async function build_server(options, client) {
config,
hooks: app_relative(hooks_file),
has_service_worker: config.kit.serviceWorker.register && !!service_worker_entry_file,
runtime: get_runtime_path(config.kit),
runtime: posixify(path.relative(build_dir, get_runtime_directory(config.kit))),
template: load_template(cwd, config)
})
);
Expand Down
7 changes: 5 additions & 2 deletions packages/kit/src/vite/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ export function find_deps(manifest, entry, add_dynamic_css) {
*/
export const get_default_config = function ({ config, input, ssr, outDir }) {
return {
appType: 'custom',
base: assets_base(config.kit),
build: {
cssCodeSplit: true,
manifest: true,
outDir,
polyfillDynamicImport: false,
polyfillModulePreload: false,
rollupOptions: {
input,
output: {
Expand All @@ -110,7 +111,6 @@ export const get_default_config = function ({ config, input, ssr, outDir }) {
resolve: {
alias: get_aliases(config.kit)
},
// @ts-expect-error
ssr: {
// when developing against the Kit src code, we want to ensure that
// our dependencies are bundled so that apps don't need to install
Expand Down Expand Up @@ -138,6 +138,9 @@ export function assets_base(config) {
}

/**
* vite.config.js will contain vite-plugin-svelte-kit, which kicks off the server and service
* worker builds in a hook. When running the server and service worker builds we must remove
* the SvelteKit plugin so that we do not kick off additional instances of these builds.
* @param {import('vite').UserConfig} config
*/
export function remove_svelte_kit(config) {
Expand Down
Loading