Skip to content
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

chore(build): validate if exporting is correct in package.json and jsr.json #3638

Merged
merged 8 commits into from
Nov 7, 2024

Conversation

EdamAme-x
Copy link
Contributor

Related: #3636

If there is a difference between the two exports, the build will fail.

@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Nov 6, 2024

It fails as follows.
image
https://github.com/honojs/hono/actions/runs/11704963747/job/32598601119?pr=3638

The test succeeds when this PR is merged.
#3636

@EdamAme-x EdamAme-x marked this pull request as draft November 7, 2024 03:02
@EdamAme-x EdamAme-x marked this pull request as ready for review November 7, 2024 03:37
@EdamAme-x
Copy link
Contributor Author

Fixed some missing exports

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.67%. Comparing base (4598d7a) to head (efa95f0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
build/validate-exports.ts 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3638      +/-   ##
==========================================
+ Coverage   90.52%   91.67%   +1.15%     
==========================================
  Files         159      159              
  Lines       10179    10132      -47     
  Branches     2827     2864      +37     
==========================================
+ Hits         9215     9289      +74     
+ Misses        962      841     -121     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Nov 7, 2024

@yusukebe
Could you review this?

@yusukebe
Copy link
Member

yusukebe commented Nov 7, 2024

Hi @EdamAme-x !

This PR means you added a function to validate the configuration of exporting modules in package.json and jsr.json with validateExports, right?

@EdamAme-x
Copy link
Contributor Author

That is what I mean.
If an endpoint is missing that should be exported to either, throw an error.

@yusukebe
Copy link
Member

yusukebe commented Nov 7, 2024

@EdamAme-x

Thanks! Seems to be good. But adding a test for validateExports like remove-private-fields.test.ts is better.

@EdamAme-x
Copy link
Contributor Author

thanks, okay.

@EdamAme-x
Copy link
Contributor Author

@yusukebe
ready for review

@EdamAme-x
Copy link
Contributor Author

@yusukebe
Re-ready for review

@yusukebe yusukebe changed the title feat(build): for both exports to be the same chore(build): validate if exporting is correct in package.json and jsr.json Nov 7, 2024
@yusukebe
Copy link
Member

yusukebe commented Nov 7, 2024

Hi @nakasyou Can you review this?

@nakasyou
Copy link
Contributor

nakasyou commented Nov 7, 2024

It looks good to me. An idea, what do you think about generating exports in package.json from jsr.json?


const args = arg({
'--watch': Boolean,
})

const isWatch = args['--watch'] || false

const readJsonExports = (path: string) => JSON.parse(fs.readFileSync(path, 'utf-8')).exports

const [packageJsonExports, jsrJsonExports] = ['./package.json', './jsr.json'].map(readJsonExports)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it also should validate typesVersions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, will work on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nakasyou Ah, you are right. But perhaps validating typeVersions is another issue? We can check whether it's correct without jsr.json.

@EdamAme-x What do you think of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to write the code, but you are right, it may be another problem.  
I will consider this after this PR is merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Let's merge this first.

@EdamAme-x
Copy link
Contributor Author

EdamAme-x commented Nov 7, 2024

It looks good to me.

Thanks.

An idea, what do you think about generating exports in package.json from jsr.json?

I think there is room for consideration, let's create a new issue and discuss it there.

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

yusukebe commented Nov 7, 2024

@EdamAme-x @nakasyou

Thanks! Let's go with this.

@yusukebe yusukebe merged commit a6ccfa2 into honojs:main Nov 7, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants