skypackjs / skypack-cdn

An issue tracker for the CDN
107 stars 5 forks source link

Support nested subpath patterns in exports field #263

Open marcofugaro opened 2 years ago

marcofugaro commented 2 years ago

Given the following exports field in a library package.json:

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

The following link will work:

https://cdn.skypack.dev/example@1.0.0/features/TestFeature.js

However the following link will default to raw mode:

https://cdn.skypack.dev/example@1.0.0/features/awesomeFeature/TestFeature.js

This does not match the Node.js behaviour, since as you can see from the docs:

* maps expose nested subpaths as it is a string replacement syntax only.

It would be ideal if the imports mode would work on nested exports as well.

This is breaking skypack usage with the current three.js version: see #261

You can test the behaviour with this link: https://cdn.skypack.dev/three@0.137.5/examples/jsm/controls/OrbitControls.js

Related also to #249

abernier commented 1 year ago

Any update on this?

This issue currently prevents us from importing nested foo/bar/baz modules[^1]: [^1]: for instance any three/addons/**/* modules

import baz from 'https://cdn.skypack.dev/mypackage@1.2.3/foo/bar/baz.js'

despite package.json.exports rule being set:

"./foo/*": "./foo/*"

--

As a workaround, we could of course add:

"./foo/*": "./foo/*"
"./foo/bar/*": "./foo/bar/*"

but this become not realistic when many foo/* folders OR many deep-nested folders foo/**/*