Typescript 未定义网页包导出模块
我想使用webpack为我的应用程序编译bundle.js。 通过将导入和导出添加到*.ts文件中,我创建了依赖关系树。 我在尝试运行应用程序时遇到一个问题 我有一个main.ts文件:Typescript 未定义网页包导出模块,typescript,webpack,dependencies,bundle,Typescript,Webpack,Dependencies,Bundle,我想使用webpack为我的应用程序编译bundle.js。 通过将导入和导出添加到*.ts文件中,我创建了依赖关系树。 我在尝试运行应用程序时遇到一个问题 我有一个main.ts文件: import { componentA, componentB } from 'moduleX'; import { componentC } from 'moduleC' export var componentE: componentA; $().ready(function () { if
import { componentA, componentB } from 'moduleX';
import { componentC } from 'moduleC'
export var componentE: componentA;
$().ready(function () {
if (componentA.someProperty === true) {
...
}
}
export class MyClass extends componentC {
...
}
// end file
这是我的moduleX文件:
import { componentE } from 'main';
import { componentC } from 'moduleC'
export componentA extends componentC {
...
if (componentE.someProperty === true) {
}
...
}
在运行build dev并尝试运行我的应用程序后,我得到了如下结果:
Uncaught ReferenceError: componentC is not defined
at eval (moduleX.js?d3a3:5913)
at Object../js/moduleX.js (bundle.js?8.0.0:96)
at __webpack_require__ (bundle.js?8.0.0:20)
at eval (main.ts?8a84:4)
at Object../js/main.ts (bundle.js?8.0.0:163)
at __webpack_require__ (bundle.js?8.0.0:20)
at bundle.js?8.0.0:84
at bundle.js?8.0.0:87
当我在chrome的moduleX.js?d3a3:5913查看源代码时,我可以看到:
var componentA = /** @class */ (function (_super) {
__extends(componentA, _super);
//componentA code
}(componentC));
我在}(componentC)中有一个错误代码>:未捕获引用错误:未定义组件C
问题在哪里?
你能帮我吗
问题在哪里?你能帮我吗
你有一个循环依赖
修理
移除它
例子
例如,foo
依赖于bar
依赖于baz
依赖于foo
(循环!)
工具
各种各样的。我也写了一篇: