diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f732d16ab43..42ced576d2f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - run: pnpm check Tests: runs-on: ${{ matrix.os }} - timeout-minutes: 10 + timeout-minutes: 15 strategy: fail-fast: false matrix: diff --git a/packages/kit/.gitignore b/packages/kit/.gitignore index e44c6ab79232..4d29456c81bc 100644 --- a/packages/kit/.gitignore +++ b/packages/kit/.gitignore @@ -1,8 +1,7 @@ .DS_Store /node_modules /dist -/assets/runtime -/assets/kit.js +/assets/* /client/**/*.d.ts /test/**/.svelte-kit /test/**/build diff --git a/packages/kit/package.json b/packages/kit/package.json index bc50399d64e1..19feb0bdf4f9 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -57,7 +57,7 @@ "svelte-kit.js" ], "scripts": { - "build": "rollup -c", + "build": "rollup -c && node scripts/cp.js src/runtime/components assets/components", "dev": "rollup -cw", "lint": "eslint --ignore-path .gitignore --ignore-pattern \"src/packaging/test/**\" \"{src,test}/**/*.{ts,mjs,js,svelte}\" && npm run check-format", "check": "tsc && svelte-check --ignore \"src/packaging/test\"", @@ -78,9 +78,6 @@ ".": { "types": "./types/index.d.ts" }, - "./ssr": { - "import": "./dist/ssr.js" - }, "./node": { "import": "./dist/node.js" }, diff --git a/packages/kit/rollup.config.js b/packages/kit/rollup.config.js index ec2f90f5f8f2..f979b01d511b 100644 --- a/packages/kit/rollup.config.js +++ b/packages/kit/rollup.config.js @@ -4,7 +4,7 @@ import replace from '@rollup/plugin-replace'; import resolve from '@rollup/plugin-node-resolve'; import pkg from './package.json'; -(fs.rmSync || fs.rmdirSync)('assets/runtime', { recursive: true, force: true }); +(fs.rmSync || fs.rmdirSync)('assets', { recursive: true, force: true }); const external = [].concat( Object.keys(pkg.dependencies || {}), @@ -17,8 +17,8 @@ const external = [].concat( export default [ { input: { - 'internal/start': 'src/runtime/client/start.js', - 'internal/singletons': 'src/runtime/client/singletons.js', + 'client/start': 'src/runtime/client/start.js', + 'client/singletons': 'src/runtime/client/singletons.js', 'app/navigation': 'src/runtime/app/navigation.js', 'app/stores': 'src/runtime/app/stores.js', 'app/paths': 'src/runtime/app/paths.js', @@ -27,15 +27,15 @@ export default [ env: 'src/runtime/env.js' }, output: { - dir: 'assets/runtime', + dir: 'assets', format: 'esm', chunkFileNames: 'chunks/[name].js', paths: { - ROOT: '../../generated/root.svelte', - MANIFEST: '../../generated/manifest.js' + __ROOT__: '../../generated/root.svelte', + __MANIFEST__: '../../generated/manifest.js' } }, - external: ['svelte', 'svelte/store', 'ROOT', 'MANIFEST'], + external: ['svelte', 'svelte/store', '__ROOT__', '__MANIFEST__'], plugins: [ resolve({ extensions: ['.mjs', '.js', '.ts'] @@ -47,7 +47,7 @@ export default [ input: 'src/runtime/server/index.js', output: { format: 'esm', - file: 'assets/kit.js' + file: 'assets/server/index.js' }, plugins: [ resolve({ @@ -59,9 +59,8 @@ export default [ { input: { cli: 'src/cli.js', - ssr: 'src/runtime/server/index.js', - node: 'src/core/node/index.js', - hooks: 'src/runtime/hooks.js', + node: 'src/node.js', + hooks: 'src/hooks.js', 'install-fetch': 'src/install-fetch.js' }, output: { @@ -70,13 +69,14 @@ export default [ chunkFileNames: 'chunks/[name].js' }, external: (id) => { - return external.includes(id); + return id.startsWith('node:') || external.includes(id); }, plugins: [ replace({ preventAssignment: true, values: { - __VERSION__: pkg.version + __VERSION__: pkg.version, + 'process.env.BUNDLED': 'true' } }), resolve({ diff --git a/packages/kit/scripts/cp.js b/packages/kit/scripts/cp.js new file mode 100755 index 000000000000..bca3e121c516 --- /dev/null +++ b/packages/kit/scripts/cp.js @@ -0,0 +1,5 @@ +import { copy } from '../src/utils/filesystem.js'; + +const [src, dest] = process.argv.slice(2); + +copy(src, dest); diff --git a/packages/kit/src/core/build/build_client.js b/packages/kit/src/core/build/build_client.js index 41e974eaca47..b7198f1fd51e 100644 --- a/packages/kit/src/core/build/build_client.js +++ b/packages/kit/src/core/build/build_client.js @@ -4,8 +4,10 @@ import { svelte } from '@sveltejs/vite-plugin-svelte'; import { deep_merge } from '../../utils/object.js'; import { print_config_conflicts } from '../config/index.js'; import { create_app } from '../create_app/index.js'; -import { copy_assets, posixify } from '../utils.js'; +import { copy_assets, get_aliases } from '../utils.js'; import { create_build, find_deps } from './utils.js'; +import { SVELTE_KIT } from '../constants.js'; +import { posixify } from '../../utils/filesystem.js'; /** * @param {{ @@ -13,7 +15,6 @@ import { create_build, find_deps } from './utils.js'; * assets_base: string; * config: import('types/config').ValidatedConfig * manifest_data: import('types/internal').ManifestData - * build_dir: string; * output_dir: string; * client_entry_file: string; * service_worker_entry_file: string | null; @@ -25,17 +26,16 @@ export async function build_client({ assets_base, config, manifest_data, - build_dir, output_dir, client_entry_file }) { create_app({ manifest_data, - output: build_dir, + output: `${SVELTE_KIT}/generated`, cwd }); - copy_assets(build_dir); + copy_assets(`${SVELTE_KIT}/runtime`); process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : ''; @@ -80,10 +80,7 @@ export async function build_client({ } }, resolve: { - alias: { - $app: path.resolve(`${build_dir}/runtime/app`), - $lib: config.kit.files.lib - } + alias: get_aliases(config) }, plugins: [ svelte({ @@ -103,15 +100,16 @@ export async function build_client({ /** @type {import('vite').Manifest} */ const vite_manifest = JSON.parse(fs.readFileSync(`${client_out_dir}/manifest.json`, 'utf-8')); + const entry = posixify(client_entry_file); const entry_js = new Set(); const entry_css = new Set(); - find_deps(client_entry_file, vite_manifest, entry_js, entry_css); + find_deps(entry, vite_manifest, entry_js, entry_css); return { assets, chunks, entry: { - file: vite_manifest[client_entry_file].file, + file: vite_manifest[entry].file, js: Array.from(entry_js), css: Array.from(entry_css) }, diff --git a/packages/kit/src/core/build/build_server.js b/packages/kit/src/core/build/build_server.js index 8f685ebc0619..355ca8c2cfc6 100644 --- a/packages/kit/src/core/build/build_server.js +++ b/packages/kit/src/core/build/build_server.js @@ -1,10 +1,10 @@ import fs from 'fs'; import path from 'path'; import { svelte } from '@sveltejs/vite-plugin-svelte'; -import { mkdirp } from '../../utils/filesystem.js'; +import { mkdirp, posixify } from '../../utils/filesystem.js'; import { deep_merge } from '../../utils/object.js'; import { load_template, print_config_conflicts } from '../config/index.js'; -import { posixify, resolve_entry } from '../utils.js'; +import { get_aliases, resolve_entry } from '../utils.js'; import { create_build, find_deps } from './utils.js'; import { SVELTE_KIT } from '../constants.js'; import { s } from '../../utils/misc.js'; @@ -12,18 +12,18 @@ import { s } from '../../utils/misc.js'; /** * @param {{ * cwd: string; - * runtime: string; * hooks: string; * config: import('types/config').ValidatedConfig; * has_service_worker: boolean; + * runtime: string; * }} opts * @returns */ -const template = ({ cwd, config, hooks, runtime, has_service_worker }) => ` -import { respond } from '${runtime}'; -import root from './generated/root.svelte'; -import { set_paths, assets, base } from './runtime/paths.js'; -import { set_prerendering } from './runtime/env.js'; +const template = ({ cwd, config, hooks, has_service_worker, runtime }) => ` +import { respond } from '${runtime}/server/index.js'; +import root from '../generated/root.svelte'; +import { set_paths, assets, base } from '${runtime}/paths.js'; +import { set_prerendering } from '${runtime}/env.js'; import * as user_hooks from ${s(hooks)}; const template = ({ head, body, assets }) => ${s(load_template(cwd, config)) @@ -122,7 +122,6 @@ export class App { * service_worker_entry_file: string | null; * service_worker_register: boolean; * }} options - * @param {string} runtime * @param {{ vite_manifest: import('vite').Manifest, assets: import('rollup').OutputAsset[] }} client */ export async function build_server( @@ -136,7 +135,6 @@ export async function build_server( service_worker_entry_file, service_worker_register }, - runtime, client ) { let hooks_file = resolve_entry(config.kit.files.hooks); @@ -184,8 +182,8 @@ export async function build_server( cwd, config, hooks: app_relative(hooks_file), - runtime, - has_service_worker: service_worker_register && !!service_worker_entry_file + has_service_worker: service_worker_register && !!service_worker_entry_file, + runtime: '../runtime' }) ); @@ -231,10 +229,7 @@ export async function build_server( }) ], resolve: { - alias: { - $app: path.resolve(`${build_dir}/runtime/app`), - $lib: config.kit.files.lib - } + alias: get_aliases(config) } }); diff --git a/packages/kit/src/core/build/build_service_worker.js b/packages/kit/src/core/build/build_service_worker.js index d19744b1d076..adf4d1a51982 100644 --- a/packages/kit/src/core/build/build_service_worker.js +++ b/packages/kit/src/core/build/build_service_worker.js @@ -1,9 +1,9 @@ import fs from 'fs'; -import path from 'path'; import vite from 'vite'; import { s } from '../../utils/misc.js'; import { deep_merge } from '../../utils/object.js'; import { print_config_conflicts } from '../config/index.js'; +import { SVELTE_KIT } from '../constants.js'; /** * @param {{ @@ -11,15 +11,13 @@ import { print_config_conflicts } from '../config/index.js'; * assets_base: string; * config: import('types/config').ValidatedConfig * manifest_data: import('types/internal').ManifestData - * build_dir: string; * output_dir: string; - * client_entry_file: string; * service_worker_entry_file: string | null; * }} options * @param {import('vite').Manifest} client_manifest */ export async function build_service_worker( - { cwd, assets_base, config, manifest_data, build_dir, output_dir, service_worker_entry_file }, + { cwd, assets_base, config, manifest_data, output_dir, service_worker_entry_file }, client_manifest ) { // TODO add any assets referenced in template .html file, e.g. favicon? @@ -34,8 +32,10 @@ export async function build_service_worker( } } + const service_worker = `${cwd}/${SVELTE_KIT}/generated/service-worker.js`; + fs.writeFileSync( - `${build_dir}/runtime/service-worker.js`, + service_worker, ` export const timestamp = ${Date.now()}; @@ -76,7 +76,7 @@ export async function build_service_worker( }, resolve: { alias: { - '$service-worker': path.resolve(`${build_dir}/runtime/service-worker`), + '$service-worker': service_worker, $lib: config.kit.files.lib } } diff --git a/packages/kit/src/core/build/index.js b/packages/kit/src/core/build/index.js index 2b2b403ff416..0c6751ae0712 100644 --- a/packages/kit/src/core/build/index.js +++ b/packages/kit/src/core/build/index.js @@ -1,9 +1,9 @@ import fs from 'fs'; import path from 'path'; -import { rimraf } from '../../utils/filesystem.js'; +import { mkdirp, rimraf, posixify } from '../../utils/filesystem.js'; import create_manifest_data from '../create_manifest_data/index.js'; import { SVELTE_KIT } from '../constants.js'; -import { posixify, resolve_entry } from '../utils.js'; +import { runtime, resolve_entry } from '../utils.js'; import { generate_manifest } from '../generate_manifest/index.js'; import { build_service_worker } from './build_service_worker.js'; import { build_client } from './build_client.js'; @@ -11,18 +11,18 @@ import { build_server } from './build_server.js'; /** * @param {import('types/config').ValidatedConfig} config - * @param {{ - * cwd?: string; - * runtime?: string; - * }} [opts] * @returns {Promise} */ -export async function build(config, { cwd = process.cwd(), runtime = './kit.js' } = {}) { - const build_dir = path.resolve(cwd, `${SVELTE_KIT}/build`); +export async function build(config) { + const cwd = process.cwd(); // TODO is this necessary? + const build_dir = path.resolve(`${SVELTE_KIT}/build`); rimraf(build_dir); + mkdirp(build_dir); - const output_dir = path.resolve(cwd, `${SVELTE_KIT}/output`); + const output_dir = path.resolve(`${SVELTE_KIT}/output`); + rimraf(output_dir); + mkdirp(output_dir); const options = { cwd, @@ -35,17 +35,16 @@ export async function build(config, { cwd = process.cwd(), runtime = './kit.js' assets_base: `${config.kit.paths.assets || config.kit.paths.base}/${config.kit.appDir}/`, manifest_data: create_manifest_data({ config, - output: build_dir, cwd }), output_dir, - client_entry_file: `${SVELTE_KIT}/build/runtime/internal/start.js`, + client_entry_file: path.relative(cwd, `${runtime}/client/start.js`), service_worker_entry_file: resolve_entry(config.kit.files.serviceWorker), service_worker_register: config.kit.serviceWorker.register }; const client = await build_client(options); - const server = await build_server(options, runtime, client); + const server = await build_server(options, client); if (options.service_worker_entry_file) { if (config.kit.paths.assets) { diff --git a/packages/kit/src/core/create_app/index.js b/packages/kit/src/core/create_app/index.js index 7367d5d19d42..6dd144706183 100644 --- a/packages/kit/src/core/create_app/index.js +++ b/packages/kit/src/core/create_app/index.js @@ -28,11 +28,10 @@ export function write_if_changed(file, code) { * }} options */ export function create_app({ manifest_data, output, cwd = process.cwd() }) { - const dir = `${output}/generated`; - const base = path.relative(cwd, dir); + const base = path.relative(cwd, output); - write_if_changed(`${dir}/manifest.js`, generate_client_manifest(manifest_data, base)); - write_if_changed(`${dir}/root.svelte`, generate_app(manifest_data)); + write_if_changed(`${output}/manifest.js`, generate_client_manifest(manifest_data, base)); + write_if_changed(`${output}/root.svelte`, generate_app(manifest_data)); } /** @@ -89,6 +88,7 @@ function generate_client_manifest(manifest_data, base) { return `// ${route.a[route.a.length - 1]}\n\t\t[${tuple.join(', ')}]`; } }) + .filter(Boolean) .join(',\n\n\t\t')} ]`.replace(/^\t/gm, ''); diff --git a/packages/kit/src/core/create_manifest_data/index.js b/packages/kit/src/core/create_manifest_data/index.js index 1ed531177da4..12eafda7d940 100644 --- a/packages/kit/src/core/create_manifest_data/index.js +++ b/packages/kit/src/core/create_manifest_data/index.js @@ -1,7 +1,8 @@ import fs from 'fs'; import path from 'path'; import mime from 'mime'; -import { posixify } from '../utils.js'; +import { runtime } from '../utils.js'; +import { posixify } from '../../utils/filesystem.js'; /** * A portion of a file or directory name where the name has been split into @@ -28,12 +29,16 @@ const specials = new Set(['__layout', '__layout.reset', '__error']); /** * @param {{ * config: import('types/config').ValidatedConfig; - * output: string; + * fallback?: string; * cwd?: string; * }} opts * @returns {import('types/internal').ManifestData} */ -export default function create_manifest_data({ config, output, cwd = process.cwd() }) { +export default function create_manifest_data({ + config, + fallback = `${runtime}/components`, + cwd = process.cwd() +}) { /** * @param {string} file_name * @param {string} dir @@ -49,8 +54,8 @@ export default function create_manifest_data({ config, output, cwd = process.cwd /** @type {import('types/internal').RouteData[]} */ const routes = []; - const default_layout = posixify(path.relative(cwd, `${output}/components/layout.svelte`)); - const default_error = posixify(path.relative(cwd, `${output}/components/error.svelte`)); + const default_layout = posixify(path.relative(cwd, `${fallback}/layout.svelte`)); + const default_error = posixify(path.relative(cwd, `${fallback}/error.svelte`)); /** * @param {string} dir diff --git a/packages/kit/src/core/create_manifest_data/index.spec.js b/packages/kit/src/core/create_manifest_data/index.spec.js index 88c010dd9038..349237633d5e 100644 --- a/packages/kit/src/core/create_manifest_data/index.spec.js +++ b/packages/kit/src/core/create_manifest_data/index.spec.js @@ -29,13 +29,13 @@ const create = (dir, extensions = ['.svelte']) => { return create_manifest_data({ config: /** @type {import('types/config').ValidatedConfig} */ (initial), - cwd, - output: cwd + fallback: cwd, + cwd }); }; -const layout = 'components/layout.svelte'; -const error = 'components/error.svelte'; +const layout = 'layout.svelte'; +const error = 'error.svelte'; test('creates routes', () => { const { components, routes } = create('samples/basic'); @@ -230,8 +230,8 @@ test('disallows rest parameters inside segments', () => { pattern: /^\/prefix-(.*?)\/?$/, params: ['...rest'], path: '', - a: ['components/layout.svelte', 'samples/rest-prefix-suffix/prefix-[...rest].svelte'], - b: ['components/error.svelte'] + a: [layout, 'samples/rest-prefix-suffix/prefix-[...rest].svelte'], + b: [error] }, { type: 'endpoint', diff --git a/packages/kit/src/core/dev/index.js b/packages/kit/src/core/dev/index.js index 83c416dcc967..33eb6e81a478 100644 --- a/packages/kit/src/core/dev/index.js +++ b/packages/kit/src/core/dev/index.js @@ -1,11 +1,10 @@ import path from 'path'; import { svelte } from '@sveltejs/vite-plugin-svelte'; import vite from 'vite'; -import { rimraf } from '../../utils/filesystem.js'; import { deep_merge } from '../../utils/object.js'; import { print_config_conflicts } from '../config/index.js'; import { SVELTE_KIT } from '../constants.js'; -import { copy_assets } from '../utils.js'; +import { copy_assets, get_aliases, runtime } from '../utils.js'; import { create_plugin } from './plugin.js'; /** @@ -21,10 +20,7 @@ import { create_plugin } from './plugin.js'; /** @param {Options} opts */ export async function dev({ cwd, port, host, https, config }) { - const output = path.resolve(cwd, `${SVELTE_KIT}/dev`); - - rimraf(output); - copy_assets(output); + copy_assets(`${SVELTE_KIT}/runtime`); const [vite_config] = deep_merge( { @@ -53,16 +49,13 @@ export async function dev({ cwd, port, host, https, config }) { configFile: false, root: cwd, resolve: { - alias: { - $app: path.resolve(`${output}/runtime/app`), - $lib: config.kit.files.lib - } + alias: get_aliases(config) }, build: { rollupOptions: { // Vite dependency crawler needs an explicit JS entry point // eventhough server otherwise works without it - input: path.resolve(`${output}/runtime/internal/start.js`) + input: `${runtime}/client/start.js` } }, plugins: [ @@ -73,7 +66,7 @@ export async function dev({ cwd, port, host, https, config }) { hydratable: !!config.kit.hydrate } }), - await create_plugin(config, output, cwd) + await create_plugin(config, cwd) ], publicDir: config.kit.files.assets, base: '/' diff --git a/packages/kit/src/core/dev/plugin.js b/packages/kit/src/core/dev/plugin.js index 7d03f05b4657..cf25246ebebd 100644 --- a/packages/kit/src/core/dev/plugin.js +++ b/packages/kit/src/core/dev/plugin.js @@ -6,7 +6,7 @@ import { respond } from '../../runtime/server/index.js'; import { __fetch_polyfill } from '../../install-fetch.js'; import { create_app } from '../create_app/index.js'; import create_manifest_data from '../create_manifest_data/index.js'; -import { getRawBody } from '../node/index.js'; +import { getRawBody } from '../../node.js'; import { SVELTE_KIT, SVELTE_KIT_ASSETS } from '../constants.js'; import { get_mime_lookup, resolve_entry } from '../utils.js'; import { coalesce_to_error } from '../../utils/error.js'; @@ -14,11 +14,10 @@ import { load_template } from '../config/index.js'; /** * @param {import('types/config').ValidatedConfig} config - * @param {string} output * @param {string} cwd * @returns {Promise} */ -export async function create_plugin(config, output, cwd) { +export async function create_plugin(config, cwd) { /** @type {import('amphtml-validator').Validator} */ let amp; @@ -37,9 +36,9 @@ export async function create_plugin(config, output, cwd) { let manifest; function update_manifest() { - const manifest_data = create_manifest_data({ config, output, cwd }); + const manifest_data = create_manifest_data({ config, cwd }); - create_app({ manifest_data, output, cwd }); + create_app({ manifest_data, output: `${SVELTE_KIT}/generated`, cwd }); manifest = { appDir: config.kit.appDir, @@ -47,7 +46,7 @@ export async function create_plugin(config, output, cwd) { _: { mime: get_mime_lookup(manifest_data), entry: { - file: `/${SVELTE_KIT}/dev/runtime/internal/start.js`, + file: `/${SVELTE_KIT}/runtime/client/start.js`, css: [], js: [] }, @@ -173,9 +172,8 @@ export async function create_plugin(config, output, cwd) { throw new Error('The serverFetch hook has been renamed to externalFetch.'); } - const root = (await vite.ssrLoadModule(`/${output}/generated/root.svelte`)).default; - - const paths = await vite.ssrLoadModule(`/${SVELTE_KIT}/dev/runtime/paths.js`); + const root = (await vite.ssrLoadModule(`/${SVELTE_KIT}/generated/root.svelte`)).default; + const paths = await vite.ssrLoadModule(`/${SVELTE_KIT}/runtime/paths.js`); paths.set_paths({ base: config.kit.paths.base, diff --git a/packages/kit/src/core/preview/index.js b/packages/kit/src/core/preview/index.js index d04ea8da1506..b833d4eee0a6 100644 --- a/packages/kit/src/core/preview/index.js +++ b/packages/kit/src/core/preview/index.js @@ -4,7 +4,7 @@ import https from 'https'; import { join, resolve } from 'path'; import sirv from 'sirv'; import { pathToFileURL } from 'url'; -import { getRawBody } from '../node/index.js'; +import { getRawBody } from '../../node.js'; import { __fetch_polyfill } from '../../install-fetch.js'; import { SVELTE_KIT, SVELTE_KIT_ASSETS } from '../constants.js'; diff --git a/packages/kit/src/core/utils.js b/packages/kit/src/core/utils.js index 00fc70029611..fba2108ed68a 100644 --- a/packages/kit/src/core/utils.js +++ b/packages/kit/src/core/utils.js @@ -3,10 +3,13 @@ import path from 'path'; import colors from 'kleur'; import { copy } from '../utils/filesystem.js'; import { fileURLToPath } from 'url'; +import { SVELTE_KIT } from './constants.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +export const runtime = path.posix.resolve(`${SVELTE_KIT}/runtime`); + /** @param {string} dest */ export function copy_assets(dest) { let prefix = '..'; @@ -73,11 +76,6 @@ export function resolve_entry(entry) { return null; } -/** @param {string} str */ -export function posixify(str) { - return str.replace(/\\/g, '/'); -} - /** @param {import('./create_app/index.js').ManifestData} manifest_data */ export function get_mime_lookup(manifest_data) { /** @type {Record} */ @@ -92,3 +90,13 @@ export function get_mime_lookup(manifest_data) { return mime; } + +/** @param {import('@sveltejs/kit').ValidatedConfig} config */ +export function get_aliases(config) { + return { + __ROOT__: path.resolve(`${SVELTE_KIT}/generated/root.svelte`), + __MANIFEST__: path.resolve(`${SVELTE_KIT}/generated/manifest.js`), + $app: `${runtime}/app`, + $lib: config.kit.files.lib + }; +} diff --git a/packages/kit/src/runtime/hooks.js b/packages/kit/src/hooks.js similarity index 100% rename from packages/kit/src/runtime/hooks.js rename to packages/kit/src/hooks.js diff --git a/packages/kit/src/core/node/index.js b/packages/kit/src/node.js similarity index 100% rename from packages/kit/src/core/node/index.js rename to packages/kit/src/node.js diff --git a/packages/kit/src/runtime/client/start.js b/packages/kit/src/runtime/client/start.js index 852c4731cb3e..2a5a3e4ae552 100644 --- a/packages/kit/src/runtime/client/start.js +++ b/packages/kit/src/runtime/client/start.js @@ -1,7 +1,7 @@ // @ts-expect-error - doesn't exist yet. generated by Rollup -import Root from 'ROOT'; +import Root from '__ROOT__'; // @ts-expect-error - doesn't exist yet. generated by Rollup -import { routes, fallback } from 'MANIFEST'; +import { routes, fallback } from '__MANIFEST__'; import { Router } from './router.js'; import { Renderer } from './renderer.js'; import { init } from './singletons.js'; diff --git a/packages/kit/assets/components/error.svelte b/packages/kit/src/runtime/components/error.svelte similarity index 100% rename from packages/kit/assets/components/error.svelte rename to packages/kit/src/runtime/components/error.svelte diff --git a/packages/kit/assets/components/layout.svelte b/packages/kit/src/runtime/components/layout.svelte similarity index 100% rename from packages/kit/assets/components/layout.svelte rename to packages/kit/src/runtime/components/layout.svelte diff --git a/packages/kit/src/utils/filesystem.js b/packages/kit/src/utils/filesystem.js index bcc7f59f04c3..fbc201f401bc 100644 --- a/packages/kit/src/utils/filesystem.js +++ b/packages/kit/src/utils/filesystem.js @@ -1,6 +1,5 @@ import fs from 'fs'; import path from 'path'; -import { posixify } from '../core/utils.js'; /** @param {string} dir */ export function mkdirp(dir) { @@ -102,3 +101,8 @@ export function walk(cwd, dirs = false) { return walk_dir(''), all_files; } + +/** @param {string} str */ +export function posixify(str) { + return str.replace(/\\/g, '/'); +} diff --git a/packages/kit/test/apps/basics/src/hooks.js b/packages/kit/test/apps/basics/src/hooks.js index 6f2cdeeb1b6b..d82a0f8379bc 100644 --- a/packages/kit/test/apps/basics/src/hooks.js +++ b/packages/kit/test/apps/basics/src/hooks.js @@ -1,6 +1,6 @@ import fs from 'fs'; import cookie from 'cookie'; -import { sequence } from '../../../../src/runtime/hooks'; +import { sequence } from '../../../../src/hooks'; /** @type {import('@sveltejs/kit').GetSession} */ export function getSession(request) { diff --git a/packages/kit/test/apps/basics/svelte.config.js b/packages/kit/test/apps/basics/svelte.config.js index d5b673464b77..857b5c6b7bd6 100644 --- a/packages/kit/test/apps/basics/svelte.config.js +++ b/packages/kit/test/apps/basics/svelte.config.js @@ -1,3 +1,5 @@ +import path from 'path'; + /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { @@ -10,6 +12,11 @@ const config = { // for CI, we need to explicitly prebundle deps, since // the reload confuses Playwright include: ['cookie', 'marked'] + }, + server: { + fs: { + allow: [path.resolve('../../../src')] + } } }, methodOverride: { diff --git a/packages/kit/test/apps/options-2/svelte.config.js b/packages/kit/test/apps/options-2/svelte.config.js index 5ef4ec64ac44..ae312052d2af 100644 --- a/packages/kit/test/apps/options-2/svelte.config.js +++ b/packages/kit/test/apps/options-2/svelte.config.js @@ -1,8 +1,17 @@ +import path from 'path'; + /** @type {import('@sveltejs/kit').Config} */ const config = { kit: { serviceWorker: { register: false + }, + vite: { + server: { + fs: { + allow: [path.resolve('../../../src')] + } + } } } }; diff --git a/packages/kit/test/apps/options/svelte.config.js b/packages/kit/test/apps/options/svelte.config.js index b497dc1fe625..5891eff90787 100644 --- a/packages/kit/test/apps/options/svelte.config.js +++ b/packages/kit/test/apps/options/svelte.config.js @@ -1,3 +1,5 @@ +import path from 'path'; + /** @type {import('@sveltejs/kit').Config} */ const config = { extensions: ['.jesuslivesineveryone', '.whokilledthemuffinman', '.svelte.md', '.svelte'], @@ -20,7 +22,12 @@ const config = { build: { minify: false }, - clearScreen: false + clearScreen: false, + server: { + fs: { + allow: [path.resolve('../../../src')] + } + } }, paths: { base: '/path-base',