lucacasonato / esbuild_deno_loader

Deno module resolution for `esbuild`
https://deno.land/x/esbuild_deno_loader
MIT License
162 stars 43 forks source link

Support for import maps #34

Closed Laurin-W closed 1 year ago

Laurin-W commented 1 year ago

I've was going to use an import_map.json to reference imports in my typescript files using lume.

This gave me an error: [plugin lumeLoader] Must be an absolute path.

I then tried to use esbuild-plugin-import-map however the error message remained the same. I'm not sure why this fails.

It would be great to have some kind of support for import maps!

For now I will resort to using a deps.ts file that im- and exports dependencies (e.g. export * as some_dependency from 'foobar';)

Basic code I used:

import * as importMap from 'npm:esbuild-plugin-import-map';
import esbuild from 'lume/plugins/esbuild.ts';
import lume from 'lume/mod.ts';

const site = lume();

importMap.load({
  'imports': {
    'some_dependency: 'foobar',
  },
});

site.use(
  esbuild({
    options: {
      plugins: [importMap.plugin()],
    },
  }),
);

export default site;
lucacasonato commented 1 year ago

Import maps are supported. You can specify an import map URL in the esbuild_deno_loader plugin options: https://deno.land/x/esbuild_deno_loader@0.6.0/mod.ts?s=DenoPluginOptions#prop_importMapURL