preact-lazy-route icon indicating copy to clipboard operation
preact-lazy-route copied to clipboard

Webpack: Critical dependency: the request of a dependency is an expression

Open scurker opened this issue 7 years ago • 1 comments

When bundling with webpack, you may come across the error:

Critical dependency: the request of a dependency is an expression

This is due to the dynamic require being used for server-side rendering. Since that require should never be utilized when bundling in webpack, we should not include that require for analysis when webpack is being used.

scurker avatar Apr 25 '17 14:04 scurker

I believe it would be nicer if the API was like this, and it would solve the problem with Critical dependency.

<LazyRoute path="/" component={() => import('./home')} ssr={() => require('./home')} />

evertonrobertoauler avatar Dec 18 '17 13:12 evertonrobertoauler