Skip to content

Commit

Permalink
.svelte -> .svelte-kit (#1321)
Browse files Browse the repository at this point in the history
* .svelte -> .svelte-kit

* update gitignores in project templates

* changeset

* fix example

* doh

* missed a few
  • Loading branch information
Rich Harris committed May 4, 2021
1 parent bbbbe89 commit 0befffb
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .changeset/flat-turtles-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'create-svelte': patch
'@sveltejs/kit': patch
---

Rename .svelte to .svelte-kit
8 changes: 0 additions & 8 deletions examples/hn.svelte.dev/svelte.config.cjs

This file was deleted.

8 changes: 8 additions & 0 deletions examples/hn.svelte.dev/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import netlify from '@sveltejs/adapter-netlify';

export default {
kit: {
adapter: netlify(),
target: '#svelte'
}
};
8 changes: 4 additions & 4 deletions packages/adapter-cloudflare-workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ module.exports = function () {
utils.rimraf(entrypoint);

utils.log.info('Installing worker dependencies...');
utils.copy(`${__dirname}/files/_package.json`, '.svelte/cloudflare-workers/package.json');
utils.copy(`${__dirname}/files/_package.json`, '.svelte-kit/cloudflare-workers/package.json');

// TODO would be cool if we could make this step unnecessary somehow
const stdout = execSync('npm install', { cwd: '.svelte/cloudflare-workers' });
const stdout = execSync('npm install', { cwd: '.svelte-kit/cloudflare-workers' });
utils.log.info(stdout.toString());

utils.log.minor('Generating worker...');
utils.copy(`${__dirname}/files/entry.js`, '.svelte/cloudflare-workers/entry.js');
utils.copy(`${__dirname}/files/entry.js`, '.svelte-kit/cloudflare-workers/entry.js');

await esbuild.build({
entryPoints: ['.svelte/cloudflare-workers/entry.js'],
entryPoints: ['.svelte-kit/cloudflare-workers/entry.js'],
outfile: `${entrypoint}/index.js`,
bundle: true,
target: 'es2020',
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-netlify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = function () {
const files = join(__dirname, 'files');

utils.log.minor('Generating serverless function...');
utils.copy(join(files, 'entry.js'), '.svelte/netlify/entry.js');
utils.copy(join(files, 'entry.js'), '.svelte-kit/netlify/entry.js');

await esbuild.build({
entryPoints: ['.svelte/netlify/entry.js'],
entryPoints: ['.svelte-kit/netlify/entry.js'],
outfile: join(functions, 'render/index.js'),
bundle: true,
platform: 'node'
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-static/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.DS_Store
node_modules
.svelte
build
.svelte-kit
build
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/prerendered/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
node_modules
/.svelte
/.svelte-kit
/build
/functions
2 changes: 1 addition & 1 deletion packages/adapter-static/test/apps/spa/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
node_modules
/.svelte
/.svelte-kit
/build
/functions
6 changes: 3 additions & 3 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ module.exports = function () {
};

// TODO ideally we'd have something like utils.tmpdir('vercel')
// rather than hardcoding '.svelte/vercel/entry.js', and the
// rather than hardcoding '.svelte-kit/vercel/entry.js', and the
// relative import from that file to output/server/app.js
// would be controlled. at the moment we're exposing
// implementation details that could change
utils.log.minor('Generating serverless function...');
utils.copy(join(files, 'entry.js'), '.svelte/vercel/entry.js');
utils.copy(join(files, 'entry.js'), '.svelte-kit/vercel/entry.js');

await esbuild.build({
entryPoints: ['.svelte/vercel/entry.js'],
entryPoints: ['.svelte-kit/vercel/entry.js'],
outfile: join(dirs.lambda, 'index.js'),
bundle: true,
platform: 'node'
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/default/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
node_modules
/.svelte
/.svelte-kit
/build
/functions
2 changes: 1 addition & 1 deletion packages/create-svelte/templates/skeleton/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
node_modules
/.svelte
/.svelte-kit
/build
/functions
4 changes: 2 additions & 2 deletions packages/kit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
/dist
/assets/runtime
/client/**/*.d.ts
/test/**/.svelte
/test/**/.svelte-kit
/test/**/build
!/src/api/adapt/test/fixtures/*/.svelte
!/src/api/adapt/test/fixtures/*/.svelte-kit
3 changes: 2 additions & 1 deletion packages/kit/src/core/adapt/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dirname, join, resolve as resolve_path } from 'path';
import { parse, pathToFileURL, resolve } from 'url';
import { mkdirp } from '../filesystem/index.js';
import '../../install-fetch.js';
import { SVELTE_KIT } from '../constants.js';

/** @param {string} html */
function clean_html(html) {
Expand Down Expand Up @@ -57,7 +58,7 @@ const REDIRECT = 3;
* all: boolean; // disregard `export const prerender = true`
* }} opts */
export async function prerender({ cwd, out, log, config, build_data, fallback, all }) {
const dir = resolve_path(cwd, '.svelte/output');
const dir = resolve_path(cwd, `${SVELTE_KIT}/output`);

const seen = new Set();

Expand Down
11 changes: 9 additions & 2 deletions packages/kit/src/core/adapt/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import rimraf from 'rimraf';
import glob from 'tiny-glob/sync.js';
import { get_utils } from '../utils.js';
import { fileURLToPath } from 'url';
import { SVELTE_KIT } from '../../constants.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = join(__filename, '..');
Expand Down Expand Up @@ -53,12 +54,18 @@ suite('copy files', () => {
rimraf.sync(dest);
utils.copy_client_files(dest);

assert.equal(glob('**', { cwd: `${cwd}/.svelte/output/client` }), glob('**', { cwd: dest }));
assert.equal(
glob('**', { cwd: `${cwd}/${SVELTE_KIT}/output/client` }),
glob('**', { cwd: dest })
);

rimraf.sync(dest);
utils.copy_server_files(dest);

assert.equal(glob('**', { cwd: `${cwd}/.svelte/output/server` }), glob('**', { cwd: dest }));
assert.equal(
glob('**', { cwd: `${cwd}/${SVELTE_KIT}/output/server` }),
glob('**', { cwd: dest })
);
});

suite('prerender', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/kit/src/core/adapt/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SVELTE_KIT } from '../constants.js';
import { copy, rimraf, mkdirp } from '../filesystem/index.js';
import { prerender } from './prerender.js';

Expand All @@ -20,12 +21,12 @@ export function get_utils({ cwd, config, build_data, log }) {

/** @param {string} dest */
copy_client_files(dest) {
copy(`${cwd}/.svelte/output/client`, dest, (file) => file[0] !== '.');
copy(`${cwd}/${SVELTE_KIT}/output/client`, dest, (file) => file[0] !== '.');
},

/** @param {string} dest */
copy_server_files(dest) {
copy(`${cwd}/.svelte/output/server`, dest, (file) => file[0] !== '.');
copy(`${cwd}/${SVELTE_KIT}/output/server`, dest, (file) => file[0] !== '.');
},

/** @param {string} dest */
Expand Down
9 changes: 5 additions & 4 deletions packages/kit/src/core/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { create_app } from '../../core/create_app/index.js';
import vite from 'vite';
import svelte from '@sveltejs/vite-plugin-svelte';
import glob from 'tiny-glob/sync.js';
import { SVELTE_KIT } from '../constants.js';

/** @param {any} value */
const s = (value) => JSON.stringify(value);
Expand All @@ -26,11 +27,11 @@ const s = (value) => JSON.stringify(value);
* @returns {Promise<import('types/internal').BuildData>}
*/
export async function build(config, { cwd = process.cwd(), runtime = '@sveltejs/kit/ssr' } = {}) {
const build_dir = path.resolve(cwd, '.svelte/build');
const build_dir = path.resolve(cwd, `${SVELTE_KIT}/build`);

rimraf(build_dir);

const output_dir = path.resolve(cwd, '.svelte/output');
const output_dir = path.resolve(cwd, `${SVELTE_KIT}/output`);

const options = {
cwd,
Expand All @@ -46,7 +47,7 @@ export async function build(config, { cwd = process.cwd(), runtime = '@sveltejs/
cwd
}),
output_dir,
client_entry_file: '.svelte/build/runtime/internal/start.js',
client_entry_file: `${SVELTE_KIT}/build/runtime/internal/start.js`,
service_worker_entry_file: resolve_entry(config.kit.files.serviceWorker)
};

Expand Down Expand Up @@ -199,7 +200,7 @@ async function build_server(
) {
let hooks_file = resolve_entry(config.kit.files.hooks);
if (!fs.existsSync(hooks_file)) {
hooks_file = path.resolve(cwd, '.svelte/build/hooks.js');
hooks_file = path.resolve(cwd, `${SVELTE_KIT}/build/hooks.js`);
fs.writeFileSync(hooks_file, '');
}

Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/core/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SVELTE_KIT = '.svelte-kit';
5 changes: 3 additions & 2 deletions packages/kit/src/core/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { copy_assets, get_no_external, resolve_entry } from '../utils.js';
import svelte from '@sveltejs/vite-plugin-svelte';
import { get_server } from '../server/index.js';
import '../../install-fetch.js';
import { SVELTE_KIT } from '../constants.js';

/** @typedef {{ cwd?: string, port: number, host: string, https: boolean, config: import('types/config').ValidatedConfig }} Options */
/** @typedef {import('types/internal').SSRComponent} SSRComponent */
Expand All @@ -30,7 +31,7 @@ class Watcher extends EventEmitter {
super();

this.cwd = cwd;
this.dir = path.resolve(cwd, '.svelte/dev');
this.dir = path.resolve(cwd, `${SVELTE_KIT}/dev`);

this.port = port;
this.host = host;
Expand Down Expand Up @@ -162,7 +163,7 @@ class Watcher extends EventEmitter {
amp: this.config.kit.amp,
dev: true,
entry: {
file: '/.svelte/dev/runtime/internal/start.js',
file: `/${SVELTE_KIT}/dev/runtime/internal/start.js`,
css: [],
js: []
},
Expand Down
5 changes: 3 additions & 2 deletions packages/kit/src/core/start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getRawBody } from '../http/index.js';
import { join, resolve } from 'path';
import { get_server } from '../server/index.js';
import '../../install-fetch.js';
import { SVELTE_KIT } from '../constants.js';

/** @param {string} dir */
const mutable = (dir) =>
Expand All @@ -23,7 +24,7 @@ const mutable = (dir) =>
* }} opts
*/
export async function start({ port, host, config, https: use_https = false, cwd = process.cwd() }) {
const app_file = resolve(cwd, '.svelte/output/server/app.js');
const app_file = resolve(cwd, `${SVELTE_KIT}/output/server/app.js`);

/** @type {import('types/internal').App} */
const app = await import(pathToFileURL(app_file).href);
Expand All @@ -33,7 +34,7 @@ export async function start({ port, host, config, https: use_https = false, cwd
? mutable(config.kit.files.assets)
: (_req, _res, next) => next();

const assets_handler = sirv(resolve(cwd, '.svelte/output/client'), {
const assets_handler = sirv(resolve(cwd, `${SVELTE_KIT}/output/client`), {
maxAge: 31536000,
immutable: true
});
Expand Down

0 comments on commit 0befffb

Please sign in to comment.