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
optional dependencies when using es6 import/export #7713
Comments
try {
require("external");
} catch(e) {
// fallback
} |
Thanks But 😄 All I actually want to know is how to get the (external) module to be defined as optional, without using the try-catch method. |
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
Answer above #7713 (comment) |
I know closing the ticket is automated, but this ticket is not resolved. |
Hi everyone 👋 I've read a few issues across GitHub of libraries using optional externals via a try/catch. None of them are fully resolved. The major issue is that you get a warning If a library wants to offer optional adapters for third-party dependencies out-of-the-box, its users will receive a warning for each optional dependencies that this user doesn't need. I'm not sure that this is an acceptable behaviour. To be more precise.Current context: wrap Am I missing something? Here's a couple of those issues I was talking about: |
@lorisleiva here's another example: websockets/ws#1220 |
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so with import(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non- standard module system for these. For more info, see: webpack/webpack#7713
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so with import(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non- standard module system for these. For more info, see: webpack/webpack#7713
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so with require(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non- standard module system for these. For more info, see: webpack/webpack#7713
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so — or at least, not in a way that blocks Next.js from building the app — with require(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non-standard module system for these. For more info, see: webpack/webpack#7713
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so — or at least, not in a way that blocks Next.js from building the app — with require(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non-standard module system for these. For more info, see: webpack/webpack#7713
Webpack issues a warning when trying to import() a module that is not present, whereas it does not do so — or at least, not in a way that blocks Next.js from building the app — with require(). Since we're requiring a bundler anyway (since we're using npm package names rather than import paths), we're not any worse off using a non-standard module system for these. For more info, see: webpack/webpack#7713
Hey, If there is a good solution to this problem, please let me know. In the meantime, you can probably disable the warning with warningsFilter option: https://webpack.js.org/configuration/stats/#statswarningsfilter
Not sure it will work for you because our setup is not very usual (we actually duplicate some code from Webpack), but this worked for me. Edit, for Webpack 5 I believe this has changed a bit and now it became:
|
I am trying to define optional externals in an es6 project.
The feature exists - #339 , but there is no flag that I can set in the (externals) configuration to make a dependency optional. Digging into the code I found that optional is a flag checking for reasons, and if every reason's dependency is marked as optional. But I can't seem to find where it is defined.
What would be the best way to define an external dependency optional? Have I missed something and it is possible doing it using configuration?
The text was updated successfully, but these errors were encountered: