Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build and dev support for kit package #1496

Merged
merged 5 commits into from
May 20, 2021

Conversation

ryc76
Copy link
Contributor

@ryc76 ryc76 commented May 19, 2021

pnpm build and dev commands were failing on Windows due to lack of "rm" command as specified in packages\kit\package.json

"dev": "rm -rf assets/runtime && rollup -cw",
"build": "rm -rf assets/runtime && rollup -c",

Have added run-script-os NPM package to allow OS dependant commands to run and added equivalent Windows command

"build": "run-script-os",
"dev": "run-script-os",
"dev:default": "rm -rf assets/runtime && rollup -cw",
"dev:win32": "del /S /Q assets\runtime && rollup -cw",
"build:default": "rm -rf assets/runtime && rollup -c",
"build:win32": "del /S /Q assets\runtime && rollup -c",

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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts

@benmccann
Copy link
Member

Thanks for this. We'd probably like to avoid adding any new dependencies and just call node -e "whatever" instead using fs.rm / fs.rmdir or whatever

@benmccann
Copy link
Member

Or just call those commands synchronously at the top of rollup.config.js

@Conduitry
Copy link
Member

Conduitry commented May 20, 2021

So, something like:

diff --git a/packages/kit/package.json b/packages/kit/package.json
index 0b7fa33..0d1ffe4 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -49,8 +49,8 @@
 		"svelte-kit.js"
 	],
 	"scripts": {
-		"dev": "rm -rf assets/runtime && rollup -cw",
-		"build": "rm -rf assets/runtime && rollup -c",
+		"dev": "rollup -cw",
+		"build": "rollup -c",
 		"lint": "eslint --ignore-path .gitignore \"src/**/*.{ts,mjs,js,svelte}\" && npm run check-format",
 		"check": "tsc && svelte-check",
 		"format": "prettier --write . --config ../../.prettierrc --ignore-path .gitignore",
diff --git a/packages/kit/rollup.config.js b/packages/kit/rollup.config.js
index 9d1e936..8a2fca1 100644
--- a/packages/kit/rollup.config.js
+++ b/packages/kit/rollup.config.js
@@ -1,3 +1,6 @@
+import fs from 'fs';
+(fs.rmSync || fs.rmdirSync)('assets/runtime', { recursive: true, force: true });
+
 import commonjs from '@rollup/plugin-commonjs';
 import replace from '@rollup/plugin-replace';
 import resolve from '@rollup/plugin-node-resolve';

@benmccann benmccann merged commit 0413d41 into sveltejs:master May 20, 2021
andyburke pushed a commit to andyburke-forks/kit that referenced this pull request May 25, 2021
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
@ryc76 ryc76 deleted the windows-build-support branch July 1, 2021 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants