Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The esbuild plugin doesn't work flawlessly with tsup #398

Open
favna opened this issue May 28, 2024 · 1 comment
Open

The esbuild plugin doesn't work flawlessly with tsup #398

favna opened this issue May 28, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@favna
Copy link

favna commented May 28, 2024

🐛 The bug

I'm attempting to implement magic-regexp in the project https://github.com/sapphiredev/utilities (draft PR: sapphiredev/utilities#755), however, for some unknown reason the esbuild plugin is giving me compiler errors. Sadly I cannot manage to reproduce the issue in a clean project so it's somehow something very specific with our project. Even if I use the exact same tsup options in a clean project, the issues does not show up in such a project.

The error I currently get is:

X [ERROR] Unexpected token (9:29) [plugin MagicRegExpTransformPlugin]

  This error came from the "onLoad" callback registered here:

    ../../node_modules/esbuild/lib/main.js:1340:8:
X       1340 │         [ERRORawait promise;
           ╵         ]^ 

    at setupPlugins (file:///F:/sapphiredev/utilities/node_modules/unplugin/dist/index.mjs:995:16)
    at async handlePlugins (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1340:9)

Unexpected token (9:29) [plugin MagicRegExpTransformPlugin]

  This error came from the "onLoad" callback registered here:

    ../../node_modules/esbuild/lib/main.js:1340:8:
      1340 │         await promise;
           ╵         ^

    at setupPlugins (file:///F:/sapphiredev/utilities/node_modules/unplugin/dist/index.mjs:995:16)
    at async handlePlugins (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1340:9)

IIFE dist\iife\index.global.js     29.93 KB
IIFE dist\iife\index.global.js.map 70.50 KB
IIFE ⚡️ Build success in 188ms
CJS Build failed
Error: Build failed with 1 error:
error: Unexpected token (9:29)
    at failureErrorWithLog (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1651:15)
    at F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1059:25
    at runOnEndCallbacks (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1486:45)
    at buildResponseToResult (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1057:7)
    at F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:1086:16
    at responseCallbacks.<computed> (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:704:9)
    at handleIncomingPacket (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:764:9)
    at Socket.readFromStdout (F:\sapphiredev\utilities\node_modules\esbuild\lib\main.js:680:7)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:559:12)
ESM Build failed

I have linked the draft PR with the WIP branch below as opposed to a stackblitz because the issue is very specific to our project it seems.

To reproduce:

  1. Clone the repository
  2. Check out the proper branch
  3. Run yarn install to install dependencies
  4. Build the package that packages/utilities depends on with:
yarn turbo run build --filter "@sapphire/node-utilities" --filter "@sapphire/eslint-config" --filter "@sapphire/prettier-config"
  1. cd into packages/utilites
  2. Run yarn build
  3. Observe the error being thrown

🛠️ To reproduce

sapphiredev/utilities#755

🌈 Expected behaviour

I am able to build my code correctly using tsup with the esbuild plugin

ℹ️ Additional context

No response

@favna favna added the bug Something isn't working label May 28, 2024
@favna
Copy link
Author

favna commented Jul 2, 2024

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants