Giter Club home page Giter Club logo

esm.sh's Introduction

ESM

A fast, global content delivery network for ES Modules. All modules in NPM are transformed to ESM by esbuild.

Import from URL

import React from 'https://esm.sh/react'

Specify version

import React from 'https://esm.sh/[email protected]'

Submodule

import { renderToString } from 'https://esm.sh/react-dom/server'

or import non-module(js) files:

import 'https://esm.sh/tailwindcss/dist/tailwind.min.css'

Bundle mode

import { Button } from 'https://esm.sh/antd?bundle'

In bundle mode, all dependencies will be bundled into one JS file.

Development mode

import React from 'https://esm.sh/react?dev'

Specify external deps

import React from 'https://esm.sh/[email protected]'
import useSWR from 'https://esm.sh/[email protected]'

Package CSS

import Daygrid from 'https://esm.sh/@fullcalendar/daygrid'
<link rel="stylesheet" href="https://esm.sh/@fullcalendar/daygrid?css">

Specify ESM target

import React from 'https://esm.sh/react?target=es2020'

By default, esm.sh will check the browser's User-Agent to get the build target, or set it based on the target query. Available targets: es2015 - es2020, esnext, and deno.

Deno compatibility

esm.sh will resolve the node internal modules (fs, os, etc.) with deno.land/std/node to support some packages working in Deno, like postcss:

import postcss from 'https://esm.sh/postcss'
import autoprefixer from 'https://esm.sh/autoprefixer'

const { css } = await postcss([ autoprefixer ]).process(`
  backdrop-filter: blur(5px);
  user-select: none;
`).async() 
console.log(css)

X-Typescript-Types

By default, esm.sh will respond with a custom X-TypeScript-Types HTTP header when types (.d.ts) are defined. This is useful for deno type checks (link).

figure #1

You can pass the no-check query to disable the X-TypeScript-Types header if some types are incorrect:

import unescape from 'https://esm.sh/lodash/unescape?no-check'

Network of esm.sh

Self-Hosting

You will need Go 1.16+ to compile the server, and ensure supervisor installed on your host machine.
The server runtime will install the nodejs (14 LTS) automatically.

$ git clone https://github.com/postui/esm.sh
$ cd esm.sh
$ sh ./scripts/deploy.sh

esm.sh's People

Contributors

asafamr avatar douglasduteil avatar ije avatar marktiedemann avatar voces avatar wleonardo avatar zhoukekestar avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.