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

fix(shared): Add missing entries to "files" array in package.json #4172

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaggy-lobsters-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/shared": patch
---

Set correct "files" property in package.json
5 changes: 4 additions & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"main": "./dist/index.js",
"files": [
"authorization",
"dist",
"browser",
"callWithRetry",
Expand Down Expand Up @@ -73,7 +74,9 @@
"scripts",
"telemetry",
"logger",
"webauthn"
"webauthn",
"router",
"pathToRegexp"
],
"scripts": {
"build": "tsup",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/subpaths.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file is a helper for the "subpath-workaround.mjs" script
// We have to polyfill our "exports" subpaths :cry:
// When adding an entry to "subpathNames" also add it to "files" in package.json

export const subpathNames = [
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just replace this with package.files ? In order to use package.json as the source of truth ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The files array contains directories (like dist, scripts, react) that need special handling and/or shouldn't get subdirectories created. So one way or another you'd need to add special handling. I can adjust the logic in another PR probably so that files array is the source of truth

'authorization',
Expand Down
5 changes: 5 additions & 0 deletions scripts/subpath-workaround.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ async function run() {
...subpathHelperFile.ignoredFolders,
'dist',
];

if (pkgFile.files.length !== allFilesNames.length) {
throw new Error('The package.json "files" array length does not match the subpaths.mjs');
}

Comment on lines +33 to +37
Copy link
Member

Choose a reason for hiding this comment

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

❓ is this almost the same error as the one that exists right below?

Copy link
Member Author

Choose a reason for hiding this comment

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

The .every error won't fire if the length is not the same, so early return here and make the error clearer

Copy link
Member

Choose a reason for hiding this comment

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

We could merge these 2 checks and throw a single error if any of these checks fail.

const hasAllSubpathsInFiles = pkgFile.files.every(name => allFilesNames.includes(name));

if (!hasAllSubpathsInFiles) {
Expand Down
Loading