Module not find error after upgrading to Angular 9/NativeScript 7
kaustavlahiri opened this issue · 3 comments
After upgrading to Angular 9 (from 8) and NS 7 (from 6), the worker classes fail to initialize when using the webpack loader method.
It runs into Module not found errors.
We have kept Ivy mode turned off and using ts loader to compile worker classes.
Setup:
package.json
"nativescript-worker-loader": "^0.12.1",
"nativescript-dev-webpack": "^1.5.0",
webpack
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
.
.
.
module : {
rules: [
.
.
{
test: /(?:.ngfactory.js|.ngstyle.js|.ts)$/,
exclude: /.worker.tns.ts$/,
use: [
"nativescript-dev-webpack/moduleid-compat-loader",
"nativescript-dev-webpack/lazy-ngmodule-hot-loader",
"@ngtools/webpack",
]
},
{ test: /.worker.tns.ts$/, loader: "ts-loader" },
{
test: /[/\]@angular[/\]core[/\].+.js$/,
parser: { system: true },
},
]
}
plugins: [
.
.
new NativeScriptWorkerPlugin(),
]
someworker.service.tns.ts
import * as WorkerScript from 'nativescript-worker-loader!./../../workers/myWorker.worker.tns';
.
.
this.possibleActionsWorker = new WorkerScript();
Error on compile (tns run ios....)
ERROR in src/app/services/add-work/someworker.service.tns.ts:15:40 - error TS2307: Cannot find module 'nativescript-worker-loader!./../../workers/possibleActions.worker.tns'.
15 import * as WorkerScript from 'nativescript-worker-loader!./../../workers/myWorker.worker.tns';
Want to add that we also tried using Workers API method --> new Worker ('./../../workers/myWorker.worker.tns'), but that causes build process to remain stuck forever.
bump! any news on this?
It's really a bummer that with every new release of {N} something has to break. Is it because we are using now native"@nativescript/webpack" instead of nativescript-dev-webpack?
Please let us know how we can fix this.
This may help - I had the same error after upgrading my Svelte Native project to NativeScript 7, and after a bit of poking around I was able to get past this build error by explicitly adding my references.d.ts file (which is in the root of my project) to the "include" list in my tsconfig.json. the "include" list originally was:
"include": [
"app/**/*"
],so I changed it to
"include": [
"app/**/*",
"references.d.ts"
],For reference, my NS6 tsconfig had no include section.
I'm not familiar with the Angular project setup, but you might see if something like this helps.
It's possible moving my references.d.ts file to the app/ directory would have worked as well.