Title: [AOT] multiple workers won't compile using aot · Issue #5247 · NativeScript/nativescript-cli · GitHub
Open Graph Title: [AOT] multiple workers won't compile using aot · Issue #5247 · NativeScript/nativescript-cli
X Title: [AOT] multiple workers won't compile using aot · Issue #5247 · NativeScript/nativescript-cli
Description: While working with workers in nativescript we stuck with an error when there is more than one worker defined and being used. There is no issue while compiling with JIT but by adding the AOT flag the project won't compile and following er...
Open Graph Description: While working with workers in nativescript we stuck with an error when there is more than one worker defined and being used. There is no issue while compiling with JIT but by adding the AOT flag th...
X Description: While working with workers in nativescript we stuck with an error when there is more than one worker defined and being used. There is no issue while compiling with JIT but by adding the AOT flag th...
Opengraph URL: https://github.com/NativeScript/nativescript-cli/issues/5247
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[AOT] multiple workers won't compile using aot","articleBody":"While working with workers in nativescript we stuck with an error when there is more than one worker defined and being used. There is no issue while compiling with JIT but by adding the AOT flag the project won't compile and following error raises\r\n\r\n```\r\nChild worker:\r\n Asset Size Chunks Chunk Names\r\n 0adb156fd1eb2394a395.worker.js 4.21 MiB main [emitted] main\r\n Entrypoint main = 0adb156fd1eb2394a395.worker.js\r\n [../node_modules/ts-loader/index.js!./workers/second.worker.ts] ../node_modules/ts-loader!./workers/second.worker.ts 430 bytes {main} [built]\r\n [./package.json] 139 bytes {main} [optional] [built]\r\n [./shared.ts] 130 bytes {main} [built]\r\n + 252 hidden modules\r\nChild worker:\r\n Asset Size Chunks Chunk Names\r\n 5caf84999f4cdd72d8dd.worker.js 4.21 MiB main [emitted] main\r\n Entrypoint main = 5caf84999f4cdd72d8dd.worker.js\r\n [../node_modules/ts-loader/index.js!./workers/typescript.worker.ts] ../node_modules/ts-loader!./workers/typescript.worker.ts 416 bytes {main} [built]\r\n [./package.json] 139 bytes {main} [optional] [built]\r\n [./shared.ts] 130 bytes {main} [built]\r\n + 252 hidden modules\r\n\r\n ERROR in Internal Error: already initialized!\r\nWebpack compilation complete.\r\nExecuting webpack failed with exit code 2.\r\n```\r\n\r\nso this issue happens if there is more than one javascript or typescript worker defined. \r\n\r\n**Sample project**\r\nI have modified the official webworker sample ( https://github.com/NativeScript/worker-loader/tree/master/demo-angular ) and just added a second typescript worker. the sample source code can be found at https://github.com/trodellez/twoworker\r\n\r\nso basically I have added a second ts worker \r\n```typescript\r\nimport \"tns-core-modules/globals\";\r\nimport { sharedFunction } from \"../shared\";\r\n\r\nconst context: Worker = self as any;\r\n\r\ncontext.onmessage = msg => {\r\n sharedFunction(\"worker\");\r\n setTimeout(() => {\r\n console.log(\"Inside Second TS worker...\");\r\n console.log(msg);\r\n (\u003cany>global).postMessage(\"Second TS Worker\");\r\n }, 500)\r\n};\r\n```\r\nand added a method to worker.service.ts to initialize it\r\n```typescript\r\ninitSecondTsWorker() {\r\n if (this.secondTsWorker) {\r\n return this.secondTsWorker;\r\n }\r\n\r\n // add if building with webpack\r\n this.secondTsWorker = new SecondTsWorker();\r\n\r\n return this.secondTsWorker;\r\n }\r\n```\r\nthen the project won't compile anymore with aot flag\r\n```\r\ntns build android --env.aot\r\n```\r\nany help would be really appreciated","author":{"url":"https://github.com/m0-h0","@type":"Person","name":"m0-h0"},"datePublished":"2020-02-11T15:56:38Z","url":"https://github.com/NativeScript/nativescript-cli/issues/5247"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8c82b971-8658-ab15-f22c-92b43d418325 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A704:38C5CF:20CB1D9:299EF27:6B015694 |
| html-safe-nonce | ab9b9334426520024165ed832a74570ee38b8987d2508815a929fa6bc92db423 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzA0OjM4QzVDRjoyMENCMUQ5OjI5OUVGMjc6NkIwMTU2OTQiLCJ2aXNpdG9yX2lkIjoiNDE0MzYwNTA2NTM3MTk2NTA3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a4aae3227bfb4d9deadd599b54654d7115468336b4f398611971ef943a166adc |
| hovercard-subject-tag | issue:564055028 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/nativescript-cli/5247/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1cb2e15ac51b711ae044f0cbdb3b735e2cd2a0af894cc5920d43386efbea8d20/NativeScript/nativescript-cli/issues/5247 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1cb2e15ac51b711ae044f0cbdb3b735e2cd2a0af894cc5920d43386efbea8d20/NativeScript/nativescript-cli/issues/5247 |
| og:image:alt | While working with workers in nativescript we stuck with an error when there is more than one worker defined and being used. There is no issue while compiling with JIT but by adding the AOT flag th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | m0-h0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/nativescript-cli git https://github.com/NativeScript/nativescript-cli.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 21347346 |
| octolytics-dimension-repository_nwo | NativeScript/nativescript-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21347346 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/nativescript-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width