wwwy3y3 / coren

React offline server-rendered framework
Apache License 2.0
103 stars 2 forks source link

fix 'Critical dependency: the request of a dependency is an expression' #7

Closed ctxhou closed 7 years ago

ctxhou commented 7 years ago

when require var, webpack will throw Critical dependency: the request of a dependency is an expression warning and it will break hmr.

app.js: https://github.com/Canner/coren/blob/master/server/app.js#L45-L47

solution reference:

ctxhou commented 7 years ago

fix at https://github.com/Canner/coren/commit/e92978f471ec0ddfa48902818bfe4dad9d7bf81d

Because user will not use App component, remove it from coren api.

ssougnez commented 7 years ago

Hi,

I just updated angular to v5.0.0-beta.6 and this error is back (I didn't have it with version 5.0.0-beta.5. Here is the error:

WARNING in C:/.../node_modules/@angular/core/esm5/index.js 5697:15-36 Critical dependency: the request of a dependency is an expression WARNING in C:/.../node_modules/@angular/core/esm5/index.js 5713:15-102 Critical dependency: the request of a dependency is an expression

Here is the supposed fix in the webpack.config.json. It used to work for a few weeks now (since the project creation) and started to fail just after the upgrade.

new webpack.ContextReplacementPlugin(/angular(\\|\/)core(\\|\/)@angular/, helpers.root("src"))

Regards

ctxhou commented 7 years ago

Hi @ssougnez, I think your error is caused by angular. You can open this issue on their repo.

ssougnez commented 7 years ago

Oops, sorry, I came from a link in the angular repo, I didn't notice I ended up on another one.