Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The AngularCompilerPlugin was not found. #23

Closed
valera1401 opened this issue Oct 3, 2018 · 11 comments · Fixed by #39
Closed

The AngularCompilerPlugin was not found. #23

valera1401 opened this issue Oct 3, 2018 · 11 comments · Fixed by #39

Comments

@valera1401
Copy link

valera1401 commented Oct 3, 2018

Error occurs if some ts class is imported inside typescript.worker.ts.

It can be reproduced easily in the demo app. Just create some ts class and import it in typescript.worker.ts.

@jerbob92
Copy link

jerbob92 commented Jan 10, 2019

I also have this issue. I tried to inject services from the Angular app so we can use the same classes/logic in the workers, but this doesn't really seem to be possible sadly.
The worker support in NativeScript doesn't really seem to be that much used. How do people let their app perform?

@pacome2017
Copy link

I have the same error, I only import 'globals' in my workers. I'm trying to add webpack bundling, it worked ok without.

@JohnnyClutch
Copy link

I have the same problem with webpack and a worker. Using worker-loader as so:

const SEARCH_WORKER = require('worker-loader!../../../../workers/search');

Error from webpack dev server output:

ERROR in ./src/workers/search.ts (./node_modules/@ngtools/webpack/src!./src/workers/search.ts)
Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: The AngularCompilerPlugin was not found. The @ngtools/webpack loader requires the plugin.
    at Object.ngcLoader (/Users/gbullock/projects/gadmin-ui/node_modules/@ngtools/webpack/src/loader.js:27:15)

@dpavez14
Copy link

dpavez14 commented Feb 6, 2019

Take a look to this answer:
https://stackoverflow.com/a/54546214/4982126

@darkyelox
Copy link

I have this problem and i can't import any class from my Angular project using Typescript worker making this plugin almost useless and worst being the only way for threading in nativescript. You must fix this ASAP because is affecting the perception of NativeScript.

@Pala2812
Copy link

Pala2812 commented May 7, 2019

Also facing this issue. Unfortunately being able to process some long running tasks is a requirement for me so... This could be the reason to drop NS.
Has anyone found a workaround ?

@NickIliev
Copy link

@Pala2812 have you tried the solution suggested by @dpavez14 here

@Pala2812
Copy link

Pala2812 commented May 7, 2019

Need to try it tonight, if we pass an object to worker would we be able to call the functions. For example:

const backendLogic = new backendLogic ()
worker.postmessage({backend: backendLogic})

And in worker
context.onmessage = msg => {
msg.data.backend.init();
const data =msg.data.backend.getData();
context.postmessage(data)
}

@Pala2812
Copy link

Pala2812 commented May 8, 2019

i got it mostly working using the js worker - but now i've run into a problem.
when calling native api like com.microsoft.azure.storage.table.TableOperationType.delete it does not work as delete is a reserved js word. Any idea how to solve this ?

@edusperoni
Copy link
Contributor

@NickIliev
I decided to revisit this issue (past discussion here: #20).
I finally managed to fix this issue in my project using this as reference: GoogleChromeLabs/worker-plugin#13

Using the proposed solution generated another error inside nativescript-dev-webpack, which I believe comes from GenerateBundleStarterPlugin, so I modified the code to do the following:

const compilerOptions = this._compiler.options || {};
    console.log(compilerOptions.plugins);
    const workerCompiler = this._compilation.createChildCompiler("worker", outputOptions, [compilerOptions.plugins[6]]);

compilerOptions.plugins[6] was the AngularCompilerPlugin, in my case. (this is just a hack and proof of concept)

After this I was able to successfully import ts files and use the worker as I desired. So it seems the worker is not using the correct plugins.

I suggest we migrate from using worker-loader as a base implementation, to worker-plugin, which has proper support for plugins (including named plugins and etc).

@NidheeshMv
Copy link

Hello @edusperoni ,

I am getting the below error when i doing ns run ios.

***** Fatal JavaScript exception - application has been terminated. *****
NativeScript encountered a fatal error: Uncaught Error: Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: The Angular Webpack loader requires the AngularWebpackPlugin.
at Object.angularWebpackLoader (/app/node_modules/@ngtools/webpack/src/ivy/loader.js:44:18)
at
./src/polyfills.ts(file:///app/bundle.js:17:7)
at webpack_require(file: src/webpack:/MobileCore-app/webpack/bootstrap:24:0)
at webpack_exec(file:///app/bundle.js:27:39)
at (file:///app/bundle.js:28:28)
at (file:///app/bundle.js:33:3)
at require(:1:137)
(CoreFoundation) *** Terminating app due to uncaught exception 'NativeScript encountered a fatal error: Uncaught Error: Module build failed (from ./node_modules/@ngtools/webpack/src/index.js):
Error: The Angular Webpack loader requires the AngularWebpackPlugin.
at Object.angularWebpackLoader (/app/node_modules/@ngtools/webpack/src/ivy/loader.js:44:18)
at
./src/polyfills.ts(file:///app/bundle.js:17:7)
at webpack_require(file: src/webpack:/MobileCore-app/webpack/bootstrap:24:0)
at webpack_exec(file:///app/bundle.js:27:39)
at (file:///app/bundle.js:28:28)
at (file:///app/bundle.js:33:3)
at require(:1:137)
', reason: '(null)'
*** First throw call stack:

NS CLI - 8.1.5
Angular CLI - 12.1.4

Please help me to resolve this

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants