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(build): warn dynamic import module with a static import alongside #12850

Merged
merged 5 commits into from Jun 10, 2023

Conversation

fi3ework
Copy link
Member

@fi3ework fi3ework commented Apr 13, 2023

Description

fix #12706. As @bluwy suggested, use rollup's warn to warn the ineffective dynamic import.

Additional context


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 PR Title 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.

@stackblitz
Copy link

stackblitz bot commented Apr 13, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@fi3ework fi3ework force-pushed the warn-ineffective-dynamic-import branch 3 times, most recently from 9b28228 to eb95a3c Compare May 4, 2023 14:34
@fi3ework fi3ework force-pushed the warn-ineffective-dynamic-import branch from eb95a3c to d16e2e2 Compare May 17, 2023 18:57
@fi3ework fi3ework requested a review from bluwy May 18, 2023 11:16
@bluwy bluwy added this to the 4.4 milestone Jun 7, 2023
@bluwy bluwy added p2-nice-to-have Not breaking anything but nice to have (priority) feat: build labels Jun 7, 2023
Comment on lines 127 to 139
this.warn(
`\n(!) ${
module.id
} is dynamically imported by ${module.dynamicImporters
.map((m) => m)
.join(
', ',
)} but also statically imported by ${module.importers
.map((m) => m)
.join(
', ',
)}, dynamic import will not move module into another chunk.\n`,
)
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a break after the this.warn here?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍🏻 Nice catch. Switched to using .some instead of a for loop (I start to know why it's hard to understand 😅)

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.

Looks great!

@bluwy bluwy changed the title fix(build): warn dynamic import module with a static import alongside feat(build): warn dynamic import module with a static import alongside Jun 10, 2023
@patak-dev patak-dev merged commit 127c334 into vitejs:main Jun 10, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: build 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.

Warn when a dynamically imported chunk is statically imported
3 participants