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: don't run import analysis on build in lib #3912

Closed
wants to merge 2 commits into from

Conversation

modderme123
Copy link
Contributor

Description

When running in library mode, import analysis returns strings that aren't analyzable by future bundlers, which prevents assets from being loaded and throws errors in final bundles. The solution is to not run this process at all, and instead require users of a library to import the css directly (which is what must be done currently, this just gets rid of the errors)

Additional context

Fixes #3662


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.

antfu
antfu previously approved these changes Jun 25, 2021
@patak-dev
Copy link
Member

Doesn't this break glob imports in lib mode?

@antfu antfu dismissed their stale review June 25, 2021 21:31

DIsmiss

@antfu
Copy link
Member

antfu commented Jun 25, 2021

Yeah, good point, sorry I missed that.

@modderme123 Can you share a minimal repro of the problem you are trying to resolve?

@modderme123
Copy link
Contributor Author

modderme123 commented Jun 26, 2021

https://github.com/modderme123/vitebug/tree/import-analysis

I'm sure this isn't the tiniest way of triggering import analysis, but it is reasonably small and all sorts of things go wrong when lib mode has the preload import added. A tinier change might be to only disable this if statement: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/importAnalysisBuild.ts#L155

@patak-dev
Copy link
Member

@modderme123 I converted this to a draft, please marked as ready for review later. Thanks!

@modderme123
Copy link
Contributor Author

To clarify: I should update with the if statement suggested in my comment above and then mark this as ready for review?

@modderme123
Copy link
Contributor Author

Fixed by #4097

@modderme123 modderme123 deleted the lib-analysis branch August 17, 2021 18:20
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.

Preload fails in library mode
3 participants