-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
use yarn workspace to build packages #1060
Conversation
When using workspaces, you should structure the project differently. |
@marcus-sa I know it's good to separate each package, current package structure comes with some problems.
I think my current commits is a minium modification towards yarn workspace and can be merged. I will try to work this 2 problems out this weekend. |
|
Breaking changes, who cares? Meanwhile you're at it you could remove all the deprecated features anyway, I mean if they're not gonna be removed, why tf even mark them as deprecated? |
I put source code into an It's such a boring thing, I don't know if these changes are good for you @kamilmysliwiec |
Current status: All the 5 packages compile well, and sample code runs well, so this should be a backward compitable change. This package structure looks really good 😸 Current package list: I'd like to move sample directory into workspace so we can try the latest code in sample projects. Current test status: I just fixed test case in Advice and reviews are welcome, thanks! |
@xcaptain Great job!! Really well done! |
All the import statements in
I have uninformed all these styles into 1 Till now I think this pr is ready to be reviewed and merged. |
The only problem which I notice is that this PR is incredibly huge which makes it almost impossible to review |
Maybe removing the bundle directory? |
Maybe is there a way to somehow split this PR into a few parts? They don't have to necessarily play well separately. For example, firstly just push configuration stuff+small instructions what should I do in order to make it work well. I could move all source files manually which would be 1000x faster than reviewing each existing file 😅 |
@kamilmysliwiec This is only project struct adjust ,there are not any function changes. |
@kamilmysliwiec This pr should be backward compatible, the main work I did includes:
tests in |
Yes, this pr was mainly just directory structure change, this idea originally come from that I want to learn this framework but after I dug into the source code I found that I have to install these packages from npmjs rather than local. If the pr get merged I think contributing to this project will be much easier |
Please, could you get rid of merge conflicts? Looking at the source code now :) |
aa5e307
to
dd3aebd
Compare
@kamilmysliwiec I just rebased this pull request. I think the biggest controversial point exists in how I deal with module import in |
Just figured this out. I think that the problem really is that this PR simplifies contribution (which is great) although it affects developer experience. If we decide to export everything from the root file, it would mean that each of these interfaces/classes is a part of the public API that may be used by the developers in their projects built on top of Nest. We definitely cannot export everything, it may bring a lot of mess in auto-completion/intellisense provided by the IDE. A huge list of useless exports may potentially lead to very bad decisions. |
Some of this stuff is used by nest packages internally, just to provide more context about a specific thing. They should never be used in real projects. |
@kamilmysliwiec Yes, I know expose too much API is bad, but as I said in #1060 (comment) I recgonize For example To import in
But for style consistency I prefer to write the former one. |
I understand it @xcaptain. However, we still need to get rid of internal types and it's impossible with the current approach. |
Good practices and code organization are fine as soon as they don't mean a lot of troubles for the end user. |
Not that hard to fix. {
"extends": "./tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./packages",
"paths": {
"@nestjs/core": ["./core/src"],
"@nestjs/core/*": ["./core/src/*"],
"@nestjs/common": ["./common/src"],
"@nestjs/common/*": ["./common/src/*"]
}
},
"exclude": [
"./packages/*/__tests__",
"./packages/*/lib",
"node_modules"
]
} Only downside is that you'd have to add two paths per package. import { NestedFile } from '@nestjs/core/nested/dir/whatever/path';
import { RootFile } from '@nestjs/core'; or you could just keep it as it currently is, and use the base url. // <rootDir>/packages/core/src/nested/dir/whatever/path.ts
import { NestedFile } from 'core/nested/dir/whatever/path';
// <rootDir>/packages/core/src/index.ts
import { RootFile } from '@nestjs/core'; |
@marcus-sa Path mapping is good but this makes all the exported APIs accessible outside the package which I think @kamilmysliwiec won't like because of exposing too many public APIs. |
Put |
Not sure if |
https://github.com/marcus-sa/one check my repo, it works flawlessly (that'll soon be a PR for nest once I've migrated the server related modules) |
I believe that it works, I'm rather thinking about whether it's straightforward from the user perspective (to lookup for samples in the packages dir) |
@marcus-sa ❤️:boom: |
You don't have to lookup samples in the packages directory. |
Ohh, I thought you were talking about directories tree. Sorry for the confusion, this is the outcome of reading email's notifications 😅 |
This pull request is still not ready to merge due to microsoft/TypeScript#10866, though I think this is an typescript bug but I don't know why it's not solved in such a long time. |
That is not a TypeScript bug, that's just how module resolution works in Node. |
@marcus-sa So do you have any good solution on this, for example: in |
Just a quick note - moving output files to the |
The only solution I have is to output the |
Only solution without having to access the You could copy |
then tell |
There was a node issue about this nodejs/node#15755 but no one cares. @marcus-sa lerna won't support publish specific directory |
There's always those small hacks that makes life great sometimes ;) Steps
Could easily be done using a |
General question regarding this topic; It seems like the problem is certain packages are using internal functionalities of different nest packages which are not part of their public API? I am not an Angular expert; but does anybody know how they solve this issue? Reading through your suggestions it feels like we're just creating a workaround to get it working, but not solving the real issue? |
@BrunnerLivio |
@kamilmysliwiec |
I don't think that splitting the package into even more packages gives any substantial value, to be honest. |
I tried 2 ways to implement this pull request
Personally I prefer the first way, only one rule "if an api used by another package, this api must be public and must be defined in index.ts", and I think that's how angular does. This picture shows in angular's code base, |
Personally, everything is fine as soon as we fulfill 2 requirements: (1) don't expose everything to the user for better UX (2) don't break API of 3rd-party libs 🙂 |
Just merged #1176 which should solve 99% of issues |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
I rebased my original pull request in #954 and send this new pull request, changes includes:
sample
directory into workspace to use the latest nest library in samplehow to test this pr
git clone https://github.com/xcaptain/nest
cd nest
git checkout feature/workspace
yarn install
this will install all the dependencies inpackages
andsample
yarn bootstrap
to bootstrap lernayarn prepare
to re-generate lib in each packagesyarn test
to run all the tests or../../node_modules/mocha/bin/mocha --require ts-node/register test/**/*.spec.ts
in each packagesyarn pub
to publish the packages, this command will publish the source code and compiled codehow to run the sample
cd sample/01-cats-app/
yarn start
curl -i 'localhost:3000/cats/
what to do in the future
src
directory in each packages and compiled intolib
dirsample
dirDoes this PR introduce a breaking change?
Other information