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

Support an async function to provide vite config #3565

Merged
merged 4 commits into from
Feb 1, 2022

Conversation

ispyinternet
Copy link
Contributor

fixes #3436

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2022

🦋 Changeset detected

Latest commit: 50152f8

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

This PR includes changesets to release 1 package
Name Type
@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

@netlify
Copy link

netlify bot commented Jan 27, 2022

✔️ Deploy Preview for kit-demo ready!

🔨 Explore the source changes: 50152f8

🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/61f93da90ca2ca00083e220a

😎 Browse the preview: https://deploy-preview-3565--kit-demo.netlify.app

@ispyinternet
Copy link
Contributor Author

ispyinternet commented Jan 27, 2022

Don't think it breaks anything 🤷‍♂️ any help to get working would be appreciated.

@benmccann
Copy link
Member

You need to run pnpm format

@dominikg
Copy link
Member

It would be good to update the docs and config type to show that an async function can be used too.

Please also add a changeset.

sidenote:
Got confused at first because your PR never handles the vite config as object case, but it looks like the validator turns an object into ()=>object. I didn't expect that but makes sense to have it in a single place

@Rich-Harris
Copy link
Member

This seems like a harmless change so I'm 👍 , though I'm curious what the use case is? You can use top-level await in your svelte.config.js, so it seems like anything enabled by this change should already be possible

@ispyinternet
Copy link
Contributor Author

ispyinternet commented Jan 27, 2022

Ah can I? I tried to export an async function that returned a svelte.config.js object but that didn't work.

Basically I have async config that I inject into the application code (typescript files not .svelte so I can't use svelte preprocess). I'm using rollup/plugin-replace via vite 🤷

@Rich-Harris
Copy link
Member

yep, you can do this:

export default {
  kit: {
    vite: {
      plugins: [
        replace(await load_replacements());
      ]
    }
  }
};

given that, do we still need this change?

@Rich-Harris Rich-Harris merged commit cf5d4aa into sveltejs:master Feb 1, 2022
@github-actions github-actions bot mentioned this pull request Feb 1, 2022
@ispyinternet ispyinternet deleted the async-vite-config branch February 8, 2022 12:14
@ispyinternet
Copy link
Contributor Author

Sorry no reply @Rich-Harris tied up elsewhere!

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.

No support for async vite config function
4 participants