-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Warning is printed when optional modules are "missing" #9285
Comments
Warning at build time (even if it's a false positive) seems better than waiting until runtime for the application to crash! |
True, you're right! What do you think about the proposal having the ImportScanner to somehow exclude "known missing modules"? |
@avanthay - we'd like to keep the build time warning for now (as per #9285 (comment)), but regarding:
Would you mind opening a new feature request for this over in http://github.com/meteor/meteor-feature-requests/issues? Thanks! |
Thank you for the reply, I agree on not entirely removing the warning, that would ends up in crashing apps. I just opened this new feature request meteor/meteor-feature-requests#228 for this. |
Apologies for the 🧟 but as the feature requests repo is archived and this was never resolved, I'm proposing reopening. Use case: We have an internal app framework with dozens of our own private components which are then imported when needed by one of our core apps. These are all stored in a componentMap.js which includes a lazy import for every one of the private components. This structure works well and keeps the individual core app bundle sizes down, however we get warnings in the terminal for every unresolved module at build time. An "ignore list" for the |
@Grubba27 I'd be happy to take a look, but TypeScript and node aren't my usual set of tools. From a quick scan of import-scanner.ts, it looks like we'd need to add an |
Meteor's build system tries to be config free, so it would be nice if Meteor could detect these scenarios and not log the warning without configuration. In the past, I've only really seen this when I'm not sure I understand why this warning is shown with your use case. Do the files imported by |
Simplified example follows. I'm very happy to hear alternative suggestions for how to handle this. Framework modules: componentMap.js (part of ComponentHolder module):
All Core Apps use
Core App A uses Core App B prints a warning that The thinking behind this structure is that it gives us quick and easy code reuse, and a single place to keep the mapping, while theoretically keeping the bundle size down by not including unwanted components. |
Thanks @jymbob. Using dynamic imports for this makes sense. Two ideas of how we can improve this without adding configuration:
|
I'd vote for the former if that's an easy change. A reminder once that you've got something unusual going on is handy. A reminder every time starts to get ignored |
|
System & Version
My MacBook Pro runs macOS Sierra 10.12.6, my college working on Ubuntu 17.10 has the same issue. It occurs (at least) with Meteor v1.5.2.1 v1.5.2.2 & v1.6.
Error Description
I added the npm package
bootstrap-slider
to our Meteor project, which has an optional dependency to jQuery. That means the package callsrequire("jquery")
in an if statement, at some point.Since we do not use jQuery in our project, I got the following warning every time the Meteor server restarts:
As @benjamn described here the Meteor
ImportScanner
statically searches forrequire(<string literal>)
in the code base, without evaluating if that code is ever executed.This issue affects all packages requiring optional dependencies. For example, that means all packages build on top of this jQuery plugin "boilerplate", like
bootstrap-slider
in my actual case.Reproduction Recipe
which produces this output:
Solution Proposal
My expected behaviour is not to have this warning printed every time the Meteor server restarts.
I don't really understand what the purpose of this warning is – in case the "missing" module is really missing at execution time, the app will crash anyway and the developer will have to install the missing module to be able to run his code.
Anyway, if this warning is somehow important to keep, my proposition will be to add an option somewhere to be able to list "known missing modules". These modules should then be ignored by the
ImportScanner
or at least they should be considered before printing the warning.What's you opinion?
The text was updated successfully, but these errors were encountered: