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(build): remove warning about ineffective dynamic import from node_modules #13884

Merged
merged 8 commits into from Jul 20, 2023

Conversation

chaejunlee
Copy link
Contributor

@chaejunlee chaejunlee commented Jul 18, 2023

Description

fixes #13848.

I have added a BuildOption variable called warnExternalChunkRender.

Default is false which disables warning of ineffective dynamic imports of external modules.

Setting the value to true enables all ineffective dynamic import warnings.

Additional context

I not so sure if I added the variable in the right place, or with a right name.

If you give me any feedback about that, I will fix it right away.

If the members approve this, I will be responsible for adding the documentation for this new config variable.

I would like to add some robust testing around this, but I really can't do it because I can't add node_modules to the codebase. I checked that the playground/dynamic-import has some package.json hack, but the build still targets the user defined files (pkg) not node_modules. If you can guide a little more on this, I will make sure to add testing as well.


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 Jul 18, 2023

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

@andygup
Copy link

andygup commented Jul 18, 2023

@chaejunlee I'm not familiar with the build/test processes of this repo, but I'm guessing you will need to modify the existing spec, or perhaps create a one to handle the new use case. Did you take a look at the spec in the original PR?

@chaejunlee
Copy link
Contributor Author

@andygup I guess you are mentioning the tests. I didn't through the original PR but I did look into it while preparing this PR. I will go through the original PR again and try again with the test. Thank you!

Copy link

@DesignHhuang DesignHhuang left a comment

Choose a reason for hiding this comment

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

i approved these changes that can enhance the build options

@chaejunlee
Copy link
Contributor Author

chaejunlee commented Jul 20, 2023

I have added documentation for the new config option. To better explain its functionality, I coined the term 'Ineffective Dynamic Import' as mentioned in the original PR #12850.

Feedback is welcome!

Copy link

@DesignHhuang DesignHhuang left a comment

Choose a reason for hiding this comment

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

I think this is a good idea. I am waiting for these changes to be merged. Then i can use this configuration instead of writing code to monitor these warns with build.rollupOptions.onwarn .

Copy link

@DesignHhuang DesignHhuang left a comment

Choose a reason for hiding this comment

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

well done

docs/config/build-options.md Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/reporter.ts Outdated Show resolved Hide resolved
packages/vite/src/node/plugins/reporter.ts Outdated Show resolved Hide resolved
@chaejunlee
Copy link
Contributor Author

@bluwy Thank you so much for the review!

What I understood is that don't make this feature configurable as a build option, but still implement the reporter.ts part as a feature.

Correct me if I am wrong. Until then, I will be removing config bits and refactor the reporter.ts as you pointed out.

@bluwy
Copy link
Member

bluwy commented Jul 20, 2023

Yup, I think we can avoid the option for now, and only implement the fix to not emit warnings for modules that contain "node_modules"

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! Gonna wait for a bit if another maintainer has thoughts on this (and the option) before merging.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jul 20, 2023
@bluwy bluwy changed the title feat(node): remove warning about ineffective dynamic import of node_modules with config options fix(build): remove warning about ineffective dynamic import from node_modules Jul 20, 2023
@andygup
Copy link

andygup commented Jul 20, 2023

Nice job @chaejunlee!

only implement the fix to not emit warnings for modules that contain "node_modules"

@bluwy thanks, this fix will significantly reduce the number of warnings for our library and possibly others. We use lazy loading internally in various @arcgis/core modules to avoid circular dependencies, so it will be nice to not have to instruct end users to suppress all warnings.

@bluwy bluwy merged commit 33002dd into vitejs:main Jul 20, 2023
14 checks passed
@davidAtInleague
Copy link

davidAtInleague commented Aug 2, 2023

It looks like warnExternalChunkRender was planned to silence emitting these errors from user code, but was removed in favor of silencing only errors originating from node_modules. Is there a mechanism to silence these errors when they originate in user code?

I see 7a77aaf, but it requires enabling inlineDynamicImports, which it's not clear I otherwise want to do.

@andygup
Copy link

andygup commented Aug 2, 2023

@davidAtInleague maybe at the bundler level, this was a suggestion provided in my original issue: https://rollupjs.org/configuration-options/#onwarn

@davidAtInleague
Copy link

@andygup thank you so much! That is the solution.

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.

Enhancement - opt-out of warnings on dynamic import modules with a static import
6 participants