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

TypeError: Cannot read properties of undefined (reading 'tokenizePlaceholders') with swcJsLoader: true, #388

Open
thde opened this issue Nov 14, 2024 · 4 comments
Labels
bug Something isn't working builds

Comments

@thde
Copy link

thde commented Nov 14, 2024

As v2.2.0 has been released with support for @docusaurus/faster, I tried to enable it for our repository, but it fails with the following error if swcJsLoader: true, is enabled:

TypeError: Cannot read properties of undefined (reading 'tokenizePlaceholders')

It's not clear to me if the issue is at redocusaurus'es side or on the side of docusaurus.

The Spec can be found here. The full stack trace looks like this:

[ERROR] Error: Unable to build website for locale en.
    at tryToBuildLocale (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:78:15)
    at async ***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:34:9
    at async mapAsyncSequential (***/docs.nine.ch/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
    at async Command.build (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:33:5) {
  [cause]: Error: Docusaurus static site generation failed for 1 paths:
  - "/api/"
      at generateStaticFiles (***/docs.nine.ch/node_modules/@docusaurus/core/lib/ssg/ssg.js:129:15)
      at async executeSSG (***/docs.nine.ch/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:29:23)
      ... 6 lines matching cause stack trace ...
      at async Command.build (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:33:5) {
    [cause]: AggregateError
        at generateStaticFiles (***/docs.nine.ch/node_modules/@docusaurus/core/lib/ssg/ssg.js:130:20)
        at async executeSSG (***/docs.nine.ch/node_modules/@docusaurus/core/lib/ssg/ssgExecutor.js:29:23)
        at async buildLocale (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/buildLocale.js:60:31)
        at async runBuildLocaleTask (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:93:5)
        at async ***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:74:13
        at async tryToBuildLocale (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:70:9)
        at async ***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:34:9
        at async mapAsyncSequential (***/docs.nine.ch/node_modules/@docusaurus/utils/lib/jsUtils.js:21:24)
        at async Command.build (***/docs.nine.ch/node_modules/@docusaurus/core/lib/commands/build/build.js:33:5) {
      [errors]: [
        Error: Can't render static file for pathname "/api/"
            at generateStaticFile (***/docs.nine.ch/node_modules/@docusaurus/core/lib/ssg/ssg.js:167:15)
            at processTicksAndRejections (node:internal/process/task_queues:105:5)
            at runNextTicks (node:internal/process/task_queues:69:3)
            at process.processImmediate (node:internal/timers:459:9)
            at async ***/docs.nine.ch/node_modules/p-map/index.js:57:22 {
          [cause]: TypeError: Cannot read properties of undefined (reading 'tokenizePlaceholders')
          Please report this to https://github.com/markedjs/marked.
              at ***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:49942:40
              at Object.run (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:50972:6)
              at Object.highlight (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:50881:12)
              at jt (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:11348)
              at Object.highlight (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:52821)
              at Er.code (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:41553)
              at Sr.parse (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:44695)
              at parse (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:43979)
              at ***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:49196
              at Ar (***/docs.nine.ch/build/__server/assets/js/f0ad3fbb.0f5fb192.js:52600:49316)
        }
      ]
    }
  }
}
@rohit-gohri rohit-gohri added the bug Something isn't working label Nov 14, 2024
@rohit-gohri
Copy link
Owner

It's not clear to me if the issue is at redocusaurus'es side or on the side of docusaurus.

Might be worth reporting it there too (you can link this issue), since it's still experimental and your normal build works (I guess?)

@thde
Copy link
Author

thde commented Nov 14, 2024

Yeah, makes sense. Will do 👍🏼

@snowliver
Copy link

snowliver commented Nov 19, 2024

Hi @thde @rohit-gohri ,
same issue on some of our api docs. Has something to do with markdown codeblocks in the description field of a parameter.

But after i followed the first line after the "please report to marked...", i landed somewhere in the prism.languages.php definitions.

So, I got it working with adding the additional language php into the docusaurus.config.js as described here : https://docusaurus.io/docs/markdown-features/code-blocks#supported-languages

prism: {
   additionalLanguages: ['php']
}

Also not happening, if you do a docusaurus build --dev.

But - not sure if that makes things easier to permantly fix.

@thde
Copy link
Author

thde commented Nov 19, 2024

That's it! If you follow the generated code in the stack trace you end up in ***/build/__server/assets/js/f0ad3fbb.8489e1b5.js:50825:40:

Prism.hooks.add('after-tokenize', function (env) {
   Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
});

After adding php to additionalLanguages , the build worked for me too.

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

No branches or pull requests

3 participants