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

feat: respect esbuild minify config #8754

Merged
merged 10 commits into from
Jun 25, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jun 24, 2022

Description

Closes #6065

Additional context

Been thinking about the issue, and maybe it make sense to scope minify to certain aspects only.

Logic:

  1. If minify* options are specified, use them instead of minify: true (which overrides all the specific options to true)
  2. Otherwise we force minify: true
  3. Lastly, also ensure that minifyWhitespace is false for es library build.

Other improvements

  1. ES library build will not completely skip minify, it would run minifySyntax and minifyIdentifiers as those are safe.
  2. Ensure minification is totally off if build.minify: false, regardless of esbuild.minify and esbuild.minify*
  3. Ensure minification is totally off when transforming tsx/jsx files

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jun 24, 2022
@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit 7fa7067
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62b5c0bfba800b0008a44918
😎 Deploy Preview https://deploy-preview-8754--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bluwy bluwy mentioned this pull request Jun 24, 2022
4 tasks
@sapphi-red
Copy link
Member

I think setting never to config.esbuild.minify will improve UX because now it won't effect anything.

export interface ESBuildOptions extends TransformOptions {
  include?: string | RegExp | string[] | RegExp[]
  exclude?: string | RegExp | string[] | RegExp[]
  jsxInject?: string
  /** This option is not respected. Use `build.minify` instead. */
  minify?: never
}
export default defineConfig({
  esbuild: {
    minify: true // type error here. jsdoc will show the reason
  }
})

docs/config/shared-options.md Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/esbuild.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/esbuild.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/esbuild.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/esbuild.ts Outdated Show resolved Hide resolved
bluwy and others added 5 commits June 24, 2022 16:25
Co-authored-by: 翠 / green <green@sapphi.red>
Co-authored-by: 翠 / green <green@sapphi.red>
Co-authored-by: 翠 / green <green@sapphi.red>
sapphi-red
sapphi-red previously approved these changes Jun 24, 2022
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

One small nitpick but other LGTM ✨

packages/vite/src/node/__tests__/plugins/esbuild.spec.ts Outdated Show resolved Hide resolved
Co-authored-by: 翠 / green <green@sapphi.red>
@patak-dev patak-dev merged commit 8b77695 into vitejs:main Jun 25, 2022
@bluwy bluwy deleted the feat-respect-esbuild-minify branch June 25, 2022 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vite.config.js esbuild options are ignored, e.g. disabling minification or one of its aspects
3 participants