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

problem using a "lib" also for server consumption (node.js) #231

Closed
maku opened this issue Jan 25, 2018 · 3 comments
Closed

problem using a "lib" also for server consumption (node.js) #231

maku opened this issue Jan 25, 2018 · 3 comments

Comments

@maku
Copy link

maku commented Jan 25, 2018

I have the problem that a lib which contains logic should also be used in a server (node.js based).
In this case I have a basic lib which contains generic logic and a concrete "domain" lib which is based on this basic lib (say salesmodel lib uses model lib)

Now this salesmodel lib should be usable in client AND server. But I have really no idea how to get that working. (up to now this libs were good old dependencies)

Recognized problems: libs are exposed via typescript path. So all imports in "salesmodel lib" are barrel based. e.g.

import {x} from @myproject/salesmodel

Node.js is not able to resolve this. Maybe this can be solved via a helper like https://github.com/dividab/tsconfig-paths

But I have also problems on compiling the server part. How can I structure the app that the server part is included

Is there something like a guide how to tackle this? Has anybody solved this problem?

@kylecordes
Copy link

I have found it is possible to sit a package.json file in a lib/blah directory - Nx ignores it and continues working as before, and using that package file you can do all the normal things that you would do to make a valid NPM TypeScript package.

@vsavkin vsavkin added this to the 2.0.0 milestone Apr 24, 2018
@JamesHenry JamesHenry removed this from the 2.0.0 milestone Jul 16, 2018
@vsavkin
Copy link
Member

vsavkin commented Apr 15, 2019

Sorry for a super late reply :) This is a guide that shows how it can be done: https://nx.dev/fundamentals/build-full-stack-applications

@vsavkin vsavkin closed this as completed Apr 15, 2019
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants