Skip to content

Commit

Permalink
add --watch flag to svelte-kit package (#4658)
Browse files Browse the repository at this point in the history
* naive watch mode

* simplify

* rename function

* move code around a bit

* resolve package.dir earlier

* add unlink_all helper

* simplify

* Revert "resolve package.dir earlier"

This reverts commit ce80b88.

* use resolved path

* tidy up

* tidy up

* tidy up

* placeholder watch logic

* use unlink_all helper

* move resolving logic into emit_dts

* tidy up some more

* move logic around

* tidy up

* tidy up

* group events

* fix jsconfig resolution

* tests

* changeset

* await initial build

* lint

* update prettier config

* timeouts

* remove package dir from repo

* fix gitignore

* wtf

* more debugging

* gah

* skip watch tests in CI

* add some debugging

* fix windows tests

* use posixify utility

* Update packages/kit/src/packaging/index.js

Co-authored-by: Ignatius Bagus <[email protected]>

* Update packages/kit/src/packaging/test/fixtures/files-exclude/svelte.config.js

Co-authored-by: Ignatius Bagus <[email protected]>

* update docs

Co-authored-by: Ignatius Bagus <[email protected]>
  • Loading branch information
Rich-Harris and ignatiusmb authored Apr 21, 2022
1 parent 2d2f73c commit 15516b4
Show file tree
Hide file tree
Showing 25 changed files with 580 additions and 298 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-laws-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Add --watch flag to svelte-kit package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test-results/
package-lock.json
yarn.lock
/packages/create-svelte/template/CHANGELOG.md
/packages/kit/src/packaging/test/watch/package
/documentation/types.js
.env
.vercel_build_output
Expand Down
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"files": [
"**/CHANGELOG.md",
"packages/kit/src/packaging/test/fixtures/**/expected/**/*",
"packages/kit/src/packaging/test/watch/expected/**/*",
"packages/kit/src/packaging/test/watch/package/**/*",
"packages/kit/src/core/build/prerender/fixtures/**/*"
],
"options": {
Expand Down
4 changes: 3 additions & 1 deletion documentation/docs/13-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@ Like `svelte-kit dev`, it accepts the following options:

> `svelte-kit package` is currently experimental and is not subject to Semantic Versioning rules. Non-backward compatible changes may occur in any future release.
For package authors, see [packaging](/docs/packaging).
For package authors, see [packaging](/docs/packaging). `svelte-kit package` accepts the following options:

- `-w`/`--watch` — watch files in `src/lib` for changes and rebuild the package
1 change: 1 addition & 0 deletions packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"type": "module",
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.32",
"chokidar": "^3.5.3",
"sade": "^1.7.4",
"vite": "^2.9.0"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ prog
prog
.command('package')
.describe('Create a package')
.action(async () => {
.option('-w, --watch', 'Rerun when files change', false)
.action(async ({ watch }) => {
try {
const config = await load_config();
const packaging = await import('./packaging/index.js');

const { make_package } = await import('./packaging/index.js');

await make_package(config);
await (watch ? packaging.watch(config) : packaging.build(config));
} catch (error) {
handle_error(error);
}
Expand Down
Loading

0 comments on commit 15516b4

Please sign in to comment.