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] allow users to override build target #2618

Merged
merged 6 commits into from
Oct 18, 2021
Merged

[fix] allow users to override build target #2618

merged 6 commits into from
Oct 18, 2021

Conversation

gunggmee
Copy link
Contributor

@gunggmee gunggmee commented Oct 17, 2021

This PR tries to fix #2565 while ensuring the overridden value still satisfies the constraints of the default build target. It contains following changes:

  • Sets es2020 as default build target
  • Allows users to override build target
  • Ensures overridden build target satisfies the constraints of es2020 by injecting the default target into overridden target(s). This makes esbuild to check the constraints.

Made a draft PR since it doesn't satisfies some items in the checklist. Please help me with additional commits.

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 pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

- set `es2020` as default build target
- allow users to override build target
- let esbuild to check overriden build target satisfies the contraints of `es2020`
@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2021

🦋 Changeset detected

Latest commit: 0a19bfb

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

@bluwy
Copy link
Member

bluwy commented Oct 17, 2021

Nice. Thanks for implementing this! I probably wasn't clear in my comment on the issue, but my intention was that we shouldn't validate build.target and accept what the user gives as is. It's pretty cool that you have something working nonetheless. From a look I think there's a few more things we can do:

  1. Handle targets like es5 and es6 (not in year format)
  2. Report to the user that the build target setting changed.

But IMO I think it's more work than it's worth since there would always be edge cases where this behaviour is undesirable. So I'm in favour of removing the validation logic for now. Curious on what the other maintainers' thought on this.

Other than that, the last thing is to add a changset via pnpx changeset, and it should be good to go.

@gunggmee
Copy link
Contributor Author

@bluwy Oh I see. Just moved server.build.target to default_config to make the build process don't warn on overriding. Also added the changeset.

@gunggmee gunggmee marked this pull request as ready for review October 17, 2021 05:07
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

LGTM. Will wait for the others to check out before merging.

@benmccann benmccann merged commit 4d9a94a into sveltejs:master Oct 18, 2021
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 specify build target
3 participants