-
Notifications
You must be signed in to change notification settings - Fork 357
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
M3-5873: Build api-v4
and validation
with tsup
with backwards compatibility
#8484
Conversation
tsup\
for api-v4
and validation
with backwards compatibilitytsup
for api-v4
and validation
with backwards compatibility
"@linode/api-v4/lib(.*)$": "<rootDir>/../api-v4/src/$1", | ||
"@linode/validation/lib(.*)$": "<rootDir>/../validation/src/$1" |
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 should be able to be removed after we update Jest. Newer versions of Jest support the exports
values in the package.json
, and hopefully Jest will pull the required commonjs
files
Edit: I tested it and confirmed that a jest upgrade allows us to remove these. We can do that down the road
tsup
for api-v4
and validation
with backwards compatibilityapi-v4
and validation
with tsup
with backwards compatibility
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 gonna finish reviewing this later, but so far I'm liking everything I see! Nice work!
@@ -2,14 +2,14 @@ import { | |||
createDatabaseSchema, | |||
updateDatabaseSchema, | |||
} from '@linode/validation/lib/databases.schema'; | |||
import { BETA_API_ROOT as API_ROOT } from 'src/constants'; | |||
import { BETA_API_ROOT as API_ROOT } from '../constants'; |
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.
No problem here, but curious why there's a need to change to relative paths -- does tsup have issues with TypeScript's path aliases? If so, is the path
property in tsconfig.json
still necessary?
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.
tsup handled it fine, it actually was a problem with the temporary jest change above
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.
Ah that makes sense. Thanks!
packages/api-v4/package.json
Outdated
"build:node": "yarn build --config webpack.node.config.js", | ||
"start": "concurrently --raw \"tsc -w --preserveWatchOutput\" \"tsup --watch\"", | ||
"build": "concurrently --raw \"tsc\" \"tsup\"", | ||
"build:node": "echo not needed", |
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.
The only other reference I can find to build:node
is in .github/workflows/ci.yml
. I'll do some more searching later, but maybe we can get rid of this script altogether?
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 was worried our internal pipeline used it, but it appears like it does not. I'll remove it.
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.
Really, really nice! Great work @bnussman
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.
Going to finish testing this in-depth first thing tomorrow but for now I've confirmed that the app compiles and Cloud appears to be functioning well
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.
Great job! Resurfaced a question and once this gets released, some updates will need to be made to https://www.npmjs.com/package/@linode/api-v4 and maybe https://www.npmjs.com/package/@linode/validation to keep them accurate.
"@linode/api-v4": "^0.75.0", | ||
"@linode/validation": "0.12.0", | ||
"@linode/api-v4": "*", | ||
"@linode/validation": "*", |
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.
Going to resurface this question #8447 (comment). Were you able to find any documentation? Is yarn going to pull the correct versions as specified in the corresponding package.json
files?
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 did a bit of looking and didn't find anything super great, but here is the docs on how versioning with the *
works.
https://classic.yarnpkg.com/lang/en/docs/dependency-versions/#toc-x-ranges
I found some looking around and people say that yarn will resolve the *
to the latest version of a dependency and will check a monorepo's workspaces first
https://blog.charlesloubao.com/one-line-javascript-tip-1-how-to-install-a-local/
✨ Description
tsup
for building@linode/api-v4
and@linode/validation
📝 Details
yarn up
in favor ofyarn dev
@linode/validation
so it rebuilds automatically when you are usingyarn dev
/yarn up
src/
prefixed imports in@linode/api-v4
and@linode/validation
to be relative path imports (../
)jest
to use@linode/api-v4
and@linode/validation
'ssrc
instead oflib
.tsc
incremental
tsc compilation for@linode/api-v4
and@linode/validation
for faster typecheckingesm
,commonjs
, andiife
as 3 bundled formatsindex.js
s for each format (excluding type files)esm
commonjs
iife
format so it is suitable for web use🧪 How to test
@linode/api-v4
, and@linode/validation
yarn
from root dir to update dependenciesrm -rf packages/api-v4/lib && rm -rf packages/validation/lib && rm packages/api-v4/index.js && rm packages/api-v4/index.d.ts && rm packages/validation/index.js && rm packages/validation/index.d.ts
to clear old builds ofapi-v4
andvalidation
yarn up