diff --git a/.changeset/fair-cameras-boil.md b/.changeset/fair-cameras-boil.md new file mode 100644 index 00000000000..23fa2a1286d --- /dev/null +++ b/.changeset/fair-cameras-boil.md @@ -0,0 +1,5 @@ +--- +'@clerk/shared': patch +--- + +Remove `"sideEffects": "false"` since the package has side-effects \ No newline at end of file diff --git a/packages/shared/package.json b/packages/shared/package.json index ce76bcf815f..317bb725315 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -2,9 +2,27 @@ "name": "@clerk/shared", "version": "1.0.0", "description": "Internal package utils used by the Clerk SDKs", - "sideEffects": false, "files": [ - "dist" + "dist", + "browser", + "callWithRetry", + "color", + "cookie", + "date", + "deprecated", + "error", + "file", + "globs", + "handleValueOrFn", + "isomorphicAtob", + "keys", + "loadScript", + "localStorageBroadcastChannel", + "poller", + "proxy", + "underscore", + "url", + "react" ], "main": "./dist/index.js", "exports": { @@ -37,7 +55,8 @@ "types": "./dist/react/index.d.ts", "default": "./dist/react/index.js" } - } + }, + "./package.json": "./package.json" }, "scripts": { "build": "tsup", diff --git a/scripts/subpath-workaround.mjs b/scripts/subpath-workaround.mjs index 8c3c507256a..790e2805ca3 100644 --- a/scripts/subpath-workaround.mjs +++ b/scripts/subpath-workaround.mjs @@ -25,29 +25,28 @@ async function run() { `Found ${subpathHelperFile.subpathNames.length} subpaths and ${subpathHelperFile.subpathFoldersBarrel.length} subpath barrels`, ); - // Check if pkgFile.files already contains the subpaths. This means that the script has already been run and we should exit early - const subpathsAlreadyAdded = subpathHelperFile.subpathNames.some(name => pkgFile.files.includes(name)); + const allFilesNames = [...subpathHelperFile.subpathNames, ...subpathHelperFile.subpathFoldersBarrel, 'dist']; + const hasAllSubpathsInFiles = pkgFile.files.every(name => allFilesNames.includes(name)); - if (subpathsAlreadyAdded) { - return console.log(`Subpaths already added to ${pkgName} package.json. Exiting early`); + if (!hasAllSubpathsInFiles) { + throw new Error('Not all subpaths from the package.json "files" array are in the subpaths.mjs'); } - // Add all subpaths to the "files" property on package.json - pkgFile.files = [...pkgFile.files, ...subpathHelperFile.subpathNames, ...subpathHelperFile.subpathFoldersBarrel]; - - writeJSON(`../packages/${pkgName}/package.json`, pkgFile); - - console.log(`Overwrote package.json for ${pkgName} with subpaths`); - // Create directories for each subpath name using the pkgJsonPlaceholder subpathHelperFile.subpathNames.forEach(name => { - fs.mkdirSync(new URL(`../packages/${pkgName}/${name}`, import.meta.url)); + const dir = new URL(`../packages/${pkgName}/${name}`, import.meta.url); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } writeJSON(`../packages/${pkgName}/${name}/package.json`, pkgJsonPlaceholder(name)); }); // Create directories for each subpath barrel file using the pkgJsonBarrelPlaceholder subpathHelperFile.subpathFoldersBarrel.forEach(name => { - fs.mkdirSync(new URL(`../packages/${pkgName}/${name}`, import.meta.url)); + const dir = new URL(`../packages/${pkgName}/${name}`, import.meta.url); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } writeJSON(`../packages/${pkgName}/${name}/package.json`, pkgJsonBarrelPlaceholder(name)); });