ts-browser
ts-browser copied to clipboard
make ts-browser self contained
If I copy ts-browser down to my project locally, and load the module as so:
<script type="module">
import {loadModule} from './ts-browser/src/ts-browser.js';
loadModule('./index.ts');
</script>
It still calls out to various klesun urls to pull down worker scripts and ts compiler js:
https://github.com/klesun/ts-browser/blob/cd85cdc95e87aa0850af93cef9f186e840e1bae4/src/TranspileWorker.js#L3
https://github.com/klesun/ts-browser/blob/cd85cdc95e87aa0850af93cef9f186e840e1bae4/src/cdnEs6Wrappers/typescriptServices.js#L12
possibly other places too. Is it possible to make ts-browser self contained so I have no external dependence on your hosted urls?
Edit: I should add this is a very cool project!
Hi, good point, most likely just me being lazy. Will try to patch it shortly.
Gosh, those workers are such a pain...
Created a PR that seems to get this working. I am running a local webserver to serve everything and ts-browser is installed in my web root as a folder 'ts-browser'.
The changes are likely not comprehensive but its a start.
I fixed local scripts being fetched via absolute links in 8b20707e7deaa932eee8658c8de64c0121213097, that was very stupid, but wasn't obvious to me at the moment of initial writing how to avoid that.
In most places, declaring window.ts
and window.md5
with versions of the libs of your choice before calling ts-browser
should save you from fetching them from cdn. Not a very 2k20 solution, but should still work supposedly...
Making the url of typescriptServices.ts
fetched inside the worker configurable would be a nice thing, but would require some refactoring, as currently workers are initialised instantly on module level for optimisation, without any means to pass parameters from loadModule()
Also got rid of remaining klesun url-s - using unpkg.com
for typescriptServices.js
instead - 0c7645526117ea73a799cd52246406e5b05e30aa
And also published it on npm =3 https://www.npmjs.com/package/ts-browser-klesun