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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay