Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Option to keep /*webpackIgnore:true*/ in the bundle #18136

Closed
dandeancook opened this issue Feb 28, 2024 · 0 comments
Closed

Option to keep /*webpackIgnore:true*/ in the bundle #18136

dandeancook opened this issue Feb 28, 2024 · 0 comments

Comments

@dandeancook
Copy link

dandeancook commented Feb 28, 2024

Feature request

What is the expected behavior?
The special comment /*webpackIgnore*/ should have CLI option to keep it in the bundle.

What is motivation or use case for adding/changing the behavior?

I created a JS lib with some dynamic import init, so I placed `/*webpackIgnore:true*/` 
inside the import command as described by Webpack not to resolve the path variable 
passed into import function.

Now is my app, it uses the lib said above.

When bundling the app, the `webpackIgnore` comments are no longer inside the 
lib bundle, and thus Webpack shows warning:

WARNING in ./src/libs/my-lib/dist/lib.bundle.js 1:173737-173746
Critical dependency: the request of a dependency is an expression

In the lib bundle those dynamic imports are still `import(...`, but in the app bundle when 
Webpack minifies again, those dynamic imports are `x(...` where x is some minified letter.

I'm guessing of some solutions but don't know how to make it
  * Tell webpack to keep the webpackIgnore comment in the lib bundle
  * Tell webpack not to show warning when bundling the app (this is dangerous, 
    coz possibly webpack is resolving the variable passed to import(...) as null? 
    but practically checked that Webpack leaves those dynamic imports as-is)

Stack Overflow link: https://stackoverflow.com/questions/78073590/how-to-keep-the-comment-webpackignoretrue-in-bundle

How should this be implemented in your opinion?
New option in webpack.config.js to allow keeping of all /*webpackIgnore:true*/ comments.

Are you willing to work on this yourself?
No, not familiar with Webpack project source code.

@webpack webpack locked and limited conversation to collaborators Feb 28, 2024
@alexander-akait alexander-akait converted this issue into discussion #18137 Feb 28, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant