【问题标题】:webpack: Critical dependency messagewebpack:关键依赖消息
【发布时间】:2017-03-30 06:50:57
【问题描述】:

我在加载组件时收到此错误:

./~/@angular/core/@angular/core.es5.js 5889:15-36 关键依赖:依赖的请求是一个表达式

谁能帮忙弄清楚这是什么意思?

【问题讨论】:

  • Angular 2?还是角 4?我刚刚从 2 更新到 4 并开始收到此警告。你弄清楚是什么原因造成的了吗?

标签: webpack


【解决方案1】:

好的,我的问题已经解决了。也许你正在经历同样的事情。 在 Angular 2.x 中我有

new webpack.ContextReplacementPlugin(
    // The (\\|\/) piece accounts for path separators in *nix and Windows
    /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
    root('./app'), // location of your src
    {} // a map of your routes
)

现在在 Angular 4.x 中它更改为...

new webpack.ContextReplacementPlugin(
        /angular(\\|\/)core(\\|\/)@angular/,
        root('./app'),
        {}
)

根据这篇帖子https://github.com/angular/angular/issues/11580

【讨论】:

  • @Landeeyo 在你的 webpack 配置的插件部分
【解决方案2】:

我得到了与 typescript.js 相同的消息。

[...]/node_modules/typescript/lib/typescript.js 5123:41-60 关键依赖:依赖的请求是一个表达式

我知道它与 typescript.js 文件和第 5123 行写的动态要求有关:

return { module: require(modulePath), modulePath: modulePath, error: undefined };

我尝试了很多次,但我真的不知道如何使用 ContextReplacementPlugin 来避免这个警告。

当我从 typescript 模块使用 transpile 时出现警告

import { transpile } from 'typescript';

有人遇到同样的问题吗?

【讨论】:

    猜你喜欢
    • 2016-08-28
    • 2017-08-11
    • 2013-03-09
    • 2016-11-18
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    相关资源
    最近更新 更多