jsenv / importmap-node-module

Generate importmap for node_modules
35 stars 4 forks source link

Subpath folder mapping is deprecated #25

Closed dmail closed 3 years ago

dmail commented 3 years ago

Subpath folder mappings is deprecated and should be replaced with subpath patterns.

https://nodejs.org/dist/latest-v15.x/docs/api/packages.html#packages_subpath_patterns https://nodejs.org/dist/latest-v15.x/docs/api/packages.html#packages_subpath_folder_mappings

image

There is no pattern equivalent in the importmap spec (for now?) as explained in https://github.com/WICG/import-maps/issues/232.

This repository could detect the presence of * in exports field and try to do conversion when possible

{
  "exports": {
    "./features/*": "./features/*" 
  }
}

Can be converted into importmap (just removing the *)

{
  "imports": {
    "./features/": "./features/"
  }
}

However

{
  "exports": {
    "./features/*": "./features/*.js" 
  }
}

Cannot be converted to import map, it would be ignored and some console.warn would explain why.

dmail commented 3 years ago

Done, in the end the console.warn is no longer relevant because we support the * notation to add extension since the source files gets parsed to add extension.