Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ts-browser self contained #10

Open
rdlaitila opened this issue Jun 22, 2020 · 6 comments
Open

make ts-browser self contained #10

rdlaitila opened this issue Jun 22, 2020 · 6 comments
Assignees

Comments

@rdlaitila
Copy link

rdlaitila commented Jun 22, 2020

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:

self.importScripts(

const url = 'https://klesun-misc.github.io/TypeScript/lib/typescriptServices.js';

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!

@klesun
Copy link
Owner

klesun commented Jun 23, 2020

Hi, good point, most likely just me being lazy. Will try to patch it shortly.

@klesun klesun self-assigned this Jun 23, 2020
klesun added a commit to klesun-misc/ts-browser-beta that referenced this issue Jun 23, 2020
@klesun
Copy link
Owner

klesun commented Jun 23, 2020

Gosh, those workers are such a pain...

@rdlaitila rdlaitila mentioned this issue Jun 23, 2020
@rdlaitila
Copy link
Author

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.

rdlaitila added a commit to rdlaitila/ts-browser that referenced this issue Jun 23, 2020
klesun#10
ensure typescriptServices is not dynamically evaled.
vendor md5.js
remove cdn proxy imports
rdlaitila added a commit to rdlaitila/ts-browser that referenced this issue Jun 23, 2020
klesun#10 removes defunct files no longer needed
klesun added a commit to klesun-misc/ts-browser-beta that referenced this issue Jun 23, 2020
@klesun
Copy link
Owner

klesun commented Jun 23, 2020

I fixed local scripts being fetched via absolute links in 8b20707, 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()

@klesun
Copy link
Owner

klesun commented Jun 23, 2020

Also got rid of remaining klesun url-s - using unpkg.com for typescriptServices.js instead - 0c76455

@klesun
Copy link
Owner

klesun commented Jun 23, 2020

And also published it on npm =3
https://www.npmjs.com/package/ts-browser-klesun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants