Skip to content

Let me change jsx compilerOption #384

@pschiffmann

Description

@pschiffmann

My deno code contains jsx tags like: <div>hello world</div. I have configured my project to use React from npm, and use the automatic runtime, like so:

{
  "imports": {
    "react": "npm:react@18.2.0",
    "react/jsx-runtime": "npm:react@18.2.0/jsx-runtime"
  },
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "react"
  }
}

This setup works well locally as well as on Deno Deploy. However, when I try to compile this code with dnt, I get a bunch of these errors: error TS2686: 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.

The problem here is that dnt uses a hard-coded jsx compiler option value, and doesn't let me overwrite it:

dnt/mod.ts

Lines 284 to 286 in 2d1d120

jsx: ts.JsxEmit.React,
jsxFactory: "React.createElement",
jsxFragmentFactory: "React.Fragment",

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions