NativeScript / worker-loader

36 stars 20 forks source link

Bundling worker files (iOS) #14

Open erjdriver opened 6 years ago

erjdriver commented 6 years ago

I'm using NS 4.0, CORE 4.0 and IOS 4.0.1

I issue the following commands to install webpack

`

npm install --save-dev nativescript-dev-webpack@0.11.0

npm install

npm install nativescript-worker-loader -D

./node_modules/.bin/update-ns-webpack --configs --deps`

My project is Typescript.

I have the following line to load my worker file

import * as MyWorker from "nativescript-worker-loader!./worker";

But I'm getting a module-not-found exception at run-time.

If I comment the above line out (along with the associated code) - no exception at runtime.

I believe the above was the proper syntax a few web pack revisions ago.

What's the proper way to reference a worker file?

Here's the run-time exception:

JavaScript error: file:///app/export-page.js:7:23: JS ERROR Error: Could not find module 'nativescript-worker-loader!./worker'. Computed path '/Users/asrock/Library/Developer/CoreSimulator/Devices/BEDAEBC0-9E68-4E60-AFCB-04AA1E6BED4A/data/Containers/Bundle/Application/37DBBAB2-885B-4F04-9866-15F3430F7B17/publishios.app/app/tns_modules/nativescript-worker-loader!./worker'.

Thanks.

davorpeic commented 6 years ago

Did you created reference file as mentioned here? https://github.com/NativeScript/worker-loader#integrating-with-typescript

erjdriver commented 6 years ago

Yes I did.

I also did a blank project with a simple worker and that works.

The one thing that's different about my project is that I don't have a app.css file.

My app is theme based and I define four scss files which generate the respective css files.

webpack and vendor.ts files seem to refer or expects a app.css file.

What do I need to do - to account for no app.css file.

Thanks.

PeterStaev commented 6 years ago

@erjdriver make sure you dont have an error during the bundling process. From the error it seems that webpack did not replace the import of the worker. It doesn't seem related to app.css.

fransyozef commented 5 years ago

Hmm I have the same problem. First I had scss errors, so I fixed that. Using Angular. But I also get Could not find module 'nativescript-worker-loader!./workers/typescript.worker'

Eonfuzz commented 5 years ago

... and the same here, I'm trying to implement workers and running into JS ERROR Error: Could not find module 'nativescript-worker-loader!./async-loader.worker'

@erjdriver Did you end up resolving your issue, and if so please post how.

Edit: Even launching the demo-angular app throws a similar error:

file:///app/worker.service.js:5:23: JS ERROR Error: Could not find module 'nativescript-worker-loader!./workers/typescript.worker'. Computed path '/Users/Eonfuzz/Library/Developer/CoreSimulator/Devices/27BC1C0E-FFE7-4EFE-829A-10D9A18FE2AF/data/Containers/Bundle/Application/076FE98C-5BF4-4C9E-B897-3B1C280490FC/demoangular.app/app/tns_modules/nativescript-worker-loader!./workers/typescript.worker'.

To reproduce: git clone https://github.com/NativeScript/worker-loader cd ./demo-angular npm i tns run ios