-
Notifications
You must be signed in to change notification settings - Fork 282
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: update workflow to support ts #1119
Conversation
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.
LGTM
This is a great first step. Thank you for the contribution. 👍 Some comments: Code formatting can be taken up as a last step once we have all the other ts files migration. I still need to do the test/validate (changes if any) with https://github.com/minio/mint/tree/master/run/core/minio-js |
@trim21 Please resolve the conflicts. |
Another observation is : while running tests locally, the tests are not progressing after some point
Steps to replicate:
|
can we add Code formatting (#1120) first?would be easier for contributors to unify code formatting and pr diff could look better, easy for you to review following prs, too lint-staged is setup so you won't need to format code manually |
I'll take a look at mint later
I add a |
I find these tests become unexpected slow, I'll look into it
update: I try master branch and tests freezed, too. It may not be the problme of this PR?
you can see the log of ci trigged by PR #1124
|
@trim21 the master the tests are running fine.
|
should have been fixed I think
|
I wanted to suggest the usage of minio:cicd-edge docker image as a service on the CI, rather than running the minio server as a background process. But the cicd-edge tag is far outdated and there's not much maintainers that wants to use it. |
I think this is not very related to this PR and can be a seprated issue ? |
> I wanted to suggest the usage of minio:cicd-edge docker image as a service on the CI, rather than running the minio server as a background process.
>
> But the cicd-edge tag is far outdated and there's not much maintainers that wants to use it.
I think this is not very related to this PR and can be a seprated issue ?
Yeah, but it's something that I'd suggest on the Typescript rewrite journey. I'll turn my issue on Typescript into a checklist later on.
…On Wed, Apr 12, 2023 at 21:53, Trim21 ***@***.***> wrote:
> I wanted to suggest the usage of minio:cicd-edge docker image as a service on the CI, rather than running the minio server as a background process.
>
> But the cicd-edge tag is far outdated and there's not much maintainers that wants to use it.
I think this is not very related to this PR and can be a seprated issue ?
—
Reply to this email directly, [view it on GitHub](#1119 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABXP6VUELSG6O2ZKPT4GYETXA26WDANCNFSM6AAAAAAWYETGJU).
You are receiving this because you commented.Message ID: ***@***.***>
|
It can be parallel to the rewrite... |
I almost finish migrating, just wait style pr and this pr to be merged, then I can start to submit them |
This PR is ready for review now |
I'm not sure how the release bot will build this project, So I add |
mint support pull request created minio/mint#356 |
Thank you @trim21 . i was working in parallel on this. Sorry for not notifying you earlier. |
Accidentally closed this. |
That's scaring, I thought you are working on this and decide to discard this PR. 😰 |
This PR doesn't migrate source to TS except
errors.ts
as example ( or tester ), full migration and refacting can be done in seprated PRs.It migrate source files to ESM and update tool config to support typescript.
close #834 #835
Code Style ( excluding already described in #1120 )
Add a set of eslint rules to force import style to make it work with build script.
import
should be fully specified to import source files, developers of this project should writeimport {} from './errors.ts'
forerrors.ts
,import {} from './helpers.js'
forhelpers.js
, file extension must be included, this is essential for testing and buildingfunction comment:
should always write jsdoc/tsdoc, tsc will only emit jsdoc/tsdoc in type definition. function/method comment
// ...
won't work.Building
to not break existing
require('minio/dist/main/...')
, we still need to do a file to file transpiling.There is no existing bundler can do this ( and tsc doesn't fit this case ), so a script
build.mjs
is added to use babel to transform codes.src/
directory will be inclued in npm package but user should not be able to import then. editor (at lease vscode and WebStorm) will be able to jump to implementation (raw ts files insrc/
dir) with tsconfig"declarationMap": true
Type definition are also imported from
@types/minio
, need some extra work to keep it up to date.ESM
Also build esm mjs files to
./dist/esm/
Use babel to transpile type definition from
.d.ts
to.d.mts
, so importing esm files will also be typed.Add named export for all default export, and suggest stop make any new default export (keep existing backward compatible and remove them in next major version), use named exports only, like what we did in the package entrypoint. This is more clear to support both cjs and esm.
current building already transform esm default export to cjs default property, so no behavoir change here:
now users can write code in a better way:
Testing
still use mocha, no test cases are changed, but add
@babel/register
to load esm and ts files, so no need to compile before testing..env
file is totally optionalmint
mint support minio/mint#356
About
error.ts
Error.captureStackTrace
should be used when you create a plain object{}
asError
and want to add stack, not to be used when you extending built-inError
.There is no need to call
Error.captureStackTrace
in the constructor of Error or sub-class of Erro, only need to seterror.name
.Also it doesn't support es2022 standard
error.cause
(available in node16+, and doesn't broken lower version), there is no need to use it anymore.