Skip to content

Commit a68eb30

Browse files
authored
fix(shared): Remove "sideEffects" and fix postbuild script (clerk#1974)
* fix(clerk-expo,shared): Bundle shared in expo * Revert "fix(clerk-expo,shared): Bundle shared in expo" This reverts commit c1e0279. * fix(shared): Add files key and fix script * chore(repo): Linting * fix(shared): Add package.json to exports
1 parent e5598cf commit a68eb30

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed

.changeset/fair-cameras-boil.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/shared': patch
3+
---
4+
5+
Remove `"sideEffects": "false"` since the package has side-effects

packages/shared/package.json

+22-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
"name": "@clerk/shared",
33
"version": "1.0.0",
44
"description": "Internal package utils used by the Clerk SDKs",
5-
"sideEffects": false,
65
"files": [
7-
"dist"
6+
"dist",
7+
"browser",
8+
"callWithRetry",
9+
"color",
10+
"cookie",
11+
"date",
12+
"deprecated",
13+
"error",
14+
"file",
15+
"globs",
16+
"handleValueOrFn",
17+
"isomorphicAtob",
18+
"keys",
19+
"loadScript",
20+
"localStorageBroadcastChannel",
21+
"poller",
22+
"proxy",
23+
"underscore",
24+
"url",
25+
"react"
826
],
927
"main": "./dist/index.js",
1028
"exports": {
@@ -37,7 +55,8 @@
3755
"types": "./dist/react/index.d.ts",
3856
"default": "./dist/react/index.js"
3957
}
40-
}
58+
},
59+
"./package.json": "./package.json"
4160
},
4261
"scripts": {
4362
"build": "tsup",

scripts/subpath-workaround.mjs

+12-13
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,28 @@ async function run() {
2525
`Found ${subpathHelperFile.subpathNames.length} subpaths and ${subpathHelperFile.subpathFoldersBarrel.length} subpath barrels`,
2626
);
2727

28-
// Check if pkgFile.files already contains the subpaths. This means that the script has already been run and we should exit early
29-
const subpathsAlreadyAdded = subpathHelperFile.subpathNames.some(name => pkgFile.files.includes(name));
28+
const allFilesNames = [...subpathHelperFile.subpathNames, ...subpathHelperFile.subpathFoldersBarrel, 'dist'];
29+
const hasAllSubpathsInFiles = pkgFile.files.every(name => allFilesNames.includes(name));
3030

31-
if (subpathsAlreadyAdded) {
32-
return console.log(`Subpaths already added to ${pkgName} package.json. Exiting early`);
31+
if (!hasAllSubpathsInFiles) {
32+
throw new Error('Not all subpaths from the package.json "files" array are in the subpaths.mjs');
3333
}
3434

35-
// Add all subpaths to the "files" property on package.json
36-
pkgFile.files = [...pkgFile.files, ...subpathHelperFile.subpathNames, ...subpathHelperFile.subpathFoldersBarrel];
37-
38-
writeJSON(`../packages/${pkgName}/package.json`, pkgFile);
39-
40-
console.log(`Overwrote package.json for ${pkgName} with subpaths`);
41-
4235
// Create directories for each subpath name using the pkgJsonPlaceholder
4336
subpathHelperFile.subpathNames.forEach(name => {
44-
fs.mkdirSync(new URL(`../packages/${pkgName}/${name}`, import.meta.url));
37+
const dir = new URL(`../packages/${pkgName}/${name}`, import.meta.url);
38+
if (!fs.existsSync(dir)) {
39+
fs.mkdirSync(dir);
40+
}
4541
writeJSON(`../packages/${pkgName}/${name}/package.json`, pkgJsonPlaceholder(name));
4642
});
4743

4844
// Create directories for each subpath barrel file using the pkgJsonBarrelPlaceholder
4945
subpathHelperFile.subpathFoldersBarrel.forEach(name => {
50-
fs.mkdirSync(new URL(`../packages/${pkgName}/${name}`, import.meta.url));
46+
const dir = new URL(`../packages/${pkgName}/${name}`, import.meta.url);
47+
if (!fs.existsSync(dir)) {
48+
fs.mkdirSync(dir);
49+
}
5150
writeJSON(`../packages/${pkgName}/${name}/package.json`, pkgJsonBarrelPlaceholder(name));
5251
});
5352

0 commit comments

Comments
 (0)