facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.89k stars 8.56k forks source link

Upgrading to 'faster' causes error on build #10667

Closed liam-swinney closed 2 weeks ago

liam-swinney commented 2 weeks ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

npm run build :

[WARNING] Docusaurus site warnings:
- Your site is using the SWC js loader. You can safely remove the Babel config file at `babel.config.js`.
●  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ (8%) setup compilation
●  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ (9%) setup compilation                                                                                                                                          [ERROR] Error:   × TypeError: Cannot read properties of undefined (reading 'set')
  │     at Object.fn (/Users/{redacted}/node_modules/webpack/lib/DefinePlugin.js:362:37)
  │     at SyncHook.callAsyncStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:240:21)
  │     at SyncHook.callStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:259:14)
  │     at QueriedHook.call (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:218:26)
  │     at /Users/{redacted}/node_modules/@rspack/core/dist/index.js:17454:36
  │     at last.function (/Users/{redacted}/node_modules/@rspack/core/dist/index.js:17936:25)
  │

[ERROR] Error: Unable to build website for locale en.
    at tryToBuildLocale (/Users/{redacted}/node_modules/@docusaurus/core/lib/commands/build/build.js:78:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/{redacted}/node_modules/@docusaurus/core/lib/commands/build/build.js:34:9
    at async mapAsyncSequential (/Users/{redacted}/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
    at async Command.build (/Users/{redacted}/node_modules/@docusaurus/core/lib/commands/build/build.js:33:5) {
  [cause]: [Error:   × TypeError: Cannot read properties of undefined (reading 'set')
    │     at Object.fn (/Users/{redacted}/node_modules/webpack/lib/DefinePlugin.js:362:37)
    │     at SyncHook.callAsyncStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:240:21)
    │     at SyncHook.callStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:259:14)
    │     at QueriedHook.call (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:218:26)
    │     at /Users/{redacted}/node_modules/@rspack/core/dist/index.js:17454:36
    │     at last.function (/Users/{redacted}/node_modules/@rspack/core/dist/index.js:17936:25)
    │
  ] {
    code: 'GenericFailure'
  }
}

npm run start

●  ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ (9%) setup compilation                                                                     <e> [webpack-dev-middleware] [Error:   × TypeError: Cannot read properties of undefined (reading 'set')
<e>   │     at Object.fn (/Users/{redacted}/node_modules/webpack/lib/DefinePlugin.js:362:37)
<e>   │     at SyncHook.callAsyncStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:240:21)
<e>   │     at SyncHook.callStageRange (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:259:14)
<e>   │     at QueriedHook.call (/Users/{redacted}/node_modules/@rspack/lite-tapable/dist/index.js:218:26)
<e>   │     at /Users/{redacted}/node_modules/@rspack/core/dist/index.js:17454:36
<e>   │     at last.function (/Users/{redacted}/node_modules/@rspack/core/dist/index.js:17936:25)
<e>   │ 
<e> ] {
<e>   code: 'GenericFailure'
<e> }

I've updated my existing build to 3.6.1 (I have confirmed this version works fine). I have then installed 'faster' and have enabled this in my docusaurus.config.js file.

I have tried the combination of npm run clear, the recommended removal of the modules/lock files and reinstaillation and still get the issue.

I've also tried to 'downgrade' my rspack version as per the recommendations in https://github.com/facebook/docusaurus/issues/10664#issuecomment-2466735654, I can see in my package.lock file this is using 1.0.14, however I get the issue either way!

Thanks

Reproducible demo

No response

Steps to reproduce

Unable to replicate on a fresh build

Expected behavior

The builds to build correctly with no errors

Actual behavior

See the description for error codes

Your environment

Self-service

slorber commented 2 weeks ago

It is impossible to help you without a repro.

The error message is familiar to me and is very likely related to a custom or third-party Docusaurus plugin that doesn't support Rspack and is using webpack.DefinePlugin instead of currentBundler.instance.DefinePlugin

Please read this to understand what must be done: https://github.com/facebook/docusaurus/issues/10572