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(repo): QoL for subpaths script #4180

Merged
merged 3 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
2 changes: 2 additions & 0 deletions .changeset/moody-fans-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
50 changes: 9 additions & 41 deletions packages/localizations/subpaths.mjs
Original file line number Diff line number Diff line change
@@ -1,45 +1,13 @@
// This file is a helper for the "subpath-workaround.mjs" script
// We have to polyfill our "exports" subpaths :cry:
import packageJson from './package.json' with { type: 'json' };

export const subpathNames = [
'ar-SA',
'cs-CZ',
'da-DK',
'de-DE',
'el-GR',
'en-US',
'es-ES',
'fr-FR',
'fi-FI',
'he-IL',
'is-IS',
'it-IT',
'ja-JP',
'ko-KR',
'mn-MN',
'nb-NO',
'nl-NL',
'nl-BE',
'pl-PL',
'pt-BR',
'pt-PT',
'ro-RO',
'ru-RU',
'sk-SK',
'sv-SE',
'tr-TR',
'uk-UA',
'vi-VN',
'zh-CN',
'zh-TW',
'es-MX',
'bg-BG',
'th-TH',
'ca-ES',
'hu-HU',
'sr-RS',
'hr-HR',
];
/**
* This file is a helper for the "subpath-workaround.mjs" script.
* Add your new subpath to package.json#files.
*
* When you add an entry to the package.json "files" field, a subfolder will be automatically created with a package.json pointing to that file
*/

export const subpathNames = packageJson.files.filter(k => k !== 'dist');

Copy link
Member Author

Choose a reason for hiding this comment

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

Source of truth now:

"files": [
"dist",
"ar-SA",
"ca-ES",
"cs-CZ",
"da-DK",
"de-DE",
"el-GR",
"en-US",
"es-ES",
"fi-FI",
"fr-FR",
"he-IL",
"is-IS",
"it-IT",
"ja-JP",
"ko-KR",
"mn-MN",
"nb-NO",
"nl-NL",
"nl-BE",
"pl-PL",
"pt-BR",
"pt-PT",
"ro-RO",
"ru-RU",
"sk-SK",
"sv-SE",
"tr-TR",
"uk-UA",
"vi-VN",
"zh-CN",
"zh-TW",
"es-MX",
"bg-BG",
"th-TH",
"hu-HU",
"sr-RS",
"hr-HR"
],

export const subpathFoldersBarrel = [];

Expand Down
15 changes: 9 additions & 6 deletions packages/react/subpaths.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import packageJson from './package.json' assert { type: 'json' };
// This file is a helper for the "subpath-workaround.mjs" script
// We have to polyfill our "exports" subpaths :cry:
import packageJson from './package.json' with { type: 'json' };

export const subpathNames = Object.keys(packageJson.exports)
.filter(k => k.startsWith('./') && k !== './' && k !== './package.json')
.map(k => k.replace('./', ''));
/**
* This file is a helper for the "subpath-workaround.mjs" script.
* Add your new subpath to package.json#files.
*
* When you add an entry to the package.json "files" field, a subfolder will be automatically created with a package.json pointing to that file
*/

export const subpathNames = packageJson.files.filter(k => k !== 'dist');

Copy link
Member Author

@LekoArts LekoArts Sep 17, 2024

Choose a reason for hiding this comment

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

"files": [
"dist",
"internal",
"errors"
],

Previously it extracted the same from this:

"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./internal": {
"import": {
"types": "./dist/internal.d.mts",
"default": "./dist/internal.mjs"
},
"require": {
"types": "./dist/internal.d.ts",
"default": "./dist/internal.js"
}
},
"./errors": {
"import": {
"types": "./dist/errors.d.mts",
"default": "./dist/errors.mjs"
},
"require": {
"types": "./dist/errors.d.ts",
"default": "./dist/errors.js"
}
},
"./package.json": "./package.json"
},

export const subpathFoldersBarrel = [];

Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@
},
"main": "./dist/index.js",
"files": [
"authorization",
"dist",
"scripts",
"authorization",
"browser",
"callWithRetry",
"color",
Expand All @@ -71,7 +72,6 @@
"react",
"constants",
"apiUrlFromPublishableKey",
"scripts",
"telemetry",
"logger",
"webauthn",
Expand Down
43 changes: 9 additions & 34 deletions packages/shared/subpaths.mjs
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
// This file is a helper for the "subpath-workaround.mjs" script
// When adding an entry to "subpathNames" also add it to "files" in package.json
import packageJson from './package.json' with { type: 'json' };

export const subpathNames = [
'authorization',
'browser',
'callWithRetry',
'color',
'cookie',
'date',
'deprecated',
'deriveState',
'error',
'file',
'globs',
'handleValueOrFn',
'isomorphicAtob',
'isomorphicBtoa',
'keys',
'loadClerkJsScript',
'loadScript',
'localStorageBroadcastChannel',
'poller',
'proxy',
'underscore',
'url',
'versionSelector',
'constants',
'apiUrlFromPublishableKey',
'telemetry',
'logger',
'webauthn',
'router',
'pathToRegexp',
];
/**
* This file is a helper for the "subpath-workaround.mjs" script.
* Add your new subpath to package.json#files.
*
* When you add an entry to the package.json "files" field, a subfolder will be automatically created with a package.json pointing to that file
*/

export const subpathNames = packageJson.files.filter(k => !['dist', 'scripts', 'react'].includes(k));

Copy link
Member Author

Choose a reason for hiding this comment

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

scripts should be left alone, react is a barrel file so handled below

export const subpathFoldersBarrel = ['react'];

Expand Down
Loading