-
Notifications
You must be signed in to change notification settings - Fork 116
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
Build fails when config includes redocusaurus and docusaurus-theme-search-typesense #236
Comments
I have the exact same issue. It would be great to be able to use both search and redocusaurus at the same time, but honestly I have no idea where to even start debugging it. @GalexyN have you found a workaround in the meantime? |
I made a minimal example to reproduce the bug, I hope it will help whoever can debug this: https://github.com/balazsbotond/redocusaurus-typesense-bug-repro |
Please note that @GalexyN also reported the same issue here: typesense/docusaurus-theme-search-typesense#23 I've found a closed issue about the same problem in the debug.js project. A PR which fixed this issue with minimal changes was rejected with the justification that "it wasn't the maintainers' job to fix other people's messes". Another PR which may fix this issue has been open for more than four years. The original issue offers several possible workarounds by defining webpack plugins but I'm not sure these can be added to a Docusaurus project. One of my coworkers suggested simply commenting out the offending line in the function save(namespaces) {
if (namespaces) {
// process.env.DEBUG = namespaces;
} else {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete process.env.DEBUG;
}
} Which, while being an incredibly hacky solution, is the one we currently use as part of our CI pipeline by running the following sed command after installing npm packages:
Far from ideal, I know, but I hope it helps someone until the root cause is fixed. |
This is very easy to do. We already do it here - https://github.com/rohit-gohri/redocusaurus/blob/main/packages/docusaurus-theme-redoc/src/index.ts#L24-L27 If some one can open a PR, I'll be happy to review and release it. Thanks @balazsbotond for the research on the issue! |
Probably this is the culprit -
But this was added for some other reason. Better to add a define for |
I solved the problem by changing this in plugins: [
...
async function customPlugin(context, opts) {
return {
name: 'custom-plugin',
configureWebpack(config, isServer, utils, content) {
// Modify internal webpack config. If returned value is an Object, it
// will be merged into the final config using webpack-merge;
// If the returned value is a function, it will receive the config as the 1st argument and an isServer flag as the 2nd argument.
return {
plugins: [
new webpack.DefinePlugin({
// IMPORTANT: To fix debug library‘s bug
// {}.DEBUG = namespaces; // SyntaxError: Unexpected token '.'
'process.env.DEBUG': 'process.env.DEBUG',
})
]
}
},
}
}
], |
@Sakura-pgh you made my day ⭐ |
@Sakura-pgh Thank you SO MUCH. You've helped me tremendously in 2024. I was already debugging this issue for 2 days before stumbling on your comment. |
Hi
I'm getting a build error when I compile with 2 plugins in the same config
I also wanted to note that I only run into this error when running
npm run build
if i donpm start
everything works fine with both plugins available in the docusaurus config.I've tried a mix of the following
I've noticed that if I were to comment out the redocusaurus config in presets of
docusaurus.config.js
ORthemes:['docusaurus-theme-search-typesense']
the build happens smoothlydocusaurus.config.js
package.json
error message
The text was updated successfully, but these errors were encountered: