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

fix: use postinstall hook to run sync instead of prepare #5651

Closed
wants to merge 5 commits into from

Conversation

dominikg
Copy link
Member

fixes #4585 and possibly a few others where people had issues with missing aliases

caveat:
this currently does not invoke sync for workspace projects depending on "@sveltejs/kit":"workspace:*" when running pnpm install in kit monorepo.

We could think about keeping prepare in those, but i'm uneasy doing it do avoid it masking issues with postinstall.

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
  • 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 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
Copy link

changeset-bot bot commented Jul 21, 2022

🦋 Changeset detected

Latest commit: 2a5c4fd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
create-svelte Patch
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

Looks like we'll need to do some more setup work for our own CI.

If we move this to postinstall, do we still need to keep svelte-kit sync? Feels like at that point we could just have an internal script that we don't expose via a CLI, since we only really added it for the sake of prepare. The consequence of that is that we don't need a svelte-kit CLI at all — we could move svelte-kit package into a separate package, which would make various things quite a bit easier.

@dominikg
Copy link
Member Author

That's a great idea, not going through the cli script for postinstall could make this easier.

Unfortunately I think we need to keep the sync command in a cli for cases where postinstall isnt run.

@Rich-Harris
Copy link
Member

Do we though? The only reason we included sync in the first place was so that people weren't faced with red squigglies in a new project — they can npm i && npm run check and the project will typecheck appropriately, which is handy for CI in some cases. But in any situation where you can run svelte-kit sync manually, you can also run sync via vite dev or vite build. I can't imagine there's a situation where you absolutely need to sync, but can't build, after you've already successfully installed the project

@dominikg
Copy link
Member Author

  1. there is npm install --ignore-scripts so postinstall is not guaranteed to be executed.
  2. dev and build are a lot heavier than sync alone.
  3. i think @dummdidumm and @jasonlyu123 recently discussed that the language server might want to call sync
  4. our own repo CI currently fails because postinstall for workspace deps isn't called consistently in a pnpm workspace, which means we'd have to build all project for the lint task.

Comment on lines +33 to +36
const cliPath = is_workspace
? fileURLToPath(new URL('./src/cli.js', import.meta.url))
: '@sveltejs/kit/dist/cli.js';
await import(cliPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should work, no?

Suggested change
const cliPath = is_workspace
? fileURLToPath(new URL('./src/cli.js', import.meta.url))
: '@sveltejs/kit/dist/cli.js';
await import(cliPath);
await import(
fileURLToPath(new URL(`./${is_workspace ? 'src' : 'dist'}/cli.js`, import.meta.url))
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(otherwise it complains about ./dist/cli.js not being in pkg.exports)

@Rich-Harris
Copy link
Member

I'll be honest, I don't understand what any of the new stuff in packages/kit/svelte-kit.js is for. Our CI workflow already ensures that SvelteKit is built, can't we get rid of all the is_workspace stuff?

@Rich-Harris Rich-Harris mentioned this pull request Jul 29, 2022
@Rich-Harris
Copy link
Member

merged #5760 so will close this

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.

Cannot run npm ci --prod with adapter-node
2 participants