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(lib): cjs instead of umd as default format for multiple entries #10315

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

schummar
Copy link
Contributor

@schummar schummar commented Oct 2, 2022

Description

This is a follow up to #7047. I propose to use different default format settings when using multiple entries in lib mode.

At the moment using a config like this:

lib: {
  entry: {
      primary: 'src/index.ts',
      secondary: 'src/secondary.ts'
  }
}

will result in an error

Multiple entry points are not supported when output formats include "umd" or "iife".

That is because, if not specified otherwise, the output formats in lib mode will be ['es', 'umd'] and Rollup does not support multiple entry points for UMD (rollup/rollup#2072). Since this is not a nice user experience, I think it's better to not use UMD by default - if multiple entries are used. Instead CommonJs could be used, which is at least a part of UMD, minus the AMD part.

Additional context

Since multiple entries are not released yet, this is not a breaking change. If we can get it in before 3.2 😉


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.

@schummar schummar changed the title Feature/multi entry default format feat(lib): cjs instead of umd as default format for multiple entries Oct 2, 2022
@sapphi-red sapphi-red added p2-nice-to-have Not breaking anything but nice to have (priority) feat: library mode labels Oct 10, 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.

Thanks! This looks good to me.

@patak-dev patak-dev merged commit 07d3fbd into vitejs:main Oct 10, 2022
@schummar schummar deleted the feature/multiEntryDefaultFormat branch October 10, 2022 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: library mode 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.

3 participants