-
Notifications
You must be signed in to change notification settings - Fork 31
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
Move typescript package into subdirectory #170
Conversation
a39ccf9
to
72715cb
Compare
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 don't understand why there's both schemas/typescript
and typescript/schemas
typescript/schemas/package.json
Outdated
"url": "git+https://github.com/foxglove/foxglove-sdk.git", | ||
"directory": "typescript/schemas" | ||
}, | ||
"main": "./dist/typescript/schemas/src/index.js", |
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 confused as to why this path includes typescript/schemas
, why isn't it just e.g. dist/index.js
or dist/typescript/index.js
? And do we have a typescript/schemas/typescript
folder? That seems weird
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.
Also answering your other question at the same time:
I don't understand why there's both
schemas/typescript
andtypescript/schemas
typescript/schemas
is the typescript@foxglove/schemas
package. I thought about nesting putting it intypescript/@foxglove/schemas
but that seemed overkill unless we plan to have some non-foxglove-namespaced packages in this reposchemas/typescript
are the generated type definitions for our schemas
Now one option would be to move the generated typescript types into typescript/schemas/src/types
, that would almost lead to the schemas package being self contained. It might be a bit weird that not all the generated schemas would live under top level schemas
package, but that's not as much of a concern since anyone using typescript would be much more likely to import the package rather than copy/pasting files from the repo.
The wrinkle is that we also currently bundle the jsonschemas into the typescript package, and nesting them only under the typescript package seems less of a clear win, since people using other languages might want to easily find and copy/paste them (like they do with proto/flatbuffer/etc). Side note: I looked in our app and we only use the jsonschemas in a single test, so maybe we could stop bundling them into @foxglove/schemas
?
This brings me to your question why the package.json
main path is dist/typescript/schemas/src/index.js
not just dist/index.js
. It's because we import stuff from above the package, so typescript infers our baseUrl
as the repo root, meaning the dist
output is super nested. We could solve that by putting all the typescript + jsonschemas under typescript/schemas/src
so that src
compiles cleanly to dist
, but as mentioned above that is a bit weird especially for jsonschema.
Another route I could take is a prepack
script in this package which copies the files into the package at build time, and we gitignore the duplicates. That seems like probably the best option which allows us to clean up the dist
dir.
Thoughts?
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 tried the latter approach and quite like it. I pushed it to this branch, the main changes are in c72299d.
Did you test your new package in the app repo to ensure that all the package.json entrypoints resolve as expected? You should be able to |
3872568
to
1e8ba39
Compare
1e8ba39
to
c72299d
Compare
f126138
to
d4b60ae
Compare
6b1eb43
to
355c693
Compare
355c693
to
c45c779
Compare
@defunctzombie confirmed the current version of this PR is compatible with app (#8633) |
@@ -3,19 +3,26 @@ import fs from "fs/promises"; | |||
import path from "path"; |
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.
If you wanted you could put the scripts into a packages
folder and also have them part of the yarn workspace. Could even expose them with bin
fields in package.json
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.
ok will have a look at that in another PR, this one is big enough
Changelog
None
Docs
None
Description
Migrate
@foxglove/schemas
typescript package intotypescript
directory. This prepares for other typescript packages to live in this repo.Also restrict to only necessary files included in the npm package. Currently lots of stuff unintentionally included:
New package contents: