-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
build(testlab): move test files to src/__tests__
#2283
Conversation
"should-as-function.d.ts", | ||
"src" | ||
"src", | ||
"!*/__tests__" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This excludes both src/__tests__
and dist/__tests__
from the npm package tarball.
src/__tests__
src/__tests__
[WIP - DO NOT MERGE]
I just realized that I forgot to check that developer experience in VS Code is preserved with these changes in place, per https://github.com/strongloop/loopback-next/blob/master/docs/site/DEVELOPING.md#how-to-test-infrastructure-changes This PR should not be landed until I verify those aspects. |
As kind of expected, "Go to definition" in VSCode is jumping to |
This can be easily fixed by adding Unfortunately, that does not solve the second important feature: refactorings, e.g. "rename symbol". |
To make refactorings work, I had to bring package-level index files back. I hope we will be able to remove them when we switch to project references and abandon the current approach where we pretend for VSCode that the entire monorepo is a single typescript project. Original commit: c14e4ea |
ee10452
to
e68d6bf
Compare
src/__tests__
[WIP - DO NOT MERGE]src/__tests__
@raymondfeng the patch is ready for final review and landing, PTAL. |
e68d6bf
to
c1b1315
Compare
@bajtos The following settings in "main": "./dist/index.js",
"types": "./src/index.ts", Can you verify? |
What's going to happen for
|
Nice hack! It works for me well 👍 I am concerned about the ramifications of such change for our consumers though, I posted a question on StackOverflow to get a qualified answer (hopefully ): https://stackoverflow.com/questions/54399058/ramifications-of-exporting-original-ts-files-instead-of-d-ts-files-as-module-t. Feel free to post an answer yourself. Considering that switching from hand-written I think that once we switch to project references, we may not need this hack anymore 🤞 , so it may be better to not bother at all and remove Thoughts?
The directory The directory What do you think, how can we make this distinction easier to understand for people contributing to LoopBack (including ourselves)? Few alternatives that come to my mind:
|
Before this PR, we have root level Please also note that |
For two types of |
c1b1315
to
232cde1
Compare
Done in 232cde1.
Here is my understanding of how thing works currently: When working in our monorepo:
When consuming
Anyhow, as I commented before, I would like to set this discussion aside for now and land only the changes moving test files from @raymondfeng Does the pull request LGTY now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as moving test files to src/__tests__
and the rationale behind it, LGTM.
232cde1
to
65f247f
Compare
This change greatly simplifies our build and project setup. - Source files are compiled from `src/{foo}` to `dist/{foo}`, the same pattern is applied to test files too. - Both TypeScript sources and JavaScript output are stored in the same path relative to project root. This makes it much easier to refer to test fixtures. This change is also enabling future improvements, for example TypeScript project references and migration to jest test runner.
65f247f
to
ac24e03
Compare
I'd like to resume work on migrating our monorepo to TypeScript Project References, as investigated in #1636. As I see it, the next step is to simplify our project setup by moving our test files from
test
tosrc/__test__
.Source files are compiled from
src/{foo}
todist/{foo}
, the same pattern is applied to test files too.Both TypeScript sources and JavaScript output are stored in the same path relative to project root. This makes it much easier to refer to test fixtures.
There is no need for hacky manually-mainitained index files in package root. We can directly use TypeScript output:dist/index.js
as the main package file,dist/index.d.ts
as the type definitions.This change is also enabling future improvements, for example TypeScript project references and migration to jest test runner.
IMPORTANT NOTE
I am intentionally migrating only one of our packages in this pull request. By limiting the changes to a single package, the pull request is smaller and easier to review in detail. Once we agree on the best way how to make these changes, I'll open follow-up pull requests to migrate other monorepo packages accordingly.
Checklist
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated