【发布时间】:2017-03-30 06:50:57
【问题描述】:
我在加载组件时收到此错误:
./~/@angular/core/@angular/core.es5.js 5889:15-36 关键依赖:依赖的请求是一个表达式
谁能帮忙弄清楚这是什么意思?
【问题讨论】:
-
Angular 2?还是角 4?我刚刚从 2 更新到 4 并开始收到此警告。你弄清楚是什么原因造成的了吗?
标签: webpack
我在加载组件时收到此错误:
./~/@angular/core/@angular/core.es5.js 5889:15-36 关键依赖:依赖的请求是一个表达式
谁能帮忙弄清楚这是什么意思?
【问题讨论】:
标签: webpack
好的,我的问题已经解决了。也许你正在经历同样的事情。 在 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'),
{}
)
【讨论】:
我得到了与 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';
有人遇到同样的问题吗?
【讨论】: