【问题标题】:Debugging Angular 6 Universal with SSR使用 SSR 调试 Angular 6 Universal
【发布时间】:2018-12-03 01:42:53
【问题描述】:

Angular 6 正在使用通用 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

你遇到过这些吗?我怎样才能摆脱这些?

【问题讨论】:

    标签: angular warnings angular6 angular-universal server-side-rendering


    【解决方案1】:

    我相信您可以通过在“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'),
          {}
        )
      ]
    ...

    【讨论】:

      猜你喜欢
      • 2022-10-07
      • 1970-01-01
      • 2023-02-15
      • 2020-12-16
      • 1970-01-01
      • 2019-02-15
      • 2021-11-01
      • 2021-03-19
      • 1970-01-01
      相关资源
      最近更新 更多