skypackjs / skypack-cdn

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

Unable to resolve media type for specifier #96

Open YuriGal opened 3 years ago

YuriGal commented 3 years ago

Trying to get archive-promise package in deno, getting:

Error: Unable to resolve media type for specifier: 
"https://cdn.skypack.dev/-/archiver-promise@v1.0.0-dFLwcYtSiypeogvf3KVZ/dist=es2020,mode=types/null" 

Help?

timreichen commented 3 years ago

I have the same problem when trying to load cssnano with deno.

An unsupported media type was attempted to be imported as a module.
  Specifier: https://cdn.skypack.dev/-/entities@v1.1.2-8Cauvwsy6UxU2k1OBsYo/dist=es2020,mode=raw/maps/entities.json
  MediaType: Json

Also when used as described in the browser

<script type="module">
  import cssnano from 'https://cdn.skypack.dev/cssnano';
</script>

it will throw

Failed to load module script: The server responded with a non-JavaScript MIME type of "application/json". Strict MIME type checking is enforced for module scripts per HTML spec. envs.json:1 
Failed to load module script: The server responded with a non-JavaScript MIME type of "application/json". Strict MIME type checking is enforced for module scripts per HTML spec. release-schedule.json:1 
GET https://cdn.skypack.dev/-/vendors@v1.0.4-ZnLe9HQixqBQlo9iroy8/dist=es2020/vendors.js net::ERR_ABORTED 404 postcss-merge-rules.js:3
GET https://cdn.skypack.dev/-/css-color-names@v0.0.4-OyNLfqqIhCy5oT5RejYV/dist=es2020/css-color-names.js net::ERR_ABORTED 404 postcss-merge-longhand.js:3

How to fix this?

FredKSchott commented 3 years ago

Thanks for filing. You're right, since the css-color-names package's main entrypoint is JSON we don't currently support someone ESM importing that JSON as if it were a JS module, so it fails as not found. I agree that we should have some basic support for this.

Working on something over the next two weeks which could enable this.

timreichen commented 3 years ago

@FredKSchott that is great to hear. I know that the whole scenario with json imports is quite messy at the moment. Even import assertions proposal is at stage 3, json modules proposal is at stage 2 and typescript has a flag --resolveJsonModule. Maybe some kind of wrapper to transform a json file into a default exported object could be a possible solution?

{
"foo": "bar"
}

to

export default {
"foo": "bar"
}