esm.sh

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 田修为
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

ESM

A fast, global content delivery network to transform NPM packages to standard ES Modules by esbuild.

Import from URL

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

Specify version

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

or import a major version:

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

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 a single JS file.

Development mode

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

The ?dev mode builds code with process.env.NODE_ENV equals to development, that is useful to build modules like React to allow you get more development warn/error details.

Specify external dependencies

import React from 'https://esm.sh/react@16.14.0'
import useSWR from 'https://esm.sh/swr?deps=react@16.14.0'

By default, esm.sh rewrites import specifier based on the package's dependency statement. To specify version of dependencies you can use the ?deps=PACKAGE@VERSION query. You can separate multiple dependencies with commas: ?deps=react@16.14.0,react-dom@16.14.0.

Aliasing dependencies

import useSWR from 'https://esm.sh/swr?alias=react:preact/compat'

in combination with ?deps:

import useSWR from 'https://esm.sh/swr?alias=react:preact/compat&deps=preact@10.5.14'

The origin idea was came from @lucacasonato.

Specify ESM target

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

By default, esm.sh will check the User-Agent header to get the build target automatically. You can specify it with the ?target query. Available targets: es2015 - es2021, esnext, node, and deno.

Package CSS

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

This only works when the NPM module imports css files in JS directly.

Deno compatibility

esm.sh will resolve the node internal modules (fs, child_process, 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()

X-Typescript-Types

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

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

To host esm.sh by yourself, check hosting documentation.

  • 之前一直求助于QQ旋风,但在其他Gateway,旋风也halt了 esg总是提供wget.sh script帮助unix用户下载,让我一度都想换系统 但总也懒得行事 今天突然发现了可以在java下运行的,支持unix/window/mac系统 DataMover-Lite 最最厉害的是,他居然可以执行sh文件!! You Can Feel It!!!! 哇,我终于可以摆脱现在这痛苦的境地了 今天下

  • 目录 前言 一、准备环境和代码 1.拷贝代码 二、机器相关的脚本文件配置 1.复制配置文件并命名 2.修改配置文件 (1)Macros.huanmy_intel  (2)config_machine.xml 三、创建case和编译 1.创建case 2.编译case 四、运行case 1.编写作业脚本 2.拷贝陆面模式初始场和强迫场 (1)mkdir timing (2)陆面资料  (3)修改一些

  • 问题描述 提示:这里描述具体问题:部署一个quasar框架,进行开发。 原因分析: 提示:这里填写问题的分析:这里填写该问题的具体解决方案:在一台从没有安过quasar的平台上跑项目,需要安装那些依赖完成quasar项目运行。 解决方案: 提示: 继续执行npm run start提示 sh: 1: quasar: not found 所以安装quasar npm i -g @quasar/ap

  • 参考一下: vue.esm.js?efeb:591 [Vue warn]: Invalid prop: type check failed for prop "data". Expected Array, got String..........

相关阅读

相关文章

相关问答

相关文档