如何解决Webpack:TypeScript编译中缺少 ...在AngularCompilerPlugin.getCompiledFile
我在Web应用程序中使用10.1.0-next.4
"@ngtools/webpack": "^10.0.0","webpack": "^4.43.0",
在构建时出错。
PS D:\app2020\testing\local\angular10\sampleangular10app\myangular10app> ng run myangular10app:build-worker
Hash: 8132eb4a13b2ee0de491
Version: webpack 4.44.1
Time: 134ms
Built at: 08/12/2020 12:01:42 AM
Asset Size Chunks Chunk Names
./src/appResourceFiles/workers/httpWebWorker.js 1.66 KiB 0 ./src/appResourceFiles/workers/httpWebWorker
Entrypoint ./src/appResourceFiles/workers/httpWebWorker = ./src/appResourceFiles/workers/httpWebWorker.js
[0] multi ./src/webWorker/main.worker.ts 28 bytes {0} [built]
[1] ./src/webWorker/main.worker.ts 734 bytes {0} [built] [failed] [1 error]
ERROR in ./src/webWorker/main.worker.ts
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: D:\app2020\testing\local\angular10\sampleangular10app\myangular10app\src\webWorker\main.worker.ts is missing from the TypeScript compilation. Please
make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (D:\app2020\testing\local\angular10\sampleangular10app\myangular10app\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:935:23)
at D:\app2020\testing\local\angular10\sampleangular10app\myangular10app\node_modules\@ngtools\webpack\src\loader.js:42:31
at processTicksAndRejections (internal/process/task_queues.js:97:5)
@ multi ./src/webWorker/main.worker.ts ./src/appResourceFiles/workers/httpWebWorker[0]
PS D:\app2020\testing\local\angular10\sampleangular10app\myangular10app>
这是github示例应用程序。我需要更新或缺少任何配置或版本吗?
解决方法
您需要将项目目录包括在 include 中,否则,您的代码将不会被编译。在tsconfig.app.json中更改:
export class Tab2 extends Component {
constructor(props: any) {
super(props);
this.playVideo = this.playVideo.bind(this)
}
playVideo() {
// THE PROBLEM
const history = useHistory();
// NEED SOME REDIRECTION ON CLICK HERE
history.push("/tab1")
}
render() {
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Tab 2</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">Tab 2</IonTitle>
</IonToolbar>
</IonHeader>
<IonButton onClick={this.playVideo}>This is a play button</IonButton>
</IonContent>
</IonPage>
);
}
};
或
"files": [
...,"node_modules/jqwidgets-scripts/jqwidgets-ts/angular_jqxbargauge.ts"
],
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。