Repository: sveltejs/kit
Pull request #4923 (2022-05-14 05:15:58)

[fix] get packaging test working on Windows
Packaging's "watches for changes" test hasn't worked on Windows. Upon investigation it was because of two reasons:

- We need to wait for `chokidar`'s `ready` event before writing the files;
- Typescript uses `crlf` on the generated `.d.ts` files by default, causing a mismatch with our expected output.

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [x] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [ ] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 01cc32125b321e8948d6700e3e7b529374a9f586

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/mrkishi/kit/new/watch-test?filename=.changeset/spotty-timers-fix.md&value=---%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A---%0A%0A%5Bfix%5D%20get%20packaging%20test%20working%20on%20Windows%0A)



Patch:
diff --git a/packages/adapter-vercel/README.md b/packages/adapter-vercel/README.md
index 34a0999fb..7095c12b7 100644
--- a/packages/adapter-vercel/README.md
+++ b/packages/adapter-vercel/README.md
@@ -6,7 +6,7 @@ If you're using [adapter-auto](../adapter-auto), you don't need to install this
 
 ## Usage
 
-> The `edge` and `split` options depend on the Vercel Build Output API which is currently in beta. For now, you must opt in by visiting `https://vercel.com/svelte/[YOUR_PROJECT]/settings/environment-variables` and adding `ENABLE_VC_BUILD` with the value `1`.
+> The `edge` and `split` options depend on the Vercel Build Output API which is currently in beta. For now, you must opt in by visiting `https://vercel.com/[YOUR_USERNAME]/[YOUR_PROJECT]/settings/environment-variables` and adding `ENABLE_VC_BUILD` with the value `1`.
 
 Add `"@sveltejs/adapter-vercel": "next"` to the `devDependencies` in your `package.json` and run `npm install`.
 
diff --git a/packages/kit/src/packaging/index.js b/packages/kit/src/packaging/index.js
index c525ca135..010774db9 100644
--- a/packages/kit/src/packaging/index.js
+++ b/packages/kit/src/packaging/index.js
@@ -109,6 +109,7 @@ export async function watch(config, cwd = process.cwd()) {
 	let timeout;
 
 	const watcher = chokidar.watch(lib, { ignoreInitial: true });
+	const ready = new Promise((resolve) => watcher.on('ready', resolve));
 
 	watcher.on('all', async (type, path) => {
 		const file = analyze(config, relative(lib, path));
@@ -176,6 +177,7 @@ export async function watch(config, cwd = process.cwd()) {
 
 	return {
 		watcher,
+		ready,
 		settled: () =>
 			new Promise((fulfil, reject) => {
 				fulfillers.push(fulfil);


Test patch:
diff --git a/packages/kit/src/packaging/test/index.js b/packages/kit/src/packaging/test/index.js
index ebefaef98..3c818f22b 100644
--- a/packages/kit/src/packaging/test/index.js
+++ b/packages/kit/src/packaging/test/index.js
@@ -154,7 +154,7 @@ if (!process.env.CI) {
 		const config = await load_config({ cwd });
 		config.kit.package.dir = resolve(cwd, config.kit.package.dir);
 
-		const { watcher, settled } = await watch(config, cwd);
+		const { watcher, ready, settled } = await watch(config, cwd);
 
 		/** @param {string} file */
 		function compare(file) {
@@ -181,6 +181,8 @@ if (!process.env.CI) {
 		}
 
 		try {
+			await ready;
+
 			// completes initial build
 			compare('index.js');
 
diff --git a/packages/kit/src/packaging/test/watch/tsconfig.json b/packages/kit/src/packaging/test/watch/tsconfig.json
index bcc299cd9..44dca20d0 100644
--- a/packages/kit/src/packaging/test/watch/tsconfig.json
+++ b/packages/kit/src/packaging/test/watch/tsconfig.json
@@ -1,6 +1,7 @@
 {
 	"compilerOptions": {
 		"allowJs": true,
-		"checkJs": true
+		"checkJs": true,
+		"newLine": "lf"
 	}
 }