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

Redoc does not work with nextjs #1647

Closed
tm1000 opened this issue Jun 11, 2021 · 5 comments
Closed

Redoc does not work with nextjs #1647

tm1000 opened this issue Jun 11, 2021 · 5 comments

Comments

@tm1000
Copy link

tm1000 commented Jun 11, 2021

Between release 53 and 54. Redoc suddenly broken with any system that is using webpack 5 and nextjs (v2.0.0-rc.53...v2.0.0-rc.54)

See:

It looks like redoc is including webpack and perhaps being bundled twice. The "standalone" version of Redoc (used in React) should not be bundled/compiled. The bundling should be left to upstream. What appears to be happening is that the bundle is assuming "WEB" only while nextjs is both NODE and WEB

info  - Creating an optimized production build ..<w> [webpack.cache.PackFileCacheStrategy] Restoring pack from /app/.next/cache/webpack/client-production.pack failed: Error: No such label 'restore cache container' for WebpackLogger.timeEnd()
info  - Creating an optimized production build  
Failed to compile.

ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in '/app/node_modules/redoc/bundles'
@tm1000 tm1000 changed the title Redoc does not work with webpack 5 Redoc does not work with nextjs Jun 11, 2021
@tremby
Copy link

tremby commented Jun 11, 2021

I was just about to open exactly the same ticket!

@tm1000
Copy link
Author

tm1000 commented Jun 11, 2021

@tremby you can sort of fix with with a NextJS Webpack5 workaround:

https://stackoverflow.com/a/67233156

Im not sure of the implications of doing so

For my specific usage I had to do this (next.config.js):

const settings = {
	webpack(config, options) {
		if (config.resolve.fallback) {
			config.resolve.fallback.fs = false;
		}

		return config;
	},
};
settings.future = {
	webpack5: true,
};

module.exports = settings;

What's strange is that redoc is already doing this:

fs: false,

@tremby
Copy link

tremby commented Jun 11, 2021

Thanks. But I'm still using webpack 4 for now, and have worked around the problem in the mean time by using rc 53.

@tm1000
Copy link
Author

tm1000 commented Jun 11, 2021

For webpack 4 you do something like:

const settings = {
	webpack(config, options) {
		if (config.node.fs) {
			config.node.fs = false;
		}

		return config;
	},
};

module.exports = settings;

@RomanHotsiy
Copy link
Member

Dup of #1584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants