MusicKit as ES6 Module?

Hi,


I'd like to know if it would be possible to somehow expose MusicKit as an ES6 Module instead of relying on a global variables, example:

import { MusicKit } from '@apple/music-kit' 

MusicKit.configure({   
  developerToken: 'DEVELOPER-TOKEN',     
  app: {
    name: 'My Cool Web App',
    build: '1978.4.1'    
  }
})


Thanks!

Replies

how dead

In order to ensure the best experience for the developer and users, MusicKit JS is distributed through our CDN servers and linked to your application using an HTML <script> tag.


In order to ensure support for as many browsers as possible, we don't expose this CDN version of the file as an ES6 module.


Is there a specific build system or framework that you are trying to use MusicKit JS with that you are having issue with?

Hello!


I didn't expect an answer after all this time to be honest so thanks!


Everyone knows the best developer experience working wth dependencies is with a package registry like npm. Yet I understand you're trying to keep as much control as you can over your code and depending on a 3rd party like npm is not very apple-like, you can say it outright.


Still, you could continue to serve it from your CDN but expose a ES module that doesn't rely on global variables!


Imagine:

<script src="js-cdn.music.apple.com/...">


would just become

<script type="module" src="js-cdn.music.apple.com/...">


or even


<script type="module">

import { MusicKit } from 'js-cdn.music.apple.com/...'

</script>