Currently processImport directly executes the importer function from the can-import-module package, passing it the target module name and the current (i.e. parent) module name:
can-import-module does runtime module resolution and has zero support for systems that use build-time resolution, like Webpack.
If we look at e.g. the Webpack can-stache-loader, it already uses the intermediate language representation for stache files, and finalizes construction of the renderer by passing in the module:
Why not add the possibility to specify a build-system specific importer on this module metadata?
Systems like Webpack can then use this as an injection point where can-view-import can be made to operate off of a list of modules pre-imported via the build system.
Currently
processImport
directly executes the importer function from thecan-import-module
package, passing it the target module name and the current (i.e. parent) module name:https://github.com/canjs/can-view-import/blob/d1c77e7e8756b7bcc860550a653076c850c9205d/can-view-import.js#L25-L32
can-import-module
does runtime module resolution and has zero support for systems that use build-time resolution, like Webpack.If we look at e.g. the Webpack
can-stache-loader
, it already uses the intermediate language representation for stache files, and finalizes construction of the renderer by passing in themodule
:https://github.com/canjs/can-stache-loader/blob/0a17a7cff6673cd461b85c44eecd5a2684ca37fe/index.js#L31-L36 (Sorry... no support for cross-repository embedded code snippits on GitHub just yet...)
Why not add the possibility to specify a build-system specific
importer
on this module metadata? Systems like Webpack can then use this as an injection point wherecan-view-import
can be made to operate off of a list of modules pre-imported via the build system.E.g. https://gist.github.com/rjgotten/1bdc23e0f04a1c46af44eeb5fd08a063