-
-
Notifications
You must be signed in to change notification settings - Fork 20
Plugin is not working with nativescript 4.1 #20
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
Comments
I worked around it by copying the content of the few ts imports I had (mainly interfaces) to the worker file. Then it at least ran. Aditionally, I'm getting some seemingly random syntax errors when some workers are created. My import inside sqlite.worker.ts:
the random error (SyntaxError changes from run to run):
I usually instantiate about 3 Workers in a row, which is when the error occurs. |
@edusperoni , you can change:
to:
to avoid the error I don't have error syntax, my issue is this: ERROR in ./services/bluetooth-scanner/bluetooth-scanner.worker.ts (../node_modules/nativescript-dev-webpack/moduleid-compat-loader.js!../node_modules/@ngtools/webpack/src!./services/bluetooth-scanner/bluetooth-scanner.worker.ts) And my worker is:
As you see I don't have any interface or external class. Regards |
I forgot to apply the steps 6 and 7 of the README |
That's weird, I was having the same problem even when applying step 6 and 7, I'll test it tomorrow |
@edusperoni put your webpack.config.js in a comment and I will help you |
SyntaxError:When I use
The original syntax error (using require) is completely random. Sometimes it'll run fine, while others will throw an error. I have yet to test it with webpack enabled. Webpack + ts-loader:When I try to import other ts files:
sqlite.types.ts:
If I remove the import and copy the content of sqlite.types.ts to the worker, it works, but it's very hacky. The code works fine without webpack. |
Register your file in references.d.ts to use it in your worker.
|
Those types are just so it's easier to send messages and help me with type completion as I'm using the free version. The problem is the code worked fine with NS 4.0, and using workers with sqlite and shared imports are simply not working on 4.1+webpack 0.12. I'm fine working around my custom types for now (it's already working in my test build), I'm mainly adding this info so it helps the dev team fix the regression |
Hello, I have the same problem as edusperoni, the import via reference.d.ts does not work I always have the error:
|
It seems the AngularCompilerPlugin error was fixed in 0.13.0: NativeScript/nativescript-dev-webpack#539 I'll test it out. Still don't know why the syntax error occurs from time to time. |
Nope, the problem still occurs. I've narrowed it down to my enum. If I import my types without referencing them in code, no error occurs, but as soon as I reference my enum somewhere, webpack fails. Referencing interfaces only is fine. |
i used NativeScript/nativescript-dev-webpack@e349fa8 but I still have the same mistake :
my package.json :
my webpack.config.js :
I just want to import my class soap into my worker |
Hey guys, same issue here. Trying to import an static helper class into my worker but I get the Had to duplicate logic for now :( |
@jeremypele update your Angular, |
We're having the same issue in our solution... Everything is upgraded.
...among other packages. But still getting the same error:
Any solution to this issue? This is completely blocking our upgrade to Angular 6 right now. |
We have managed to fix the issue by converting our workers to javascript. If you don't want to "allowJs" in your tsconfig, then create and compile the workers in a custom plugin and include that one as a dependency in your app. Fingers crossed that using TypeScript workers inside your app will be fixed some day. |
@YvesCandel Yup, did the very same thing for now 👍 |
I'm running into the same issue. Still no better way than to re-write the worker to plan js ? (the problem is that I'm using quite a few ts classes that are shared between the worker and the rest of the app) so it would be a pain to manage going forward |
@darxmac @jeremypele @YvesCandel you can now use TypeScript workers just as using plain JS workers. For example: let worker: any;
if ((<any>global).TNS_WEBPACK) {
var TsWorker = require("nativescript-worker-loader!./workers/typescript.worker.js"); // note that here we are requiring the transpiled JS file
worker = new TsWorker();
} else {
worker = new Worker("./workers/typescript.worker.js");
}
return worker; I've updated the demo via this PR which demonstrates the above logic. You can also use this POC app for reference. |
It seems this was actually fixed in the latest nativescript-dev-webpack release, and not by changing the worker to js. I tried changing it to js and updating the webpack config file and it still failed when importing some other files. Updating nativescript-dev-webpack and updating dependencies+config fixed the error. I haven't tried changing it to a TS worker again, but this will only work on nativescript-dev-webpack >=0.16.0 Edit: Actually, scratch that. What I actually had to do was:
instead of:
Otherwise webpack will fail trying to load the .ts file. I think this issue should probably be reopened. |
So, upgraded everything (I guess), and even changed import statements in my worker:
(commented lines is from previous trial), but error persists: Build:
package.json:
|
I agree this should be reopened. The sample projects do not give an example of using shared, internal code within the webworker. What I had to do (based on your suggestion) was in my internal "engine" that I want the webworker to use, I changed all imports to end in It might be possible to tweak |
Uh oh!
There was an error while loading. Please reload this page.
After follow the next: Upgrading to NativeScript Webpack 0.12.0
This plugin doesn't work. You can use your example angular project to get the errors.
$tns build android --bundle
Regards.
The text was updated successfully, but these errors were encountered: