jonas
jonas
DDeno
Created by jonas on 7/29/2024 in #help
Why do ES6 module imports differ from browser?
When importing a JS module (e.g. https://example.com/module.js) from a URL that returns a 301/302 redirect to a specific version of the module (e.g. https://example.com/module-42.js), the redirected module is initiated as a separate instance. This means that when explicitly importing the module from both the initial URL and the versioned URL, two instances of the module are created: import "https://example.com/module.js"; // -> redirects to https://example.com/module-42.js import "https://example.com/module-42.js"; This behavior is the same in all browsers (Chrome, Firefox, Safarie), but in Deno, the redirected URL and the versioned URL both point to the same module instance and only initialize the module once. Imo, the way Deno handles redirects makes more sense because the redirect does not just point to the same module, it points to the identical resource which should not be treated as a separate module instance. Why does deno handle it differently than all browsers? SO: https://stackoverflow.com/questions/78785224/how-are-es6-module-imports-with-http-redirects-supposed-to-work/78801025#78801025
2 replies