3 ms·
The problem with Javascript modules = Everyone will be forced to run a full web server to do anything (to handle CORS restrictions). We all lose the ability to
by geenat 3y ago
The problem with Javascript modules = Everyone will be forced to run a full web server to do anything (to handle CORS restrictions).
We all lose the ability to simply have a local index.html file, and have it Just Work (TM):
<script src="script.js"></script>
This ability is amazing for demos, fast iteration, onboarding new devs and developing without a ton of layers of js ecosystem machinery.
Deno doesn't care about retaining this level of developer experience because Deno is marketing its own runtime / build step / ecosystem.
- postalrat 3y agoIs CommonJS even a thing for javascript running in web browsers? Moving from CommonJS to modules shouldn't affect any running in a browser.
- lucacasonato 3y agoIf you are same origin, you do not require CORS to use type=module. Also type=module works on HTML pages served from file:// (file:///.../index.html).
- caditinpiscinam 3y agoI just tried this and got "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///home/**.js. (Reason: CORS request not http)" in firefox
- recursive 3y agoIt is not possible to do same origin from a file system. Everything served from a file system is considered to be different origins. This drives me bonkers.
- cxr 3y agoBecause browser makers only have respect for the bourgeoisie and clear contempt for the proletariat.
- tredre3 3y ago> <script src="/js/anything.js" ></script> Shouldn't that be a relative path for it to actually work as you intend?
- tracker1 3y agoIt just needs to be browser resolvable, assuming this element is meant to run in a browser. So absolute paths do work. For libraries, you may want to use import maps or absolute urls (similar to Deno). There's also esm.sh and jspm.org for modules that are able to be relatively easily converted. I think it may be necessary/prudent to get some level of JSX support into browsers, much like the ts as comments efforts. Not sure how that will/would land. I was a pretty big fan of E4X, and had a prototype similar to React about a decade before it. In the end, who knows.