Skip to content

Commit

Permalink
kit: Bundle kit in build step (#486)
Browse files Browse the repository at this point in the history
* kit: Bundle kit in build step

* kit: Target es2018 for builds

* Bundle production dependencies into SSR build

* create-svelte changeset

* Simplify vite config
  • Loading branch information
GrygrFlzr authored Mar 12, 2021
1 parent 10d5f65 commit 625747d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-balloons-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-svelte': patch
---

create-svelte: bundle production dependencies for SSR
5 changes: 5 additions & 0 deletions .changeset/weak-swans-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

kit: bundle @sveltejs/kit into built application
11 changes: 10 additions & 1 deletion examples/hn.svelte.dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { resolve } from 'path';
// Consult https://vitejs.dev/config/ to learn about these options
import { join, resolve } from 'path';
import { readFileSync } from 'fs';
import { cwd } from 'process';

const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json')));

/** @type {import('vite').UserConfig} */
export default {
resolve: {
alias: {
$components: resolve('src/components')
}
},
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
};
11 changes: 10 additions & 1 deletion examples/realworld.svelte.dev/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { resolve } from 'path';
// Consult https://vitejs.dev/config/ to learn about these options
import { join, resolve } from 'path';
import { readFileSync } from 'fs';
import { cwd } from 'process';

const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json')));

/** @type {import('vite').UserConfig} */
export default {
resolve: {
alias: {
$common: resolve('src/common'),
$components: resolve('src/components')
}
},
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
};
11 changes: 10 additions & 1 deletion examples/sandbox/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { resolve } from 'path';
// Consult https://vitejs.dev/config/ to learn about these options
import { join, resolve } from 'path';
import { readFileSync } from 'fs';
import { cwd } from 'process';

const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json')));

/** @type {import('vite').UserConfig} */
export default {
build: {
minify: false
Expand All @@ -8,5 +14,8 @@ export default {
alias: {
$components: resolve('src/components')
}
},
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
};
11 changes: 10 additions & 1 deletion examples/svelte-kit-demo/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { resolve } from 'path';
// Consult https://vitejs.dev/config/ to learn about these options
import { join, resolve } from 'path';
import { readFileSync } from 'fs';
import { cwd } from 'process';

const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json')));

/** @type {import('vite').UserConfig} */
export default {
resolve: {
alias: {
$components: resolve('src/components')
}
},
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
};
9 changes: 8 additions & 1 deletion packages/create-svelte/template/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// Consult https://vitejs.dev/config/ to learn about these options
import { resolve } from 'path';
import { join, resolve } from 'path';
import { readFileSync } from 'fs';
import { cwd } from 'process';

const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json')));

/** @type {import('vite').UserConfig} */
export default {
resolve: {
alias: {
$components: resolve('src/components')
}
},
ssr: {
noExternal: Object.keys(pkg.dependencies || {})
}
};
5 changes: 3 additions & 2 deletions packages/kit/src/core/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ async function build_server(
name: 'app',
formats: ['es']
},
outDir: `${output_dir}/server`
outDir: `${output_dir}/server`,
target: 'es2018'
},
resolve: {
alias: {
Expand All @@ -398,7 +399,7 @@ async function build_server(
})
],
ssr: {
noExternal: ['svelte']
noExternal: ['svelte', '@sveltejs/kit']
},
optimizeDeps: {
entries: []
Expand Down

0 comments on commit 625747d

Please sign in to comment.