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

Builds with esbuild-loader >= 2.17.0 are failing #6901

Closed
5 of 7 tasks
mxschmitt opened this issue Mar 11, 2022 · 3 comments
Closed
5 of 7 tasks

Builds with esbuild-loader >= 2.17.0 are failing #6901

mxschmitt opened this issue Mar 11, 2022 · 3 comments
Labels
closed: duplicate This issue or pull request already exists in another issue or pull request external This issue is caused by an external dependency and not Docusaurus.

Comments

@mxschmitt
Copy link
Contributor

mxschmitt commented Mar 11, 2022

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

When using esbuild-loader with docusaurus, builds start failing if esbuild-loader >= v1.17.0.

Relates: #4765

Upstream commit range: privatenumber/esbuild-loader@v2.16.0...v2.17.0

(this is more of a tracking issue for users who are encountering this so they can discover it. Its most likely not an issue with docusaurus itself. If this is against the issue policies in this repo, feel free to close)

Reproducible demo

No response

Steps to reproduce

Repro:

  1. npx create-docusaurus@latest my-website classic --typescript
  2. npm install -D esbuild-loader
  3. Add the following to the config:
webpack: {
  jsLoader: (isServer) => ({
    loader: require.resolve('esbuild-loader'),
    options: {
      loader: 'tsx',
      format: isServer ? 'cjs' : undefined,
      target: isServer ? 'node12' : 'es2017',
    },
  }),
}
  1. npm run build

Expected behavior

It works.

Actual behavior

Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Your environment

  • Public source code: See the repro
  • Public site URL: N/A
  • Docusaurus version used: beta-17
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 14, Chrome 100
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 12.2

Self-service

  • I'd be willing to fix this bug myself.
@mxschmitt mxschmitt added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Mar 11, 2022
@mxschmitt
Copy link
Contributor Author

mxschmitt commented Mar 11, 2022

I was bisecting it a bit more on esbuild level, these are my results:

  • 0.14.5 bad
  • 0.14.4 invalid
  • 0.14.3 good

why invalid?

➜  esbuild-loader npm i
npm ERR! code 1
npm ERR! path /Users/max/development/tmp/my-website/node_modules/esbuild-loader/node_modules/esbuild
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! /Users/max/development/tmp/my-website/node_modules/esbuild-loader/node_modules/esbuild/install.js:96
npm ERR!     throw new Error(`Expected ${JSON.stringify("0.14.4")} but got ${JSON.stringify(stdout)}`);
npm ERR!           ^
npm ERR! 
npm ERR! Error: Expected "0.14.4" but got "0.14.3"
npm ERR!     at validateBinaryVersion (/Users/max/development/tmp/my-website/node_modules/esbuild-loader/node_modules/esbuild/install.js:96:11)
npm ERR!     at /Users/max/development/tmp/my-website/node_modules/esbuild-loader/node_modules/esbuild/install.js:242:5

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/max/.npm/_logs/2022-03-11T23_47_50_926Z-debug-0.log

So the new range is: evanw/esbuild@v0.14.3...v0.14.5

And most likely this PR: evanw/esbuild#1849

@Josh-Cena
Copy link
Collaborator

Hi, this is a duplicate of #6235. The culprit is the one that you discovered, and you can also see the linked esbuild issue evanw/esbuild#2037 for the actual cause. TL;DR: this is an esbuild bug and not something we can help with. However, we successfully worked around it by using ESM in SSR as well:

jsLoader: (isServer) => ({
loader: require.resolve('esbuild-loader'),
options: {
loader: 'tsx',
target: isServer ? 'node12' : 'es2017',
},
}),

@Josh-Cena Josh-Cena added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels Mar 12, 2022
@mxschmitt
Copy link
Contributor Author

I can confirm this works, thank you very much @Josh-Cena, have a great weekend. 💯

@Josh-Cena Josh-Cena added external This issue is caused by an external dependency and not Docusaurus. and removed bug An error in the Docusaurus core causing instability or issues with its execution labels Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: duplicate This issue or pull request already exists in another issue or pull request external This issue is caused by an external dependency and not Docusaurus.
Projects
None yet
Development

No branches or pull requests

2 participants