v0.5.0
Pre-releaseSupport for import maps (#2)
You can now set an import map using importer.setImportMap()
:
const importer1 = new Importer(import.meta.url);
importer1.setImportMap("../import-map.json"); // import relatively to the current file
const importer2 = new Importer(import.meta.url);
importer2.setImportMap("https://example.com/import-map.json"); // import from a remote location
const importer3 = new Importer(import.meta.url);
importer3.setImportMap({
"imports": {
"./foo.js": "https://example.com/foo.js",
"./bar.js": "https://example.com/bar.js",
},
});
Similar to how this works in browsers, you can only set an import map once and only before importing anything.
Support for TypeScript imports (#14)
Previously the created blob urls would always get the text/javascript
mime type, causing Deno to use the JavaScript parser on every file, even if the file was a TypeScript file. This update takes the content-type header from any remote files, or looks at the file extension and sets the correct mime type for created blob urls.
Better stack traces during import errors (#9)
If an error occurs during the importer.import()
call, any blob urls in the message or stack trace are now replaced with the original file paths. Making it easier to debug any import issues.
BREAKING: Don't allow root imports without prefixed / ./ or ../ (#12)
This makes the behaviour more in line with what browsers and Deno are already doing.
This update also removes support for passing in URL objects to the import()
method. If you want to pass in urls, serialize them first using URL.href
, i.e.:
const url = new URL("https://example.com");
importer.import(url.href);