tscc icon indicating copy to clipboard operation
tscc copied to clipboard

Will npm modules ever be supported without resorting to externals compiler option?

Open foobardevpro opened this issue 4 years ago • 1 comments

I cannot use certain npm modules because they only support cjs, which I would be easily able to use with webpack. Even for modules made for web the process is still painful -- having to add the module to externals, copying the bundle, and manually modifiying the HTML to use it / or a cdn.

foobardevpro avatar Oct 01 '19 21:10 foobardevpro

If your npm module is written in a way that is compatible with Closure Compiler, then the answer is it could be. I haven't had much exprience on it yet, but there is --process_common_js_modules flag that is used by closure compiler webpack plugin to transform commonjs modules to a form that closure can understand, so we may utilize it.

If not - I don't see any overlap of it with the scope of tscc. You can still use browserify or webpack to first transform commonjs modules into a web-compatible format and then append to html as a script tag.

Just speculating, maybe part of the functionality of TSCC can be built as a plugin to webpack and it will resolve your use case. Among sources provided to rollup or webpack, it may be possible to compile things specified in the spec file with tsickle + closure compiler, and somehow wire it up with the rest of them. I'd welcome If someone has more idea on implementing this.

+) closure webpack plugin had a feature request like this https://github.com/webpack-contrib/closure-webpack-plugin/issues/26

theseanl avatar Oct 02 '19 20:10 theseanl