Skip to content

TS JsxFactory and JsxFragment Ignored (enhancement) #92

@bayes343

Description

@bayes343

This is mostly an FYI for the maintainer and anyone who stumbles across this issue. It's pretty niche as most aren't using custom JsxFactory declarations.

If you have custom compilerOptions for jsxFactory and/or jsxFragmentFactory, and you experience runtime errors referecning React, it's likely due to the underlying esbuild script not using the values you specify in deno.json or tsconfig.json.

Image

My workaround was to setup an esbuild script (vice using denoflare) which passes these values into the build and/or context functions (show below).

A good enhancement for denoflare could be to read those options from deno.json and/or tsconfig.json and pass them in.

import * as esbuild from "npm:[email protected]";
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader@^0.11.1";

const isProductionBuild = Deno.args.includes('prod');
const outfile = "./worker.js";
const entryPoints = ["./worker.ts"];
const plugins = [...denoPlugins()];
const bundle = true;
const format = "esm";
const jsxFactory = 'ParseJsx';
const jsxFragment = 'Fragment';

if (isProductionBuild) {
  await esbuild.build({
    plugins,
    entryPoints,
    outfile,
    bundle,
    format,
    jsxFactory,
    jsxFragment,
  });
  esbuild.stop();
} else {
  const context = await esbuild.context({
    plugins,
    entryPoints,
    outfile,
    bundle,
    format,
    jsxFactory,
    jsxFragment,
    sourcemap: true,
  });
  context.watch();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions