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

jsxImportSource resolution in config files #15559

Closed
lucacasonato opened this issue Aug 23, 2022 · 0 comments · Fixed by #15561
Closed

jsxImportSource resolution in config files #15559

lucacasonato opened this issue Aug 23, 2022 · 0 comments · Fixed by #15561
Labels
suggestion suggestions for new features (yet to be agreed)

Comments

@lucacasonato
Copy link
Member

Take the following example:

// deno.json
{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  },
  "importMap": "./import_map.json"
}
// import_map.json
{
  "scopes": {
    "./x/": {
      "preact": "./preact-1.js"
    },
    "./y/": {
      "preact": "./preact-2.js"
    }
  }
}

Currently in Deno such code would fail because the bare specifier "preact" can not be resolved from the config file module.

This is arguably a very rarely encountered edge case. I still think we should deal with it in some way. I can think of two ways:

  1. Resolve jsxImportSource relative to the config file location, and use the resolved specifier during emit. This poses the risk that the specifier may be resolved by the import map twice: once during emit, and once at runtime when the jsx import is actually loaded.
  2. Do not resolve jsxImportSource up front at all. Emit the specifier exactly as specified in the config file into the source files. Resolve the specifier individually in every file, just like /** @jsxImportSource ... */ is handled.

I prefer option 2, because it has less weird edge cases. Both may have surprising behavior when using a relative specifier in the config file. I think that is the least of all evils though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant