Skip to content

v0.5.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@jespertheend jespertheend released this 30 Apr 21:38
· 40 commits to main since this release

Support 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);

Other

  • Show the importer path when a network error occurs (#8)
  • Support export from syntax (#10)