DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Do you use CDN? Why? Why not? And yes, it does work with build process and TypeScript. What about CSS?

As long as you deliver processed JavaScript in <script type="module">, if the library is already an ES module.

For how to get the typings, you can use either JSDoc or *.d.ts.

import _react from 'https://cdn.skypack.dev/react';

/** @type {import('react')} */
const react = _react
Enter fullscreen mode Exit fullscreen mode

Or,

declare module 'https://cdn.skypack.dev/react' {
  export * from 'react'
}
Enter fullscreen mode Exit fullscreen mode

You still have to install React in package.json, though.

What about CSS? Fonts?

CSS and fonts doesn't have typings, anyway. (Unless you are talking about CSS module.) So, why don't you can consider a CDN?

Why is CDN missing for SVG icons, anyway?

Top comments (0)