Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to import types for some configuration #901

Open
mhNirob opened this issue Oct 30, 2024 · 0 comments
Open

Failed to import types for some configuration #901

mhNirob opened this issue Oct 30, 2024 · 0 comments
Labels
browser Not working in Browser

Comments

@mhNirob
Copy link

mhNirob commented Oct 30, 2024

Failing module

I am not getting types for some combination of header configuration. For example if external is "react,react-dom" and conditions is "react-server", not getting types.
If this configuration is a subset of another combination that also doesn't give types in some cases. For example this one:

  {
    external: "react,react-dom",
    conditions: "react-server",
    target: "denonext"
  }

Here is my test script to test some of the combination:

const test = async (specifier: string, headers: Record<string, string>) => {
  const url = new URL(specifier, "https://esm.sh");
  for (const [key, value] of Object.entries(headers)) {
    url.searchParams.set(key, value);
  }

  const response = await fetch(url);
  const typeUrl = response.headers.get("x-typescript-types");

  const typeResponse = await fetch(typeUrl!);
  console.log(headers, url.href, (await typeResponse.text()).substring(0, 100));
};

await Promise.all([
  // TYPES NOT FOUND
  test("react@canary/jsx-runtime", {
    external: "react,react-dom",
    conditions: "react-server",
  }),

  // OK
  test("react@canary/jsx-runtime", {}),

  // OK
  test("react@canary/jsx-runtime", {
    external: "react",
    conditions: "react-server",
  }),

  // OK
  test("react@canary/jsx-runtime", {
    external: "react-dom",
    conditions: "react-server",
  }),

  // OK
  test("react@canary/jsx-runtime", {
    external: "react,react-dom",
  }),

  // OK
  test("react@canary/jsx-runtime", {
    conditions: "react-server",
  }),
]);

Error message

After onload I got this:

Types not found

Additional info

  • esm.sh version: latest

Here are some more outputs for this script:

Screenshot 2024-10-30 at 8 13 01 PM Screenshot 2024-10-30 at 8 18 39 PM
@mhNirob mhNirob added the browser Not working in Browser label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Not working in Browser
Projects
None yet
Development

No branches or pull requests

1 participant