Git Product home page Git Product logo

esm.sh's Introduction

esm.sh

Docker Discord Sponsors

esm.sh

A global fast and smart CDN(aka content delivery network) for modern(es2015+) web development.

How to Use

esm.sh allows you to import es6 modules from a URL directly in the browser or Deno. No install/build step needed.

import * as mod from "https://esm.sh/PKG[@SEMVER][/PATH]";

or use bare specifier instead of URL with import maps:

<script type="importmap">
{
  "imports": {
    "react": "https://esm.sh/[email protected]"
  }
}
</script>
<script type="module">
  import React from "react" // alias to https://esm.sh/[email protected]
</script>

More details check out here.

Supported Registries

  • NPM(default):
    // Examples
    import React from "https://esm.sh/react"; // 18.3.0 (latest)
    import React from "https://esm.sh/react@17"; // 17.0.2
    import React from "https://esm.sh/react@beta"; // 19.0.0-beta-94eed63c49-20240425
    import { renderToString } from "https://esm.sh/[email protected]/server"; // submodules
  • Github (starts with /gh/):
    // Examples
    import tslib from "https://esm.sh/gh/microsoft/[email protected]"; // '2.6.0' is the git tag name
    // or fetch an asset file from github
    fetch("https://esm.sh/gh/microsoft/fluentui-emoji/assets/Party%20popper/Color/party_popper_color.svg");
  • JSR (starts with /jsr/):
    // Examples
    import * as mod from "https://esm.sh/jsr/@std/[email protected]/base64";
    import { html } from "https://esm.sh/jsr/@mark/html@1";

Specifying Dependencies

By default, esm.sh rewrites import specifiers based on the package dependencies. To specify the version of these dependencies, you can add the ?deps=PACKAGE@VERSION query. To specify multiple dependencies, separate them with a comma, like this: [email protected],[email protected].

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

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&[email protected]";

The original idea came from @lucacasonato.

Tree Shaking

By default, esm.sh exports a module with all its exported members. However, if you want to import only a specific set of members, you can specify them by adding a ?exports=foo,bar query to the import statement.

import { __await, __rest } from "https://esm.sh/tslib"; // 7.3KB
import { __await, __rest } from "https://esm.sh/tslib?exports=__await,__rest"; // 489B

By using this feature, you can take advantage of tree shaking with esbuild and achieve a smaller bundle size. Note that this feature is only supported for ESM modules and not CJS modules.

Bundling Strategy

By default, esm.sh bundles sub-modules that ain't declared in the exports field.

Bundling sub-modules can reduce the number of network requests for performance. However, it may bundle shared modules repeatedly. In extreme case, it may break the side effects of the package, or change the import.meta.url semantics. To avoid this, you can add ?bundle=false to disable the default bundling behavior:

import "https://esm.sh/@pyscript/core?bundle=false";

For package authors, you can override the bundling strategy by adding the esm.sh field to package.json:

{
  "name": "foo",
  "esm.sh": {
    "bundle": false // disables the default bundling behavior
  }
}

esm.sh also supports ?standalone query to bundle the module with all external dependencies(except in peerDependencies) into a single JS file.

import { Button } from "https://esm.sh/antd?standalone";

Development Mode

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

With the ?dev option, esm.sh builds a module with process.env.NODE_ENV set to "development" or based on the condition development in the exports field. This is useful for libraries that have different behavior in development and production. For example, React uses a different warning message in development mode.

ESBuild Options

By default, esm.sh checks the User-Agent header to determine the build target. You can also specify the target by adding ?target, available targets are: es2015 - es2022, esnext, deno, denonext, node and bun.

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

Other supported options of esbuild:

  • Conditions
    import foo from "https://esm.sh/foo?conditions=custom1,custom2";
  • Keep names
    import foo from "https://esm.sh/foo?keep-names";
  • Ignore annotations
    import foo from "https://esm.sh/foo?ignore-annotations";

Web Worker

esm.sh supports ?worker query to load the module as a web worker:

import createWorker from "https://esm.sh/monaco-editor/esm/vs/editor/editor.worker?worker";

// create a worker
const worker = createWorker();
// rename the worker by adding the `name` option
const worker = createWorker({ name: "editor.worker" });
// inject code into the worker
const worker = createWorker({ inject: "self.onmessage = (e) => self.postMessage(e.data)" });

You can import any module as a worker from esm.sh with the ?worker query. Plus, you can access the module's exports in the inject code. For example, uing the xxhash-wasm to hash strings in a worker:

import createWorker from "https://esm.sh/[email protected]?worker";

// variable '$module' is the imported 'xxhash-wasm' module
const inject = `
const xxhash = $module.default
self.onmessage = async (e) => {
  const hasher = await xxhash()
  self.postMessage(hasher.h64ToString(e.data))
}
`;
const worker = createWorker({ inject });
worker.onmessage = (e) => console.log("hash is", e.data);
worker.postMessage("The string that is being hashed");

Note: The inject must be a valid JavaScript code, and it will be executed in the worker context.

Package CSS

<link rel="stylesheet" href="https://esm.sh/monaco-editor?css">

This only works when the package imports CSS files in JS directly.

Importing WASM as Module

esm.sh supports importing wasm modules in JS directly, to do that, you need to add ?module query to the import URL:

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

const { exports } = new WebAssembly.Instance(wasm, imports);

Note: The *.wams?module pattern requires the top-level-await feature to be supported by the browser.

Using Import Maps

Import Maps has been supported by most modern browsers and Deno natively. This allows bare import specifiers, such as import React from "react", to work.

esm.sh introduces the ?external=foo,bar query for specifying external dependencies. By employing this query, esm.sh maintains the import specifier intact, leaving it to the browser/Deno to resolve based on the import map. For example:

{
  "imports": {
    "preact": "https://esm.sh/[email protected]",
    "preact-render-to-string": "https://esm.sh/[email protected]?external=preact"
  }
}

Alternatively, you can mark all dependencies as external by adding a * prefix before the package name:

{
  "imports": {
    "preact": "https://esm.sh/[email protected]",
    "preact-render-to-string": "https://esm.sh/*[email protected]",
    "swr": "https://esm.sh/*[email protected]",
    "react": "https://esm.sh/[email protected]/compat"
  }
}

Import maps supports trailing slash that can not work with URL search params friendly. To fix this issue, esm.sh provides a special format for import URL that allows you to use query params with trailing slash: change the query prefix ? to & and put it after the package version.

{
  "imports": {
    "react-dom": "https://esm.sh/[email protected]?dev",
    "react-dom/": "https://esm.sh/[email protected]&dev/"
  }
}

Escape Hatch: Raw Source Files

In rare cases, you may want to request JS source files from packages, as-is, without transformation into ES modules. To do so, you need to add a ?raw query to the request URL.

For example, you might need to register a package's source script as a service worker in a browser that does not yet support the type: "module" option:

await navigator.serviceWorker.register(
  new URL(
    "https://esm.sh/playground-elements/playground-service-worker.js?raw",
    import.meta.url.href,
  ),
  { scope: "/" },
);

You may alternatively use raw.esm.sh as the origin, which is equivalent to esm.sh/<PATH>?raw:

<playground-project sandbox-base-url="https://raw.esm.sh/playground-elements/"></playground-project>

so that transitive references in the raw assets will also be raw requests.

Deno Compatibility

esm.sh is a Deno-friendly CDN that resolves Node's built-in modules (such as fs, os, net, etc.), making it compatible with Deno.

import express from "https://esm.sh/express";

const app = express();
app.get("/", (req, res) => {
  res.send("Hello World");
});
app.listen(3000);

For users using deno < 1.33.2, esm.sh uses deno.land/[email protected]/node as the node compatibility layer. You can specify a different version by adding the ?deno-std=$VER query:

import postcss from "https://esm.sh/express?deno-std=0.128.0";

Deno supports type definitions for modules with a types field in their package.json file through the X-TypeScript-Types header. This makes it possible to have type checking and auto-completion when using those modules in Deno. (link).

Figure #1

In case the type definitions provided by the X-TypeScript-Types header is incorrect, you can disable it by adding the ?no-dts query to the module import URL:

import unescape from "https://esm.sh/lodash/unescape?no-dts";

This will prevent the X-TypeScript-Types header from being included in the network request, and you can manually specify the types for the imported module.

Supporting Nodejs/Bun

Nodejs(18+) supports http importing under the --experimental-network-imports flag. Bun doesn't support http modules yet.

We highly recommend Reejs as the runtime with esm.sh that works both in Nodejs and Bun.

Global CDN

The Global CDN of esm.sh is provided by Cloudflare, one of the world's largest and fastest cloud network platforms.

Self-Hosting

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

esm.sh's People

Contributors

abetaev avatar alienzhou avatar canrau avatar edeustace avatar goloveychuk avatar hellojukay avatar hjaurum avatar ije avatar jimisaacs avatar johnpangalos avatar justinidlerz avatar kateinoigakukun avatar kevinfiol avatar kidonng avatar kyiro avatar lewisl9029 avatar marcushultman avatar marktiedemann avatar mashaal avatar motss avatar olekenneth avatar patrickjs avatar renhiyama avatar rivy avatar rynomad avatar thaunknown avatar voces avatar wleonardo avatar yoavbls avatar zookatron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esm.sh's Issues

@types/prop-types build failed

Hey, I try to build my website using aleph 3.0 alpha 8, but the following file failed to build

https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts

/* esm.sh - error */
throw new Error("[esm.sh] " + "esbuild: The constant \"nominalTypeHack\" must be initialized");
export default null;

11:55:24 PM 02/08/2021: INFO Aleph server config loaded from aleph.config.js
11:55:24 PM 02/08/2021: INFO Building...
11:55:25 PM 02/08/2021: INFO Download https://esm.sh/[email protected]
11:55:26 PM 02/08/2021: INFO Download https://cdn.esm.sh/v15/[email protected]/esnext/react.js
11:55:26 PM 02/08/2021: INFO Download https://deno.land/x/[email protected]/mod.ts
11:55:27 PM 02/08/2021: INFO Download https://deno.land/x/[email protected]/framework/react/hooks.ts
11:55:27 PM 02/08/2021: INFO Download https://deno.land/x/[email protected]/framework/react/context.ts
11:55:27 PM 02/08/2021: INFO Download https://deno.land/x/[email protected]/framework/react/util.ts
11:55:27 PM 02/08/2021: INFO Download https://deno.land/x/[email protected]/framework/react/error.ts
11:55:28 PM 02/08/2021: INFO Download https://esm.sh/@ethersproject/providers
11:55:28 PM 02/08/2021: INFO Download https://cdn.esm.sh/v15/@ethersproject/[email protected]/esnext/providers.js
11:55:30 PM 02/08/2021: INFO Download https://cdn.esm.sh/v15/_process_browser.js
11:55:31 PM 02/08/2021: INFO Download https://esm.sh/[email protected]
11:55:31 PM 02/08/2021: INFO Download https://cdn.esm.sh/v15/[email protected]/esnext/react-dom.js
11:55:32 PM 02/08/2021: INFO Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts
11:55:33 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:34 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:35 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:36 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:37 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:37 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:38 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:39 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:39 PM 02/08/2021: WARN Download https://cdn.esm.sh/v13/@types/[email protected]/index.d.ts failed, retrying...
11:55:40 PM 02/08/2021: error: Uncaught (in promise) Error: Internal Server Error
11:55:40 PM 02/08/2021: return Promise.reject(new Error(resp.statusText));
11:55:40 PM 02/08/2021: ^
11:55:40 PM 02/08/2021: at app.ts:1141:35
11:55:40 PM 02/08/2021: at async Application.fetchDependency (app.ts:1139:24)
11:55:40 PM 02/08/2021: at async Application.compile (app.ts:800:25)
11:55:40 PM 02/08/2021: at async Application.compile (app.ts:983:22)
11:55:40 PM 02/08/2021: at async Application.compile (app.ts:983:22)
11:55:40 PM 02/08/2021: at async Application.compile (app.ts:983:22)
11:55:40 PM 02/08/2021: at async Application.compile (app.ts:983:22)
11:55:40 PM 02/08/2021: at async Application.init (app.ts:455:19)
11:55:40 PM 02/08/2021: at async Application.build (app.ts:239:5)
11:55:40 PM 02/08/2021: at async default (build.ts:18:3)
11:56:07 PM 02/08/2021: Error occured during the build.

Unable to bundle graphql

INFO Download https://esm.sh/graphql โ€ข https://esm.sh/graphql?target=es2018&dev
error: Uncaught (in promise) Error: Download https://esm.sh/graphql: Download https://esm.sh/graphql: 500 - Internal Server Error

When traversing to https://esm.sh/graphql?target=es2018&dev you get

/* esm.sh - error */
throw new Error("[esm.sh] " + "esbuild: \"graphql\" has already been declared");
export default null;

Auto Alias to Node Compat Layer

Recently Skypack launched a feature kind of like what ESM.sh does - uses the node compat layer. Instead of having deno bundle stuff which needs to be committed they auto alias it to the URL to the node compat layer. I think this is a great feature as it removes the need to do chore commits to add the polyfills.

Argument of type 'TransformerFactory<SourceFile>' is not assignable to parameter of type 'TransformerFactory<SourceFile> | CustomTransformerFactory'

I'm not sure if this is an aleph.js or an esm.sh issue:

error: Uncaught (in promise) TypeError: TS2345 [ERROR]: Argument of type 'TransformerFactory<SourceFile>' is not assignable to parameter of type 'TransformerFactory<SourceFile> | CustomTransformerFactory'.
  Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").TransformerFactory<import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").SourceFile>' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").TransformerFactory<import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").SourceFile>'.
    Types of parameters 'context' and 'context' are incompatible.
      Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").TransformationContext' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").TransformationContext'.
        The types of 'factory.createTypeParameterDeclaration(...).parent' are incompatible between these types.
          Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").DeclarationWithTypeParameterChildren | import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").InferTypeNode' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").DeclarationWithTypeParameterChildren | import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").InferTypeNode'.
            Type 'JSDocTemplateTag' is not assignable to type 'DeclarationWithTypeParameterChildren | InferTypeNode'.
              Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDocTemplateTag' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDocTemplateTag'.
                Types of property 'parent' are incompatible.
                  Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDoc | import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDocTypeLiteral' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDoc | import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDocTypeLiteral'.
                    Type 'JSDoc' is not assignable to type 'JSDoc | JSDocTypeLiteral'.
                      Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDoc' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").JSDoc'.
                        Types of property 'parent' are incompatible.
                          Type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").HasJSDoc' is not assignable to type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").HasJSDoc'.
                            Type 'ImportEqualsDeclaration' is not assignable to type 'HasJSDoc'.
                              Property 'isTypeOnly' is missing in type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").ImportEqualsDeclaration' but required in type 'import("https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts").ImportEqualsDeclaration'.
    if (reactRefresh) transformers.before!.push(reactRefreshTS())
                                                ~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/tsc/compile.ts:28:49

    'isTypeOnly' is declared here.
            readonly isTypeOnly: boolean;
                     ~~~~~~~~~~
        at https://cdn.esm.sh/v40/[email protected]/lib/typescript.d.ts:1601:18
    const { default: cmd } = await import(`./cli/${command}.ts`)
                             ^
    at async main (https://deno.land/x/[email protected]/cli.ts:163:30)

tailwindcss error

"Buffer.from is not a function" when using ESM package

Hey, I'm trying to use web3 from ESM

import Web3 from "https://esm.sh/web3"

export default function Home() {
  return null;
}

But when loading the page I'm getting this error

TypeError: Buffer.from is not a function
    at varintEncode (file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:31889:23)
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:31900:37
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:69:9
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:31930:33
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:69:9
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:34701:18
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:69:9
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:34738:23
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:69:9
    at file:///.../.aleph/development.es2018/-/cdn.esm.sh/v11/[email protected]/es2018/web3.development.js:34833:23

production use

I'm trying to create modern build stack using javascript modules and dynamic imports. And today this is very much possible for example with rollup and modules from npm, with esm.sh even better for loading modules directly from CDN.

The problem is production use and old browsers, it's possible now to use rollup and @babel/env to use javascript modules and dynamic imports as amd with requirejs, but that only works for npm imported es modules. (eg. https://web.dev/publish-modern-javascript/#@rollupplugin-babel)

      dir: 'dist/js',
      format: 'esm',
      entryFileNames: '[name].es5.js',
      chunkFileNames: '[name].[hash].es5.js',
      plugins: [
        getBabelOutputPlugin({
          presets: [['@babel/env', { modules: 'amd', targets: {
              esmodules: true,
            } }]],
        }),
      ]

So my question is, if it's possible to do something like import React from 'https://esm.sh/react?target=amd'? That way there could be a rollup plugin that would add correct urls for legacy builds.

And ssh.sh could be very much be used as CDN for es modules in production. Thoughts?

Panic on @material-ui/styles import

Importing https://cdn.esm.sh/v9/@material-ui/[email protected]/withStyles.d.ts (dependency of @material-ui/core) will result in the following

/* esm.sh - error */
throw new Error("[esm.sh] " + "yarn: warning package.json: No license field\nwarning No license field\nerror An unexpected error occurred: \"https://registry.yarnpkg.com/@material-ui%2fstyles/withStyles.d.ts: Request \\\"https://registry.yarnpkg.com/@material-ui%2fstyles/withStyles.d.ts\\\" returned a 405\".\n");
export default null;

Strange esm.sh error

Hey!

For some reason we can't start our project (this project is inside a docker and it was ok before last releases of esm.sh).

The error is the following:

Check https://deno.land/x/[email protected]/cli/start.ts
error: Uncaught (in promise) TypeError: AssertionError: "data" is unexpectedly null for "https://esm.sh/v25/_node.ns.d.ts".
    at assert (deno:cli/tsc/99_main_compiler.js:59:13)
    at Object.getSourceFile (deno:cli/tsc/99_main_compiler.js:268:7)
    at findSourceFileWorker (deno:cli/tsc/00_typescript.js:106861:29)
    at findSourceFile (deno:cli/tsc/00_typescript.js:106771:26)
    at deno:cli/tsc/00_typescript.js:106728:85
    at getSourceFileFromReferenceWorker (deno:cli/tsc/00_typescript.js:106695:34)
    at processSourceFile (deno:cli/tsc/00_typescript.js:106728:13)
    at deno:cli/tsc/00_typescript.js:107014:17
    at Object.forEach (deno:cli/tsc/00_typescript.js:382:30)
    at processReferencedFiles (deno:cli/tsc/00_typescript.js:107012:16)
    ```

/* esm.sh - error */ no such file or directory

Problem

import toMarkdown_ from "https://esm.sh/mdast-util-to-markdown"; yields => Error: Unable to resolve media type for specifier: "https://cdn.esm.sh/v35/[email protected]/types.d.ts"

https://cdn.esm.sh/v35/[email protected]/types.d.ts yields:

/* esm.sh - error */
throw new Error("[esm.sh] " + "open /tmp/esm-build-413904a1d3c767a56b2ad4a8af7be3e19623444b/node_modules/mdast-util-to-markdown/types.d.ts.js: no such file or directory");
export default null;

Seems like the cache is corrupt, or a bad references is produced

Cannot Import Submodule CSS

Hey guys, I was trying to use ant.design components with alephjs, which recommends using esm.sh for npm imports. I tried importing the CSS file: https://esm.sh/antd/dist/antd.css, however it throws a 500 error.

Is importing CSS beyond the intended usage of esm.sh ?

Do let me know. Thanks

`stream-browserify`

Thank you for esm.sh, of all the things I tried this gets me the closest to running telegraf on Deno. But not close enough:

~
$ deno --version
deno 1.7.1 (release, x86_64-pc-windows-msvc)
v8 8.9.255.3
typescript 4.1.3

~
$ deno eval 'import "https://esm.sh/[email protected]?dev"'
error: Uncaught SyntaxError: The requested module '/v15/[email protected]/esnext/stream-browserify.development.js' does not provide an export named 'Readable'
import {Readable} from "/v15/[email protected]/esnext/stream-browserify.development.js";
        ~~~~~~~~
    at <anonymous> (https://cdn.esm.sh/v15/[email protected]/esnext/telegraf.development.js:1542:9)

[1] ~
$

telegraf depends on sandwich-stream, which has an .mjs entry which import { Readable } from 'stream'. This is legal:

~
$ node --version
v14.0.0

~
$ node --input-type=module --eval 'import { Readable } from "stream"'

~
$

However, stream-browserify, used by esm.sh to ponyfill stream, doesn't support it. I can open a PR, but only if @goto-bus-stop or another maintainer promises to actually review it.

Otherwise, esm.sh should switch to better maintained ponyfill, perhaps https://deno.land/std/node/stream.ts?

Could not resolve "react/v39/[email protected]/deno/object-assign"

I have not much to add other than the error:

Uncaught Error: [esm.sh] esbuild: Could not resolve "react/v39/[email protected]/deno/object-assign" (mark it as external to exclude it from the bundle)
    <anonymous> object-assign.development.js:1
object-assign.development.js:1:20
    <anonymous> object-assign.development.js:1
    InnerModuleEvaluation self-hosted:2379
    InnerModuleEvaluation self-hosted:2379
    InnerModuleEval

Module exports { default, __esModule }

When importing the default export from WalletConnect

import WalletConnect from "https://esm.sh/@walletconnect/web3-provider"

console.log(WalletConnect)

Which is a class in my editor

Capture

However, when deploying (aleph dev) I get the following object instead

Capture

name export error

https://esm.sh/domhandler

all name export is undefined
image

the problem is: name export not from domhandler.default

i think maybe we need reslove name export is from default or not

image

input.js like this:
image

Does not work with shared instance and subdirectory

I found some patterns.

  • preact & preact/hooks
  • svelte & svelte/internal

Example

preact case

import { h, render } from "https://esm.sh/preact";
import { useEffect } from "https://esm.sh/preact/hooks";

function App (){
  useEffect(() => {
     console.log("mounted");
  });
  return <div></div>
}

svelte case.

<script>
  import { onMount } from "svelte";
  onMount()
</script>

compiled svelte has import { ... } from "svelte/internal".

To be common to both, they have to share the same instance in its inside. esm.sh failed.

(skypack works in these cases)

React.FC missing?

I've just tried using this im/export:
deps/react.ts

export { default as React } from "https://esm.sh/[react,react-dom]/react?dev&no-check";

But when I tried to create JSX component as const MyComponent: React.FC<MyComponentProps> = ({ prop1, ..., children }) => { ... }, it'd give out error that the prop bindings are implicit any.

And in test code, I can't find FC nor FunctionalComponent in imported React

deps/react.test.ts

import { React } from "./react.ts";

// ...
  console.log("React=",React);
  console.log("React.FC=",React.FC);

Output:

React= {
  default: {
    Fragment: Symbol(react.fragment),
    StrictMode: Symbol(react.strict_mode),
    Profiler: Symbol(react.profiler),
    Suspense: Symbol(react.suspense),
    Children: {
      map: [Function: mapChildren],
      forEach: [Function: forEachChildren],
      count: [Function: countChildren],
      toArray: [Function: toArray],
      only: [Function: onlyChild]
    },
    Component: [Function: Component],
    PureComponent: [Function: PureComponent],
    __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
      ReactCurrentDispatcher: { current: null },
      ReactCurrentBatchConfig: { transition: 0 },
      ReactCurrentOwner: { current: null },
      IsSomeRendererActing: { current: false },
      assign: [Function: assign],
      ReactDebugCurrentFrame: {
        setExtraStackFrame: [Function],
        getCurrentStack: null,
        getStackAddendum: [Function]
      }
    },
    cloneElement: [Function: cloneElementWithValidation],
    createContext: [Function: createContext],
    createElement: [Function: createElementWithValidation],
    createFactory: [Function: createFactoryWithValidation],
    createRef: [Function: createRef],
    forwardRef: [Function: forwardRef],
    isValidElement: [Function: isValidElement],
    lazy: [Function: lazy],
    memo: [Function: memo],
    useCallback: [Function: useCallback],
    useContext: [Function: useContext],
    useDebugValue: [Function: useDebugValue],
    useEffect: [Function: useEffect],
    useImperativeHandle: [Function: useImperativeHandle],
    useLayoutEffect: [Function: useLayoutEffect],
    useMemo: [Function: useMemo],
    useReducer: [Function: useReducer],
    useRef: [Function: useRef],
    useState: [Function: useState],
    version: "17.0.1"
  },
  Fragment: [Getter],
  StrictMode: [Getter],
  Profiler: [Getter],
  Suspense: [Getter],
  Children: [Getter],
  Component: [Getter],
  PureComponent: [Getter],
  __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: [Getter],
  cloneElement: [Getter],
  createContext: [Getter],
  createElement: [Getter],
  createFactory: [Getter],
  createRef: [Getter],
  forwardRef: [Getter],
  isValidElement: [Getter],
  lazy: [Getter],
  memo: [Getter],
  useCallback: [Getter],
  useContext: [Getter],
  useDebugValue: [Getter],
  useEffect: [Getter],
  useImperativeHandle: [Getter],
  useLayoutEffect: [Getter],
  useMemo: [Getter],
  useReducer: [Getter],
  useRef: [Getter],
  useState: [Getter],
  version: [Getter]
}
React.FC= undefined

Did I miss something here, or is React.FC just deprecated ?

Exports not exported for graphql-request

Esm.sh does not correctly export non default exports. When using skypack it does.

Take graphql-request for example.
Graphql-request does export a gql function.
https://github.com/prisma-labs/graphql-request/blob/5b233c5658e65ed0d98cf8bff50beec413f399b9/src/index.ts#L223

Using skypack:

import request, {gql} from "https://cdn.skypack.dev/graphql-request";
console.log(gql); // function...

Using esm.sh:

import request, {gql} from "https://esm.sh/graphql-request";
console.log(gql); // undefined

What's strange is when you download the esm.sh bundle (https://cdn.esm.sh/v14/[email protected]/esnext/graphql-request.js) it contains the following at the end. Which clearly contains gql...

...
export {
    jt as ClientError, At as GraphQLClient, It as
    default, Bt as gql, _t as rawRequest, Ft as request
};

Duplicate type declarations on some libraries

Problem

While trying to import xss:

import { filterXSS } from 'https://esm.sh/xss'

I came across with this error:

deno run -r render.ts
Download https://esm.sh/xss?nocheck
Download https://cdn.esm.sh/v28/[email protected]/deno/xss.js
Download https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts
Check file:///home/v1rtl/Coding/deno-libs/gql/graphiql/render.ts
error: TS2300 [ERROR]: Duplicate identifier 'OnTagHandler'.
      type OnTagHandler = (
           ~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:93:12

    'OnTagHandler' was also declared here.
          type OnTagHandler = (
               ~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:281:12

TS2300 [ERROR]: Duplicate identifier 'OnTagAttrHandler'.
      type OnTagAttrHandler = (
           ~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:99:12

    'OnTagAttrHandler' was also declared here.
          type OnTagAttrHandler = (
               ~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:287:12

TS2300 [ERROR]: Duplicate identifier 'SafeAttrValueHandler'.
      type SafeAttrValueHandler = (
           ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:106:12

    'SafeAttrValueHandler' was also declared here.
          type SafeAttrValueHandler = (
               ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:294:12

TS2300 [ERROR]: Duplicate identifier 'EscapeHandler'.
      type EscapeHandler = (str: string) => string;
           ~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:113:12

    'EscapeHandler' was also declared here.
          type EscapeHandler = (str: string) => string;
               ~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:301:12

TS2300 [ERROR]: Duplicate identifier 'OnTagHandler'.
      type OnTagHandler = (
           ~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:281:12

    'OnTagHandler' was also declared here.
          type OnTagHandler = (
               ~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:93:12

TS2300 [ERROR]: Duplicate identifier 'OnTagAttrHandler'.
      type OnTagAttrHandler = (
           ~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:287:12

    'OnTagAttrHandler' was also declared here.
          type OnTagAttrHandler = (
               ~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:99:12

TS2300 [ERROR]: Duplicate identifier 'SafeAttrValueHandler'.
      type SafeAttrValueHandler = (
           ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:294:12

    'SafeAttrValueHandler' was also declared here.
          type SafeAttrValueHandler = (
               ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:106:12

TS2300 [ERROR]: Duplicate identifier 'EscapeHandler'.
      type EscapeHandler = (str: string) => string;
           ~~~~~~~~~~~~~
    at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:301:12

    'EscapeHandler' was also declared here.
          type EscapeHandler = (str: string) => string;
               ~~~~~~~~~~~~~
        at https://cdn.esm.sh/v28/[email protected]/typings/xss.d.ts:113:12

Found 8 errors.

Temporary solution

Add the ?no-check to module URL.

[BUG?]: error throw since update

ref: timreichen/Bundler#29 (comment)

https://esm.sh/[email protected]?no-check returns

/* esm.sh - error */
throw new Error("[esm.sh] " + "copyDTS(@types/[email protected]/index.d.ts): read /tmp/esmd-build/d33c8a41ecd5db81/node_modules: is a directory");
export default null;

whereas before it didn't and worked as expected. My local cache file has this content:

/* esm.sh - [email protected] */
export * from "https://cdn.esm.sh/v15/[email protected]/esnext/postcss-preset-env.js?no-check";
export { default } from "https://cdn.esm.sh/v15/[email protected]/esnext/postcss-preset-env.js?no-check";

Is this a bug?

Bundle doesn't seem to have been generated - 404

INFO Download https://esm.sh/react โ€ข https://esm.sh/[react,react-hook-form,@fluentui/react,react-flow-renderer,swr]/react?target=es2018&dev
INFO Download https://cdn.esm.sh/bundle-ojv7uwoviwslf342bemex5fq7b4wvqk3.js 
error: Uncaught (in promise) Error: Download https://cdn.esm.sh/bundle-ojv7uwoviwslf342bemex5fq7b4wvqk3.js: Download https://cdn.esm.sh/bundle-ojv7uwoviwslf342bemex5fq7b4wvqk3.js: 404 - Not Found
                    throw new Error(`Download ${url}: ${err.message}`)

import_map.json

{
    "imports": {
        "https://esm.sh/": "https://esm.sh/[react,react-hook-form,@fluentui/react,react-flow-renderer,swr]/"
    }
}

Error with `stripe` package

Using the https://esm.sh/stripe package gives the error,

error: TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    export * from '/v33/@types/[email protected]/http.d.ts';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v33/@types/[email protected]/http.d.ts:2:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import * as stream from '/v33/node:stream';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v33/@types/[email protected]/http.d.ts:6:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import { URL } from '/v33/node:url';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v33/@types/[email protected]/http.d.ts:7:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import { Socket, Server as NetServer } from '/v33/node:net';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v33/@types/[email protected]/http.d.ts:8:5

Trying with https://esm.sh/stripe?no-check gives,

error: Uncaught ReferenceError: require is not defined
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:4:12741
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:1:763
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:4:23152
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:1:763
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:4:29463
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:1:763
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:5:10580
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:1:763
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:5:15340
    at https://cdn.esm.sh/v33/[email protected]/deno/stripe.js:1:763

Fix JSON error in docs

In Bundle Mode of README.md, I see this

{
    "imports": {
        "https://esm.sh/": "https://esm.sh/[react,react-dom,swr]/",
        ...
    }
}

Which causes markdown error validation on ...

You can comment this out, but JSON does not allow comments so you'll still an error.

Solution: Use json5 syntax which supports comments.

```json5
{
    "imports": {
        "https://esm.sh/": "https://esm.sh/[react,react-dom,swr]/",
        // ...
    }
}
```
{
    "imports": {
        "https://esm.sh/": "https://esm.sh/[react,react-dom,swr]/",
        // ...
    }
}

[Error]: Import or export declaration

I came across these errors while trying to download html-minifier. Is this intentional or can it be fixed?

Download http://esm.sh/html-minifier
Download https://cdn.esm.sh/v27/[email protected]/deno/html-minifier.js
Download https://cdn.esm.sh/v27/@types/[email protected]/index.d.ts
Download https://cdn.esm.sh/v27/[email protected]/deno/stream-http.js
Download https://cdn.esm.sh/v27/[email protected]/deno/url.js
Download https://cdn.esm.sh/v27/[email protected]/deno/https-browserify.js
Download https://cdn.esm.sh/v27/_node_process.js
Download https://cdn.esm.sh/v27/[email protected]/deno/path-browserify.js
Download https://cdn.esm.sh/v27/[email protected]/deno/browser.js
Download https://cdn.esm.sh/v27/_node_buffer.js
Download https://deno.land/[email protected]/node/fs.ts
Download https://cdn.esm.sh/v27/@types/[email protected]/index.d.ts
Download https://cdn.esm.sh/v27/@types/[email protected]/index.d.ts
Download https://cdn.esm.sh/v27/@types/[email protected]/index.d.ts
Download https://cdn.esm.sh/v27/[email protected]/deno/buffer.js
Download https://cdn.esm.sh/v27/[email protected]/deno/events.js
Download https://cdn.esm.sh/v27/[email protected]/deno/util.js
Download https://cdn.esm.sh/v27/[email protected]/deno/punycode.js
Download https://cdn.esm.sh/v27/[email protected]/deno/querystring-es3.js
Download https://cdn.esm.sh/v27/@types/[email protected]/http.d.ts
Download https://cdn.esm.sh/v27/@types/[email protected]/https.d.ts
Download https://esm.sh/v27/_node.ns.d.ts
Download https://cdn.esm.sh/v27/[email protected]/source-map.d.ts
Download https://deno.land/[email protected]/node/_fs/_fs_chown.ts
Download https://deno.land/[email protected]/node/_fs/_fs_mkdir.ts
Download https://deno.land/[email protected]/node/_fs/_fs_constants.ts
Download https://deno.land/[email protected]/node/_fs/_fs_mkdtemp.ts
Download https://deno.land/[email protected]/node/_fs/_fs_realpath.ts
Download https://deno.land/[email protected]/node/_fs/_fs_rmdir.ts
Download https://deno.land/[email protected]/node/_fs/_fs_access.ts
Download https://deno.land/[email protected]/node/_fs/_fs_appendFile.ts
Download https://deno.land/[email protected]/node/_fs/_fs_unlink.ts
Download https://deno.land/[email protected]/node/_fs/_fs_readdir.ts
Download https://deno.land/[email protected]/node/_fs/_fs_watch.ts
Download https://deno.land/[email protected]/node/_fs/_fs_open.ts
Download https://deno.land/[email protected]/node/_fs/_fs_stat.ts
Download https://deno.land/[email protected]/node/_fs/_fs_lstat.ts
Download https://deno.land/[email protected]/node/_fs/_fs_truncate.ts
Download https://deno.land/[email protected]/node/_fs/promises/mod.ts
Download https://deno.land/[email protected]/node/_fs/_fs_rename.ts
Download https://deno.land/[email protected]/node/_fs/_fs_close.ts
Download https://deno.land/[email protected]/node/_fs/_fs_writeFile.ts
Download https://deno.land/[email protected]/node/_fs/_fs_chmod.ts
Download https://deno.land/[email protected]/node/_fs/_fs_readFile.ts
Download https://deno.land/[email protected]/node/_fs/_fs_readlink.ts
Download https://deno.land/[email protected]/node/_fs/_fs_exists.ts
Download https://deno.land/[email protected]/node/_fs/_fs_copy.ts
Download https://deno.land/[email protected]/node/path.ts
Download https://deno.land/[email protected]/node/_utils.ts
Download https://deno.land/[email protected]/node/_fs/_fs_common.ts
Download https://deno.land/[email protected]/node/buffer.ts
Download https://cdn.esm.sh/v27/node:stream
Download https://cdn.esm.sh/v27/node:url
Download https://cdn.esm.sh/v27/node:net
Download https://deno.land/[email protected]/node/_errors.ts
Download https://deno.land/[email protected]/node/events.ts
Download https://deno.land/[email protected]/node/_fs/_fs_dirent.ts
Download https://deno.land/[email protected]/node/_fs/promises/_fs_readFile.ts
Download https://deno.land/[email protected]/node/_fs/promises/_fs_writeFile.ts
Download https://deno.land/[email protected]/fs/mod.ts
Download https://cdn.esm.sh/v27/node:tls
Download https://cdn.esm.sh/v27/node:http
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/[email protected]/testing/asserts.ts
Download https://deno.land/[email protected]/path/mod.ts
Download https://deno.land/[email protected]/encoding/base64.ts
Download https://deno.land/[email protected]/encoding/hex.ts
Download https://deno.land/[email protected]/_util/assert.ts
Download https://deno.land/[email protected]/node/util.ts
Download https://deno.land/[email protected]/fs/walk.ts
Download https://deno.land/[email protected]/fs/eol.ts
Download https://deno.land/[email protected]/fs/exists.ts
Download https://deno.land/[email protected]/fs/ensure_dir.ts
Download https://deno.land/[email protected]/fs/move.ts
Download https://deno.land/[email protected]/fs/copy.ts
Download https://deno.land/[email protected]/fs/expand_glob.ts
Download https://deno.land/[email protected]/fs/ensure_link.ts
Download https://deno.land/[email protected]/fs/ensure_symlink.ts
Download https://deno.land/[email protected]/fs/empty_dir.ts
Download https://deno.land/[email protected]/fs/ensure_file.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/pool.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/path/common.ts
Download https://deno.land/[email protected]/path/_interface.ts
Download https://deno.land/[email protected]/path/posix.ts
Download https://deno.land/[email protected]/path/win32.ts
Download https://deno.land/[email protected]/path/glob.ts
Download https://deno.land/[email protected]/_util/os.ts
Download https://deno.land/[email protected]/path/separator.ts
Download https://deno.land/[email protected]/testing/_diff.ts
Download https://deno.land/[email protected]/fmt/colors.ts
Download https://deno.land/[email protected]/node/_util/_util_callbackify.ts
Download https://deno.land/[email protected]/node/_util/_util_promisify.ts
Download https://deno.land/[email protected]/node/_util/_util_types.ts
Download https://deno.land/[email protected]/fs/_util.ts
Download https://deno.land/[email protected]/path/_util.ts
Download https://deno.land/[email protected]/path/_constants.ts
Check file:///example.ts
error: TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    export * from '/v27/@types/[email protected]/https.d.ts';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/https.d.ts:2:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import * as tls from '/v27/node:tls';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/https.d.ts:6:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import * as http from '/v27/node:http';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/https.d.ts:7:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import { URL } from '/v27/node:url';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/https.d.ts:8:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    export * from '/v27/@types/[email protected]/http.d.ts';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/http.d.ts:2:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import * as stream from '/v27/node:stream';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/http.d.ts:6:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import { URL } from '/v27/node:url';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/http.d.ts:7:5

TS2439 [ERROR]: Import or export declaration in an ambient module declaration cannot reference module through relative module name.
    import { Socket, Server as NetServer } from '/v27/node:net';
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v27/@types/[email protected]/http.d.ts:8:5

Found 8 errors.

Error When Using Solid SSR

If you go to esm.sh/solid-ssr you get the following code:

/* esm.sh - error */
throw new Error("[esm.sh] " + "esbuild: Could not resolve \"solid-ssr\" (mark it as external to exclude it from the bundle)");
export default null;

So basically for some reason Solid SSR doesn't work.

Error using deno bundle with React: Type 'C' does not satisfy the constraint 'ElementType<any>'

I'm trying to use deno bundle with esm React v17.0.1, but got this error:

$ deno bundle --config tsconfig.json src/client.tsx public/assets/js/client.js
Bundle file:///.../deno-react-minimal-frontend/src/client.tsx
Check file:///.../deno-react-minimal-frontend/src/client.tsx
Unsupported compiler options in "/.../deno-react-minimal-frontend/tsconfig.json".
  The following options were ignored:
    allowUmdGlobalAccess, disableSizeLimit, esModuleInterop, module, moduleResolution, noEmit, preserveConstEnums, resolveJsonModule, skipLibCheck, sourceMap, target
error: TS2344 [ERROR]: Type 'C' does not satisfy the constraint 'ElementType<any>'.
  Type 'string | number | ForwardRefExoticComponent<any> | (new (props: any) => Component<any, {}, any>) | ((props: any, context?: any) => ReactElement<any, string | ((props: any) => ReactElement<...> | null) | (new (props: any) => Component<...>)> | null)' is not assignable to type 'ElementType<any>'.
    Type 'number' is not assignable to type 'ElementType<any>'.
      Type 'C' is not assignable to type 'FunctionComponent<any>'.
        Type 'string | number | ForwardRefExoticComponent<any> | (new (props: any) => Component<any, {}, any>) | ((props: any, context?: any) => ReactElement<any, string | ((props: any) => ReactElement<...> | null) | (new (props: any) => Component<...>)> | null)' is not assignable to type 'FunctionComponent<any>'.
          Type 'string' is not assignable to type 'FunctionComponent<any>'.
        "ref" extends keyof ComponentPropsWithRef<C>
                                                  ^
    at https://esm.sh/@types/[email protected]/index.d.ts:120:51

TS2344 [ERROR]: Type 'C' does not satisfy the constraint 'ElementType<any>'.
  Type 'C' is not assignable to type 'FunctionComponent<any>'.
            ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
                                                ^
    at https://esm.sh/@types/[email protected]/index.d.ts:121:49

Found 2 errors.

Here is my import/export part of code:

export { default as React } from "https://esm.sh/[email protected]";

export { default as ReactDOM } from "https://esm.sh/[email protected]";

My environment:
Deno v1.5.2
OS: macOS Mojave 10.14.6

React-Router conflict

I'm trying to import React, ReactDOM and React Router for bundling by Deno.

However, when running app in browser it dies with this error:

Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
    at resolveDispatcher (client.bundle.js:24618)
    at useContext2 (client.bundle.js:24624)
    at useLocation (client.bundle.js:25894)
    at useRouteMatch (client.bundle.js:25900)
    at HeaderNavBar (client.bundle.js:26187)
...

The hook calls are surely located inside Functional Components.

Then I tried to import/re-export these 3 libs bundled together like this (previously only react and react-dom is bundled):

// src/deps/react.ts
export { default as React } from "https://esm.sh/[[email protected],[email protected],[email protected]]/react?dev&no-check";

// src/deps/react-dom.ts
export { default as ReactDOM } from "https://esm.sh/[[email protected],[email protected],[email protected]]/react-dom?dev&no-check";

// src/deps/react-router.ts
export {
  BrowserRouter as Router,
  ...
  useRouteMatch,
} from "https://esm.sh/[[email protected],[email protected],[email protected]]/react-router-dom?dev&no-check";

but Deno cannot process them because the links gave error:

/* esm.sh - error */
throw new Error("[esm.sh] " + "yarn: ");
export default null;

Removing @version numbers still gives the same results.

deno post css error

Hello,

thanks for the port to Deno

I use deno version

deno 1.6.3 (release, x86_64-unknown-linux-gnu)
v8 8.8.294
typescript 4.1.3

but when i to use deno+postcss with your sample

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()).content

i get the following error

error: TS2315 [ERROR]: Type 'Plugin' is not generic.
type Autoprefixer = Plugin & ExportedAPI;
~~~~~~~~~~~~~~~
at https://cdn.esm.sh/v14/@types/[email protected]/index.d.ts:65:25

do you have any idea of the origin ? thanks for helping

can't load https://cdn.esm.sh/v15/_node_fs.js

error message:
error: Uncaught SyntaxError: The requested module 'https://cdn.esm.sh/v15/_node_fs.js' does not provide an export named 'default' import __fs$ from "https://cdn.esm.sh/v15/_node_fs.js"; ~~~~~ at <anonymous>

named exports are missing

import('https://esm.sh/@lume/element').then(({Element}) => {
  console.log(Element)
})

results in logging undefined instead of the expected value.

Note that the @lume/element package follows modern ESM standards and it works in Node.js ESM, or any tools that strictly follow Node ESM standards (like Webpack 5+).

Here's what the entry looks like: https://unpkg.com/@lume/element

502 Bad Gateway for postcss 8.1.4

I want to try out aleph.js alephjs/aleph.js, but i every time i try to start the dev server i run into the following problem:

error: Uncaught (in promise) TypeError: Import 'https://cdn.esm.sh/v10/[email protected]/lib/processor.js.d.ts' failed: 502 Bad Gateway
    at https://cdn.esm.sh/v10/[email protected]/lib/postcss.d.ts:22:0

When i check the shown links in the browser, a Cloudflare 502 Bad gateway error is returned. Every time i run the alpeh dev command another file is affected.

https://cdn.esm.sh/v10/[email protected]/lib/comment.js.d.ts
https://cdn.esm.sh/v10/[email protected]/lib/input.js.d.ts
https://cdn.esm.sh/v10/[email protected]/lib/processor.js.d.ts

Is this error on my end somehow? Thanks!

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.