Consider using static require dependencies
See original GitHub issueThere is an issue when using the package with https://github.com/jspm (sytemjs) https://github.com/jspm/registry/issues/221
this code uses dynamic requires https://github.com/netroy/image-size/blob/master/lib/index.js#L6-L15
and https://github.com/systemjs/systemjs can not handle it.
Actually it is importaint as image-size
is used with css precompilers (such as LESS) and they have to be used in systemjs-builder worflow.
Would you consider chanding requires to static paths? Or addings static deps
declarations in the beginning of the file?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:4
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Use dependency injection in static class - Stack Overflow
You basically have two options: Change the class from static to an instance class and supply the dependency through Constructor Injection.
Read more >Dependency Injection vs Static Dependencies
I was curious whether in a situation like this it is more appropriate to use poor man's di (no framework) or static class...
Read more >Static classes are evil, or Make your dependencies explicit
Since classes with static methods have nothing to do with objects, they don't know who they are, what they should do and what...
Read more >Using .NET Core DI in static class | by Mustafa Magdy - Medium
You may encounter a situation where you need to resolve a dependency inside a static class, but with static class you are limited...
Read more >Breaking static dependency - Gunnar Peipman
This blog post introduces two tricks to make code with static dependencies testable. As a sample I take one piece of non-commercial code ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a problem for me too!! I have browserify on an express app and the dynamic requires just to not get bundled, resulting in
module not found
. Please have them changed to static. ThanksIndeed, Browserify (which ; by the way ; is not only used for client-side bundling, but can also be used to package server-side code, e.g. in Electron) fails to fulfill the dynamic
require()
calls, for instance: https://github.com/image-size/image-size/blob/a71d6372c95e79efa0b349153a8525381aab0e5c/lib/index.js#L9-L14 (from thetypes
list defined at https://github.com/image-size/image-size/blob/master/lib/types.js )The current workaround is to add explicit
require
s for each “type” using a hard-coded path. This is actually standard practice in several CommonJS libs, to ensure Browserify (and others) compatibility.