jsx: 'preserve' in optimizeDeps breaks dependency scan when .tsx files use `import.meta.glob`

Open
#262 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript, vite

Research direction

Start with the vite:dep-scan:transform:js-glob plugin in packages/vite/src/node/optimizer/scan.ts around the referenced line, then reproduce the failure with the linked vite-plugin-solid-bug project. Trace how jsx: 'preserve' affects .tsx files using import.meta.glob. Done means dependency scanning succeeds for this case without requiring either listed workaround.

Written by the indexing model from the issue text.

Description

Describe

The vite:dep-scan:transform:js-glob plugin asserts that the return result is js. But the vite-plugin-solid plugin sets jsx: 'preserve'.

Reproduction

https://github.com/zhylmzr/vite-plugin-solid-bug

Workarounds

  1. move import.meta.glob to a single js/ts file.
  2. or change transform.jsx to:
// vite.config.ts
plugins: [
  {
    name: 'fix-solid-deps-scan',
    enforce: 'post',
    config() {
      return {
        optimizeDeps: {
          rolldownOptions: {
            transform: {
              jsx: {
                importSource: 'solid-js/h',
              },
            },
          },
        },
      }
    },
  },
]
Dominant language
TypeScript
Stars
520
Forks
70
Avg merge
23h 35m
Merged PRs (30d)
39

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from solidjs/solid-vite-plugin

All issues in solidjs/solid-vite-plugin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.