-
Notifications
You must be signed in to change notification settings - Fork 23
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
#9430: tsconfig references refactor #9522
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9522 +/- ##
==========================================
+ Coverage 74.24% 75.79% +1.54%
==========================================
Files 1332 1422 +90
Lines 40817 42917 +2100
Branches 7634 7902 +268
==========================================
+ Hits 30306 32529 +2223
+ Misses 10511 10388 -123 ☔ View full report in Codecov by Sentry. |
Playwright test resultsDetails Open report ↗︎ Flaky testsmsedge › tests/runtime/localIntegrations.spec.ts › Local Integrations Page › #8067: blank numeric text integration configuration field validated on save Skipped testschrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options |
@@ -15,7 +15,7 @@ | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
import { getInvalidPath } from "@/debugUtils"; | |||
import { getInvalidPath } from "./debugUtils"; |
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.
What's the import convention from inside the browser-extension workspace? Or do we have to wait for @nx/js
to set that up?
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 is imported in the browser-extension like so:
import { getInvalidPath } from "@pixiebrix/utils/src/debugUtils";
I removed this following the suggested tsconfigs from nx, but I think we could add back the following in the libraries/utils tsconfig if we wanted:
"compilerOptions": {
"paths": {
"@/*": ["src/*"]
I don't feel too strongly either way about this.
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.
I'm not a big fan of the src
directory appearing in the import, but it wouldn't be deal breaker. @pixiebrix/utils/debugUtils
would seem the cleanest to me (like you're importing a normal package)
I'm generally not a fan of relative imports (for reasons, e.g., listed on the lint rule https://www.npmjs.com/package/eslint-plugin-no-relative-import-paths), but with the same directory a potential exception
Where in the slicing are we introducing an actual cross-workspace import to the build?
Update: I see that the example import is here:
pixiebrix-extension/applications/browser-extension/src/pageEditor/store/editor/editorSlice.ts
Line 771 in 0c76026
invalidPath: getInvalidPath( |
See comment on top-level npm run watch
: #9522 (comment)
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.
I'm not a big fan of the src directory appearing in the import, but it wouldn't be deal breaker. @pixiebrix/utils/debugUtils would seem the cleanest to me (like you're importing a normal package)
This should be simple enough to update with an exported index file as a follow-up
@fungairino I'm getting an error on top-level
SO chatter here: https://stackoverflow.com/questions/55115705/typescript-project-with-references IntelliJ can resolve the usage. But typescript not happy about the type: |
See discussion in slack https://pixiebrix.slack.com/archives/C080KB9R76G/p1731595386835629 Devs will need to have a running tsc watch process to see updates from underlying libraries in apps if they are making changes across projects concurrently. I'll make sure to communicate this out. I pushed up a change to update the root level |
No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack. Do not edit this comment manually. |
"libraries/*": { | ||
entry: "src/*.ts!", | ||
project: "**/*.ts", | ||
}, |
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.
Should we really be making every file in the src folder an entry? What if a utility function exports a helper function for testing but shouldn't be used outside the library?
"libraries/*": { | |
entry: "src/*.ts!", | |
project: "**/*.ts", | |
}, | |
"libraries/*": { | |
// Files with a `!` suffix are included in production mode and default run | |
entry: "src/index.ts!", | |
project: ["src/**/*.ts!", "!src/**/*.d.ts!"], | |
}, |
This way we force engineers to define in the index.ts exactly what functions are available outside the library
Second, NX recommends we call the library either util
or util-*
: https://nx.dev/concepts/decisions/project-dependency-rules#utility-libraries
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.
I tested the original code by creating a testFn.ts that exported a simple function and a testFn.test.ts that imported it. It's used nowhere else. The current config doesn't catch it when running production mode. The suggested config does.
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.
Wait, I checked whether the @internal disable would work, looks like it doesn't
Works with a more realistic test scenario (function exported from debugUtils but not index.ts instead)
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.
I totally agree with this suggestion, I will make this change in a follow-up since this aligns with the same feedback that Todd left further up on avoiding importing from the src directory.
What does this PR do?
Discussion
Demo
tsc --build --watch
recompiles only the utils directory when changes are made to it, and leaves the whole extension project untouchedFuture Work
Checklist
For more information on our expectations for the PR process, see the
code review principles doc