Skip to content

fix: add jsxImportSource to esbuild-loader webpack configs - #906

Merged
jordan-a-young merged 1 commit into
masterfrom
fix/esbuild-jsx-import-source
Sep 22, 2026
Merged

jordan-a-young merged 1 commit into
masterfrom
fix/esbuild-jsx-import-source

Conversation

@jordan-a-young

Copy link
Copy Markdown
Member

Problem

JS/JSX projects using @availity/workflow get Uncaught ReferenceError: React is not defined at runtime. TypeScript projects are unaffected because esbuild reads jsxImportSource from tsconfig.json. JS projects have no tsconfig, so esbuild doesn't know where to import the JSX runtime from despite jsx: 'automatic' being set.

Root cause

  • webpack.config.js (dev): had jsx: 'automatic' but no jsxImportSource
  • webpack.config.production.js: missing both jsx: 'automatic' and jsxImportSource
  • vitest.config.js: already correct — had both, no change needed

Additionally, package.json was missing a ./globals entry in the exports map, causing TypeScript to error with "Cannot find type definition file for '@availity/workflow/globals'" when "types": ["@availity/workflow/globals"] was set in a project's tsconfig.json.

Changes

  • webpack.config.js: add jsxImportSource: 'react' to esbuild-loader options
  • webpack.config.production.js: add jsx: 'automatic' and jsxImportSource: 'react' to esbuild-loader options
  • package.json: expose ./globals subpath in exports map so TypeScript can resolve @availity/workflow/globals
  • example/index.tsx: remove manual import React workaround (no longer needed with the fix in place)
  • tests/__snapshots__/workflowConfigs.spec.js.snap: update snapshots to reflect the new esbuild-loader options

Testing

All 460 tests pass.

JS/JSX projects were getting 'React is not defined' at runtime because
esbuild-loader's jsx: 'automatic' mode needs jsxImportSource to know
where to import the JSX runtime from. TypeScript projects were fine
since esbuild reads jsxImportSource from tsconfig.json, but JS projects
have no tsconfig fallback.

- webpack.config.js: add jsxImportSource: 'react' alongside jsx: 'automatic'
- webpack.config.production.js: add both jsx: 'automatic' and jsxImportSource: 'react'
- package.json: expose ./globals subpath in exports map so TypeScript can
  resolve '@availity/workflow/globals' in tsconfig types[]
- example/index.tsx: remove manual 'import React' workaround (no longer needed)
@jordan-a-young
jordan-a-young merged commit 9245a22 into master Sep 22, 2026
5 checks passed
@jordan-a-young
jordan-a-young deleted the fix/esbuild-jsx-import-source branch September 22, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant