Skip to content

Error when bundling with esbuild using custom unplugin #517

@BoYuanSu

Description

@BoYuanSu

Environment

node: 20
unplugin: 2.3.5

Reproduction

https://github.com/BoYuanSu/unplugin-unused-components/tree/fix/esbuild-test

  1. install deps, pnpm i.

  2. change directory to esbuild-plugin-test cd ./tests/esbuild-plugin-test/.

  3. run test script pnpm run test.

Describe the bug

I'm developing a custom plugin based on unplugin, designed to scan my project for components and report unused ones. It works as expected in vite and webpack, but when I try to test it with esbuild, I encounter the following error:

stdout | esbuild.test.ts > esbuild > should run esbuild tests
Found 2 unused components:
- /Users/user/Desktop/boyuansu/unplugin-unused-components/tests/fixtures/TestUnused.vue
- /Users/user/Desktop/boyuansu/unplugin-unused-components/tests/fixtures/TestUnusedReact.jsx

 ❯ esbuild.test.ts (1 test | 1 failed) 60ms
   × esbuild > should run esbuild tests 59ms
     → Build failed with 2 errors:
../fixtures/TestUsed.vue:1:0: ERROR: The JSX syntax extension is not currently enabled
../fixtures/TestUsed.vue:4:10: ERROR: Expected "}" but found "{"

I've tried to remove my custom plugin and the fixtures setup work fine with esbuild config.
Is there anything specific I need to do to support esbuild with unplugin?
Any known caveats or extra config I might be missing?

Thanks!

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions