Skip to content

Commit dbb882e

Browse files
authored
fix(sandpack-id): generate new bundler id based on client version (#1202)
1 parent e3bd9e7 commit dbb882e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

sandpack-client/.bundler

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Manually generated file to trigger new releases based on the bundler changes.
22
// The following value is the commit hash from codesandbox-client
3-
b7d51d076df01577313c724ab54419ce41667d17
3+
f64b210d3832ce8558516bcda9bebd543400c9d9

sandpack-react/rollup.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const replace = require("@rollup/plugin-replace");
44
const typescript = require("@rollup/plugin-typescript");
55
const filesize = require("rollup-plugin-filesize");
66

7+
const sandpackClientPkg = require("../sandpack-client/package.json");
8+
79
const pkg = require("./package.json");
810
const generateUnstyledTypes = require("./scripts/rollup-generate-unstyled-types");
911
const removeCss = require("./scripts/rollup-remove-css-transformer");
@@ -28,6 +30,7 @@ const configBase = [
2830
values: {
2931
"process.env.TEST_ENV": "false",
3032
"process.env.SANDPACK_UNSTYLED_COMPONENTS": `"false"`,
33+
"process.env.SANDPACK_CLIENT_VERSION": `"${sandpackClientPkg.version}"`,
3134
},
3235
}),
3336
typescript({ tsconfig: "./tsconfig.json" }),

sandpack-react/src/utils/useAsyncSandpackId.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const useSandpackId = () => {
1919
*/
2020
const MAX_ID_LENGTH = 9;
2121

22+
const sandpackClientVersion = process.env.SANDPACK_CLIENT_VERSION;
23+
2224
export const useAsyncSandpackId = (files: SandpackBundlerFiles) => {
2325
if (typeof useReactId === "function") {
2426
/* eslint-disable-next-line react-hooks/rules-of-hooks */
@@ -27,7 +29,9 @@ export const useAsyncSandpackId = (files: SandpackBundlerFiles) => {
2729
const allCode = Object.entries(files)
2830
.map((path, code) => path + "|" + code)
2931
.join("|||");
30-
const sha = await generateShortId(allCode + reactDomId);
32+
const sha = await generateShortId(
33+
allCode + reactDomId + sandpackClientVersion
34+
);
3135

3236
return ensureLength(
3337
sha.replace(/:/g, "sp").replace(/[^a-zA-Z]/g, ""),

0 commit comments

Comments
 (0)