Skip to content

Commit

Permalink
use src code locally, dist in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Jul 5, 2022
1 parent abd327e commit 12a03e2
Show file tree
Hide file tree
Showing 23 changed files with 56 additions and 32 deletions.
6 changes: 3 additions & 3 deletions packages/kit/src/core/sync/copy_assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from 'path';
import { copy } from '../../utils/filesystem.js';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const filename = fileURLToPath(import.meta.url);
const dirname = path.dirname(filename);

/** @param {string} dest */
export function copy_assets(dest) {
Expand All @@ -13,7 +13,7 @@ export function copy_assets(dest) {
do {
// we jump through these hoops so that this function
// works whether or not it's been bundled
const resolved = path.resolve(__dirname, `${prefix}/assets`);
const resolved = path.resolve(dirname, `${prefix}/assets`);

if (fs.existsSync(resolved)) {
copy(resolved, dest);
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/amp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run test:dev && npm run test:build",
"test:dev": "cross-env DEV=true playwright test",
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/apps/amp/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run test:dev && npm run test:build",
"test:dev": "rimraf test/errors.json && cross-env DEV=true playwright test",
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/apps/basics/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
Expand All @@ -12,7 +12,7 @@ const config = {
// the reload confuses Playwright
include: ['cookie', 'marked']
},
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run test:dev && npm run test:build",
"test:dev": "cross-env DEV=true playwright test",
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/apps/options-2/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/apps/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run test:dev && npm run test:build",
"test:dev": "cross-env DEV=true playwright test",
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/apps/options/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run build && uvu test"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/prerendering/basics/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/disabled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run build"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/prerendering/disabled/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run build && uvu test"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/prerendering/options/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/paths-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check",
"test": "npm run build && uvu test"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/prerendering/paths-base/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/test/prerendering/trailing-slash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"sync": "node ../../cli.js sync",
"prepare": "node ../../cli.js sync",
"check": "tsc && svelte-check"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/test/prerendering/trailing-slash/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as path from 'path';
import { sveltekit } from '@sveltejs/kit/vite';
import { plugin } from '../../utils.js';

/** @type {import('vite').UserConfig} */
const config = {
build: {
minify: false
},
clearScreen: false,
plugins: [sveltekit()],
plugins: [plugin()],
server: {
// TODO: required to support ipv6, remove on vite 3
// https://github.com/vitejs/vite/issues/7075
Expand Down
17 changes: 17 additions & 0 deletions packages/kit/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"paths": {
"@sveltejs/kit": ["../types/index"],
// internal use only
"types": ["../types/internal"]
}
}
}
3 changes: 3 additions & 0 deletions packages/kit/test/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TestType
} from '@playwright/test';
import { IncomingMessage, ServerResponse } from 'http';
import { Plugin } from 'vite';

export const test: TestType<
PlaywrightTestArgs &
Expand Down Expand Up @@ -36,3 +37,5 @@ export const start_server: (
port: number;
close: () => Promise<void>;
}>;

export const plugin: () => Plugin;
4 changes: 4 additions & 0 deletions packages/kit/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,7 @@ export async function start_server(handler, start = 4000) {
}
};
}

export const plugin = process.env.CI
? (await import('../dist/vite.js')).sveltekit
: (await import('../src/vite/index.js')).sveltekit;
4 changes: 2 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
]
},
"check": {
"dependsOn": ["sync"],
"dependsOn": ["prepare"],
"inputs": [
"src/**",
"types/**",
Expand All @@ -34,7 +34,7 @@
"outputs": []
},
"format": {},
"sync": {
"prepare": {
"outputs": [
".svelte-kit/types/**",
".svelte-kit/tsconfig.json",
Expand Down

0 comments on commit 12a03e2

Please sign in to comment.