esm.sh

A fast, smart, & global CDN for modern(es2015+) web development.

MIT License

Downloads
3.5K
Stars
2.8K
Committers
62

Bot releases are hidden (Show)

esm.sh -

Published by ije over 1 year ago

in v115, we added ?module query to allow you import .wasm as a WebAssembly.Module Object:

import wasm from "https://esm.sh/@dqbd/[email protected]/tiktoken_bg.wasm?module"

const { exports } = WebAssembly.instantiate(wasm, imports)

Changelog:

  • Return JavaScript module for ?module query with .wasm files
  • Fix types transformer (close #581)
  • Fix incorrect named import of cjs modules (close #583)
  • Fix submodule path resolving (close #584)
  • Upgrade @types/node to 18
esm.sh -

Published by ije over 1 year ago

In v114, we switched to pnpm instead of yarn which can save the server disk space and improve the build performance significantly, and now the server can handle package files of private registry (thanks @Justinidlerz for contributing to this).

We upgraded esbuild to 0.17.14, and a new query ?conditions added as conditions option of esbuild:

import foo from "https://esm.sh/foo?conditions=custom1,custom2"

For Deno users, we fixed some incorrect/missed types. Thanks for @marvinhagemeister making him first great PR to this project.

Changelog:

  • Add ?conditions query as esbuild option
  • Use pnpm to install packages instead of yarn (save the server disk space & improve the build performance)
  • Serve static files on local (#564 @Justinidlerz)
  • Support .d.mts extension (close #580)
  • Fix CJS transpiling (close #577)
  • Fix types building (close #572, #576)
  • Fix invalid type URL if submodule is main entry (#579 @marvinhagemeister)
  • Upgrade esbuild to 0.17.14
esm.sh -

Published by ije over 1 year ago

  • express is working in Deno
  • Fix lost non-mjs-extension module caused by v112 (close #559)
  • Fix exports of netmask and xml2js (#561 @jcc10)
  • Fix default import of deps for cjs (close #565, #566)
esm.sh -

Published by ije over 1 year ago

The CDN serves over 5M requests each day currently, which is powered by Cloudflare's edge worker, it's globally fast! (you can check the benchmark by @azu: https://github.com/azu/npmcdn-upptime).

Changes:

  • Use .mjs extension for the package main module to resolve sub-path conflicts
  • Ignore ?exports query when importing stable modules
  • Fix npm naming regexp (close #541)
  • Fix tree shaking (close #521)
  • Fix package nested conditions export (#546 by @Justinidlerz)
  • Fix esm imports in cjs (close #557)
  • Improve server performance (#543 by @Justinidlerz)
  • Update the requireModeAllowList (close #540, #548)

For Deno:

  • Inject XHR polyfill for axios, cross-fetch, whatwg-fetch automatically
  • Fix node:buffer import for denonext target (closed #556)
  • CLI: Use user-specified indent size (#551 by @npg418)

Credits

Huge thanks to @Justinidlerz @npg418

esm.sh -

Published by ije over 1 year ago

  • Print package deprecated message
  • Remove source map URL of worker
  • Fix package CSS redirects with target option
  • Fix build dead-loop for some edge cases
  • Fix CLI update command (close #536)

CDN Update

Before when you import a module without specifying the package version like "https://esm.sh/react", it will redirect to latest version like "https://esm.sh/[email protected]", that means it needs to ask the NPM registry what the latest version of the package every time, in v111 we added a cache layer for the NPM registry to improve the redirect response time. Since we set the cache TTL to 10 minutes, so you may get the delay of the package latest update, but for a CDN the response time is the most important care-thing, the best practice is always point out the full version of packages like "https://esm.sh/[email protected]".

esm.sh -

Published by ije over 1 year ago

  • Fix invalid Content-Type header for dts files (close #534)
esm.sh -

Published by ije over 1 year ago

  • Ignore ?external option for stable builds
  • Fix react/jsx-runtime bundles react module
  • Remove alias export resolving (close #530)
esm.sh -

Published by ije over 1 year ago

  • Add denonext target to use deno 1.31 node compatibility layer, we will switch to the denonext target as default for deno once deno deploy supports node: specifier.
    import "https://esm.sh/your-package?target=denonext"
    
  • Redirect to CSS file for CSS packages
    https://esm.sh/normalize.css -> https://esm.sh/normalize.css/normalize.css
    
  • Fix wasm packages can't resolve the default wasm file.
    import init, { transform } from "https://esm.sh/lightningcss-wasm";
    // v107: you need to specify the wasm URL
    await init("https://esm.sh/lightningcss-wasm/lightningcss_node.wasm")
    // v108: you don't need to specify it
    await init()
    
  • Disable bundle mode for stable builds
  • Fix alias export (close #527)
  • Update references to reqOrigin to use cdnOrigin (#529 by @jaredcwhite)

Credits

Huge thanks to @jaredcwhite

esm.sh -

Published by ije over 1 year ago

  • Add ?cjs-export query (close #512)
    If you get an error like ...not provide an export named..., that means esm.sh can not resolve CJS exports of the module correctly. You can add ?cjs-exports=foo,bar query to specify the export names:
    import { NinetyRing, NinetyRingWithBg } from "https://esm.sh/[email protected]?cjs-exports=NinetyRing,NinetyRingWithBg"
    
  • Update requireModeAllowList (close #520)
  • Remove ?sourcemap query, always generate source map as inline url.
  • Default export all members from original module to prevent missing named exports members (#522)
  • Only apply patch if types are missing in preact (#523)
  • Upgrade esbuild to 0.17.10.
  • Upgrade deno/std to 0.177.0

Credits

Huge thanks to @Justinidlerz @zookatron

esm.sh -

Published by ije over 1 year ago

  • Just fix fake module export names resolving broken in v105 (close #510)
esm.sh -

Published by ije over 1 year ago

  • Check types which are not defined in package.json
  • Fix empty module build (close #483)
  • Fix exports field resolving (close #503)
  • Fix deno CLI script (close #505)
  • Fix incorrect redirects (close #508)
  • Fix invalid target with HeadlessChrome/ UA (close #509)
  • Upgrade deno/std to 0.175.0
esm.sh - v104

Published by ije over 1 year ago

  • Rewrite FileSystem interface of the storage
  • Fix submodule build with exports in package.json (close #497)
  • Fix es5-ext weird /#/ path (close #502)
esm.sh -

Published by ije almost 2 years ago

  • Add inject argument for worker factory, this is useful if you want to importScripts in the worker, but the module worker doesn't allow you to do it.
    import workerFactory from "https://esm.sh/[email protected]?worker";
    
    const workerInject = `
    self.onmessage = (e) => {
      // variable 'E' is the xxhash-wasm module default export
      E().then(hasher => {
        self.postMessage(hasher.h64ToString(e.data));
      })
    }
    `;
    
    const worker = workerFactory(workerInject);
    worker.onmessage = (e) => {
      console.log(e.data); // 502b0c5fc4a5704c
    };
    worker.postMessage("Hello");
    
  • Respect ?external arg in bundle mode (close #498)
  • Add require() syntax support for dts transformer
  • Fix import maps scope is not correct by the CLI script (close #480)
  • Fix basePath doesn't take effect on redirects (close #481)
  • Fix X-TypeScript-Types header not pined for stable builds
  • Fix some bugs related to package path parsing (#487)
  • Upgrade esbuild to 0.16.17
  • Upgrade deno/std to 0.173.0

Credits

Huge thanks to @goloveychuk @ahuigo @hjaurum @kidonng

esm.sh -

Published by ije almost 2 years ago

  • Support browser field of package.json to improve compatibility with npm packages in browser. For example, the webtorrent package will use memory-chunk-store instead of fs-chunk-store and exclude built-in modules like fs, net, os and so on.

    {
      "name": "webtorrent",
      "description": "Streaming torrent client",
      "version": "1.9.6",
      "browser": {
        "./lib/server.js": false,
        "./lib/conn-pool.js": false,
        "./lib/utp.js": false,
        "bittorrent-dht/client": false,
        "fs": false,
        "fs-chunk-store": "memory-chunk-store",
        "load-ip-set": false,
        "net": false,
        "os": false,
        "ut_pex": false
      },
    }
    

    (Close #450)

esm.sh -

Published by ije almost 2 years ago

  • Fix ?bundle mode with illegal paths (close #476).
  • Fix ?worker mode doesn't support CORS.
esm.sh - v100

Published by ije almost 2 years ago

🎉🎉🎉 We just updated the esm.sh website with brand-new design for the v100 release, please take a look!
https://esm.sh

image
image

And we also added a playground app that allows you to play ESM in browser without build tools.
https://playground.esm.sh

Other Changes:

  • Improve self-hosting configuration. check HOSTING.md for more details.
  • Support browser field when it's an es6 module (close #381).
  • Purge headers from unpkg.com to avoid repeated Access-Control-Allow-Origin header (close #453).
  • Fix content compression (close #460).
  • Fix alias export (close #471).
  • Fix cycle importing (close #464).
  • Fix scenarios where module/es2015 are shims (maps).
  • Fix worker cors issue.
  • Upgrade esbuild to 0.16.10.
  • Upgrade deno/std to 0.170.0.

Credits

Huge thanks to @hjaurum @chrisirhc @ThaUnknown @rxliuli

esm.sh -

Published by ije almost 2 years ago

  • Improve CDN cache performance, now you can get faster response time of .d.ts, .wasm and other static files.
  • Remove ?deps purge (close #422).
  • Remove ?exports query of sub build task.
  • Upgrade deno/std to 0.165.0.
esm.sh -

Published by ije almost 2 years ago

  • Add tree-shaking support for es modules
    import { __await, __rest } from "https://esm.sh/tslib" // 7.3KB
    import { __await, __rest } from "https://esm.sh/tslib?exports=__await,__rest" // 489B
    
  • Add node-fetch polyfill for browsers and deno
  • Fix exports resolver (close #422)
  • Restart ns process when got "unreachable" error (close #448)
  • cjs-lexer: Update swc to latest
esm.sh - v97

Published by ije almost 2 years ago

  • Add https://esm.sh/build-target endpoint to return the compatible target of current browser/runtime by checking User-Agent header, lowest is es2015.
  • Add --npm-token option for the server to support private packages (#435).
  • Update polyfills/node_process: replace timeout with queueMicrotask (#444).
  • Upgrade deno/std to 0.162.0.

Credits

Huge thanks to @Justinidlerz @ThaUnknown

esm.sh -

Published by ije about 2 years ago

  • Update the fake node fs ployfill for browsers(add createReadStream and createWriteStream methods)
  • Check package name (close #424)
  • Fix some invalid types bulids
  • Upgrade esbuild to 0.15.9