Im trying to setup an Angular project with Worker Loader. I am able to run the app but failed at running karma! Here is my approach:
- Created project with
ng new webpack-worker-loader-karma->ng serveandng testworks - Added webpack
worker-loaderto projectnpm i -D worker-loader - Created worker typescript file
src/app/simple-loader.ts Created worker type definitions in
src/typings.d.ts:declare module 'worker-loader?inline!*' { class WebpackWorker extends Worker { constructor(); } export default WebpackWorker; }Added code for instantiation of worker in
src/app/app.component.ts->ng servereturns this error:ERROR in ./node_modules/@ngtools/webpack/src!./src/app/simple-worker.ts Module build failed: Error: @ngtools/webpack is being used as a loader but no `tsConfigPath` option nor AotPlugin was detected. You must provide at least one of these. at Object.ngcLoader (/[path]/webpack-worker-loader-karma/node_modules/@ngtools/webpack/src/loader.js:617:19)`
Had to set the tsConfigPath in webpack.config.js. So I ejected the project and changed the config:
{ "test": /\.ts$/, "loader": "@ngtools/webpack", "options": { "tsConfigPath": "src/tsconfig.app.json", } }
npm start -> works!
npm test -> error:
ERROR in ./node_modules/@ngtools/webpack/src!./src/app/simple-worker.ts
Module build failed: Error: @ngtools/webpack is being used as a loader but no `tsConfigPath` option nor AotPlugin was detected. You must provide at least one of these.
at Object.ngcLoader (/[path]/webpack-worker-loader-karma/node_modules/@ngtools/webpack/src/loader.js:617:19)
I think I have to set the tsConfigPath for karma. But don't know how. Any ideas?
I published the project on github: