Skip to content
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/fair-cameras-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/shared': patch
---

Remove `"sideEffects": "false"` since the package has side-effects
25 changes: 22 additions & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,27 @@
"name": "@clerk/shared",
"version": "1.0.1",
"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": {
Expand Down Expand Up @@ -37,7 +55,8 @@
"types": "./dist/react/index.d.ts",
"default": "./dist/react/index.js"
}
}
},
"./package.json": "./package.json"
},
"scripts": {
"build": "tsup",
Expand Down
25 changes: 12 additions & 13 deletions scripts/subpath-workaround.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});

Expand Down