Usage in the browser
Sorry this is more a question than an issue, but I'm just wondering what the best way of using components.js in the browser is? I can see that in comunica the components.js config has to be compiled initially before being sent to webpack. Is this the only way to do it at the moment? I'd love to experiment with the project a bit but all of my dev is in the browser so I just want to make sure I'm not missing anything before proceeding. Thanks!
For the browser, you typically want to optimize for size, so it makes sense to resolve the dependencies at compile time, which also gives a performance benefit because it does not need to be performed at runtime.
Additionally, webpack etc. have to know which dependencies to ship to the browser; they can't be resolved at runtime like Node.js does.
So doing this is definitely the recommended way; and for me the only why how I can imagine it working in the browser. Unless @rubensworks sees other ways.
Thanks for the speedy reply. For production it would definitely need to be compiled. I'm really just wondering about ergonomics during development. I wonder would it make sense if there was a custom webpack loader? The webpack documentation on writing a custom module loader mention give special mention to loaders that use the file system, saying they should integrate with webpack's module system. https://webpack.js.org/contribute/writing-a-loader/#module-dependencies So maybe it would be a matter of translating the componentsjs module loading into webpack loading. Easier said than done of course :-)
Ah yes, the script that interprets a Components.js configuration into JavaScript code could definitely be a webpack loader; it would not need to be that hard. Under the hood, it can remain the same; it should just return the JavaScript to webpack rather than outputting it.
Ah great! That would make it very straightforward. I haven't done any webpack loader development but I can make a go at implementing it.
That would be awesome, please keep us updated!