docusaurus: Webpack fails to parse prism-react-renderer with 3.0.0-rc.1
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I’m using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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
I’ve just upgraded to 3.0.0-rc.1 and I’m getting Prism errors: https://github.com/johnnyreilly/blog.johnnyreilly.com/actions/runs/6658477531/job/18095419680
[success] [webpackbar] Client: Compiled with some errors in 1.74m
Error: Client bundle compiled with errors therefore further build is impossible.
Module parse failed: Unexpected token (60:21)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| ],
| 'operator': /\\$/m,
> 'punctuation': /=/
| }
| },
--------------------------
Module parse failed: Unexpected token ([76](https://github.com/johnnyreilly/blog.johnnyreilly.com/actions/runs/6658477531/job/18095419680#step:5:77)3:929)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| return "(?:" + r + "|" + s + ")";
| })), lookbehind: true, greedy: true, alias: "atrule" }, directive: { pattern: /(^[ \t]*)%.+/m, lookbehind: true, alias: "important" }, datetime: { pattern: i(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source), lookbehind: true, alias: "number" }, boolean: { pattern: i(/false|true/.source, "i"), lookbehind: true, alias: "important" }, null: { pattern: i(/null|~/.source, "i"), lookbehind: true, alias: "important" }, string: { pattern: i(s), lookbehind: true, greedy: true }, number: { pattern: i(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"), lookbehind: true }, tag: t, important: n, punctuation: /---|[:[\]{}\-,|>?]|\.\.\./ }, e.languages.yml = e.languages.yaml;
> }(Prism), Prism.languages.markup = { comment: { pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, greedy: true }, prolog: { pattern: /<\?[\s\S]+?\?>/, greedy: true }, doctype: { pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, greedy: true, inside: { "internal-subset": { pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, lookbehind: true, greedy: true, inside: null }, string: { pattern: /"[^"]*"|'[^']*'/, greedy: true }, punctuation: /^<!|>$|[[\]]/, "doctype-tag": /^DOCTYPE/i, name: /[^\s<>'"]+/ } }, cdata: { pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, greedy: true }, tag: { pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, greedy: true, inside: { tag: { pattern: /^<\/?[^\s>\/]+/, inside: { punctuation: /^<\/?/, namespace: /^[^\s>\/:]+:/ } }, "special-attr": [], "attr-value": { pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, inside: { punctuation: [{ pattern: /^=/, alias: "attr-equals" }, { pattern: /^(\s*)["']|["']$/, lookbehind: true }] } }, punctuation: /\/?>/, "attr-name": { pattern: /[^\s>\/]+/, inside: { namespace: /^[^\s>\/:]+:/ } } } }, entity: [{ pattern: /&[\da-z]{1,8};/i, alias: "named-entity" }, /&#x?[\da-f]{1,8};/i] }, Prism.languages.markup.tag.inside["attr-value"].inside.entity = Prism.languages.markup.entity, Prism.languages.markup.doctype.inside["internal-subset"].inside = Prism.languages.markup, Prism.hooks.add("wrap", function(e) {
| "entity" === e.type && (e.attributes.title = e.content.replace(/&/, "&"));
| }), Object.defineProperty(Prism.languages.markup.tag, "addInlined", { value: function(e, n) {
Reproducible demo
No response
Steps to reproduce
I’ll see if I can come up with a repro
Expected behavior
Build doesn’t fail
Actual behavior
Build fails - error related to webpack and Prism
Your environment
- Public source code: https://github.com/johnnyreilly/blog.johnnyreilly.com/pull/712
- Public site URL:https://johnnyreilly.com
- Docusaurus version used: 3.0.0-rc.1
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- I’d be willing to fix this bug myself.
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 23 (6 by maintainers)
This worked for me by pinning acorn to
8.10.0(the most recent version before the recent bug). Thanks!Folks, this is because of https://github.com/acornjs/acorn/issues/1253. It’s neither because of prism-react-renderer nor Docusaurus nor Webpack. I’m going to close until that one gets fixed; in the meantime you may want to pin your Acorn version through your package manager resolution.
So I see similar issue when I try to create a fresh app for 2.4.3
Apparently it’s fixed in Acorn 8.11.2 🙌
Thanks for investigating @Josh-Cena 🤗
I also suspected Acorn by seeing the lock file diff but couldn’t be 100% sure.
Glad it’s not a Docusaurus bug, hope it will be fixed for next week’s release
I’m getting this exact error now from a branch that was working with Docusaurus 3.0.0-beta.0.