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

[Question] how to share code between {N} and web apps within Nx workspace #18

Open
sergegl opened this issue May 5, 2021 · 4 comments
Labels
question Further information is requested

Comments

@sergegl
Copy link

sergegl commented May 5, 2021

Hi there,

I noticed --shared option is not available.
Is it something coming down the pipeline or is it better to look at other solutions?

I guess one way is extend original .ts files, but it doesn't look too clean as it could've been done with .tns. files.

Do you have other suggestion on how to use nativescript web & mobile in NX besides xplat?

Thank you,
Sergei.

@sergegl sergegl changed the title No way to get --shared code going. [FEATURE REQUEST] No way to get --shared code going. May 5, 2021
@NathanWalker
Copy link
Contributor

NathanWalker commented May 6, 2021

Hi @sergegl - the approach @nativescript/nx and xplat both take is just pure folder/code organization for shared web/mobile codebases. We strongly believe that using custom file extensions (.tns) for pure sake of code sharing is not a good scalable way to go from practical experience in that area and do encourage others to not go down that path.

If you need tips on how to use @nativescript/nx within Nx workspace alongside a web app and share code effectively let us know. Perhaps there's couple pointers we could provide there - Nx in general provides a lot of flexibility in this area.

@NathanWalker NathanWalker added the question Further information is requested label May 6, 2021
@NathanWalker NathanWalker changed the title [FEATURE REQUEST] No way to get --shared code going. [Question] how to share code between {N} and web apps within Nx workspace May 6, 2021
@sergegl
Copy link
Author

sergegl commented May 6, 2021

Hi @NathanWalker, thank you for a quick reply!

Defiantly tips would be greatly appreciated.
I currently have some apps in my monorepo and would like to convert some of them into native apps.
What would you suggest, since I want to have separate views for each app?

I was thinking either inherit current web components or just yank some logic into base classes that each web & mobile components would extend from.

Please let me know.

Thanks again,
Sergei.

@mahmoudajawad
Copy link
Contributor

@sergegl, this might interest you: #20 (comment)

@rob4226
Copy link
Contributor

rob4226 commented Jun 30, 2021

Hi @sergegl - the approach @nativescript/nx and xplat both take is just pure folder/code organization for shared web/mobile codebases. We strongly believe that using custom file extensions (.tns) for pure sake of code sharing is not a good scalable way to go from practical experience in that area and do encourage others to not go down that path.

If you need tips on how to use @nativescript/nx within Nx workspace alongside a web app and share code effectively let us know. Perhaps there's couple pointers we could provide there - Nx in general provides a lot of flexibility in this area.

Some tips would definitely help. Right now I have a NativeScript 7 Angular 11 mobile/web shared project. I am currently using the method that the NS v7 docs outlined using .tns.ts extensions or .web.ts extensions for platform specific code. I want to upgrade to NativeScript 8 and Angular 12 but with the new webpack config I have not been able to figure it out.

If starting to use an nx workspace would still allow me to have a shared mobile/web project I would definitely convert the project to an nx workspace but I am not sure how to do that. Are there any examples or documentation available for using an Nx workspace with NativeScript 8 Angular 12 shared mobile/web project? Thank you!

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

No branches or pull requests

4 participants