angular - 使用 SSR 调试 Angular 6 Universal
问题描述
Angular 6 正在使用 Universal SSR,但它占用了我的服务器资源。构建 PROD 时,我有以下警告。
WARNING in ./node_modules/bindings/bindings.js
81:22-40 Critical dependency: the request of a dependency is an expression
@ ./node_modules/bindings/bindings.js
@ ./node_modules/utf-8-validate/index.js
@ ./node_modules/ws/lib/validation.js
@ ./node_modules/ws/lib/receiver.js
@ ./node_modules/ws/index.js
@ ./server.ts
WARNING in ./node_modules/bindings/bindings.js
81:43-53 Critical dependency: the request of a dependency is an expression
@ ./node_modules/bindings/bindings.js
@ ./node_modules/utf-8-validate/index.js
@ ./node_modules/ws/lib/validation.js
@ ./node_modules/ws/lib/receiver.js
@ ./node_modules/ws/index.js
@ ./server.ts
WARNING in ./node_modules/@angular/core/fesm5/core.js
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
@ ./server.ts 5560:15-36 7:13-37
WARNING in ./node_modules/@angular/core/fesm5/core.js
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
@ ./server.ts 5572:15-102 7:13-37
你遇到过这些吗?我怎么能摆脱这些?
解决方案
我相信您可以通过在“webpack.server.config.js”文件中添加以下内容来解决此问题:
...
plugins: [
// Temporary Fix for issue: https://github.com/angular/angular/issues/11580
// for 'WARNING Critical dependency: the request of a dependency is an expression'
new webpack.ContextReplacementPlugin(
/(.+)?angular(\\|\/)core(.+)?/,
path.join(__dirname, 'src'), // location of your src
{} // a map of your routes
),
new webpack.ContextReplacementPlugin(
/(.+)?express(\\|\/)(.+)?/,
path.join(__dirname, 'src'),
{}
)
]
...
推荐阅读
- oracle - 无法将字符串 unicode(1000) 插入到 oracle 中的 nvarchar2(2000) 列
- r - Quantmod:一次为多个代码创建新列
- php - XMLReader 获取节点名称
- python - 为什么我的 selenium IDE 运行良好,而相同的 python 命令却不行?
- r - 在 bookdown 中包含 R 的自定义块
- javascript - 返回一个 Rust Vec
> 通过 WebAssembly 到 JavaScript - java - 匕首 - 延迟初始化属性演示者尚未初始化android
- ssl-certificate - 没有 https 的子域的基本身份验证,还是我应该为子域购买第二个 ssl 证书?
- php - 调用未定义的方法 Illuminate\Database\Query\Builder::attach()
- php - 使用 php 提取 http-equiv 内容