2

I got a project using webpack@4 I am currently importing a 3rd party library in a lazy manner. My import looks like that:

const externalLibrary = await import(/* webpackMode: "lazy" */ 'external-library');

However I stumbed across a problem where sometimes I need the library to be imported in an eager way. Is there a way to conditionally switch between "eager" and "lazy". Something like this:

const externalLibrary = await import(/* webpackMode: process.env.NODE_ENV == "production" ? "lazy" : "eager" */ 'external-library');

Is there a way to do it?

I found an open issue on github: https://github.com/webpack/webpack/issues/5029 that has the same problem.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.