Webpack plugin
See original GitHub issueNice work @fabiandev; I’m really excited to test this out at some point!
Anyway, just throwing this idea out there in case you or anyone else have time for it at some point: a webpack plugin to automatically handle inserting the import into each source file and building with tsr.
In addition to making it a lot simpler to get started by piggybacking on existing tooling, this would abstract away most of the work required for integrations like https://github.com/angular/angular-cli/issues/6763 (at least for non-prod builds; some extra work might be needed to integrate tsr into Angular’s AOT compiler).
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Plugins - webpack
A webpack plugin is a JavaScript object that has an apply method. This apply method is called by the webpack compiler, giving access...
Read more >Plugins - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >Plugins - webpack
The plugins option is used to customize the webpack build process in a variety of ways. Webpack comes with a variety built-in plugins...
Read more >Writing a Plugin - webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >InstallWebpackPlugin | webpack
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
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 Free
Top 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

Okay, great!
Just to make it clearer, when transforming a file with the following code:
this is what you get by default:
What I’ll have to change is, that
tsr-declarations.jsshould not be imported/emitted if it is empty. However, it may be turned off in any case with--excludeDeclarationFilevia the CLI. Also it should be possible to opt out of thets-runtime/libimport, I think.Just noticed, that I will also have to align the CLI options with the API options. The project is still work in progress, but I’m glad for any feedback or issues spotted 😃
I’m considering working on this some myself, though am not sure yet whether the complexity level makes it feasible for me to complete with the motivation level I have.
In any case, I thought I’d join the conversation, and try to get a picture on what challenges are left to solve for a proper webpack loader to be created.
Regarding:
Couldn’t you simply encode each character in the Javascript code into its number/character-code, separated by some known-safe character?
For example:
And to decode:
EDIT: You should also be able to use base64 encoding, which is more compact: https://stackoverflow.com/a/2820329/2441655