角度 – 由模块“AppModule”导入的意外值“MyCustomModule”
发布时间:2020-12-17 08:16:11 所属栏目:安全 来源:网络整理
导读:我正在尝试将一个我的angular2自定义库迁移到RC.6 Webpack。我的目录结构是: - src - source TS files- lib - transpiled JS files + definition files- dev - development app to test if it works / looks ok.- myCustomLib.js - barrel- myCustomLib.d.t
|
我正在尝试将一个我的angular2自定义库迁移到RC.6 Webpack。我的目录结构是:
- src - source TS files - lib - transpiled JS files + definition files - dev - development app to test if it works / looks ok. - myCustomLib.js - barrel - myCustomLib.d.ts 在dev文件夹中尝试运行一个应用程序。我引导我的模块: app.module.ts import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { MyCustomModule } from "../../myCustomLib";
@NgModule({
imports: [
BrowserModule,MyCustomModule
],declarations: [ AppComponent ],bootstrap: [ AppComponent ]
})
export class AppModule {
}
现在使用webpack我捆绑我的开发应用程序。 webpack.config.js module.exports = {
entry: "./app/boot",output: {
path: __dirname,filename: "./bundle.js",},resolve: {
extensions: ['','.js','.ts'],modules: [
'node_modules'
]
},devtool: 'source-map',module: {
loaders: [{
test: /.js$/,loader: 'babel-loader',exclude: /node_modules/
},{
test: /.ts$/,loader: 'awesome-typescript-loader',exclude: /node_modules/
}]
},watch: true
};
但是当我尝试加载该应用程序时,我会收到一条消息: metadata_resolver.js:230 Uncaught Error: Unexpected value 'MyCustomModule' imported by the module 'AppModule' 我的桶文件导入如下: myCustomLib.js export * from './lib/myCustomLib.module'; 我也发现了hint on similar topic on github,但改为: export { MyCustomModule } from './lib/myCustomLib.module';
没有帮助。我也尝试从src目录导入模块 – 同样的错误。 MyCustomModule应该可以,因为它在systemJS之前工作正常。 myCustomLib.module.ts: import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
@NgModule({
imports: [
BrowserModule
]
})
export class MyCustomModule {}
任何想法可能是这个错误的原因?我在这里看过类似的话题,但没有回答或提示帮助。 编辑:为了使这个例子更简单,我已经从MyCustomModule中删除了全部 – 同样的问题…
在myCustomLib.js中,尝试在导出之前导入
import { MyCustomModule } from './lib/myCustomLib.module;
export MyCustomModule;
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
