Skip to content

Commit 771fd19

Browse files
Copilothotlong
andcommitted
fix: add crypto external for Vite builds to support @objectstack/core@2.0.4
@objectstack/core@2.0.4 statically imports Node.js crypto module for plugin hashing. The code has a browser fallback, so we mark crypto as external in both the console and msw-todo Vite configs to fix browser bundle builds. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 1a9bea1 commit 771fd19

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

apps/console/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ export default defineConfig({
7373
transformMixedEsModules: true
7474
},
7575
rollupOptions: {
76+
// @objectstack/core@2.0.4 statically imports Node.js crypto (for plugin hashing).
77+
// The code already has a browser fallback, so we treat it as external in the browser build.
78+
external: ['crypto'],
79+
output: {
80+
globals: {
81+
crypto: '{}',
82+
},
83+
},
7684
onwarn(warning, warn) {
7785
if (
7886
warning.code === 'UNRESOLVED_IMPORT' &&

examples/msw-todo/vite.config.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ export default defineConfig({
3535
return;
3636
}
3737
warn(warning);
38-
}
38+
},
39+
// @objectstack/core@2.0.4 statically imports Node.js crypto (for plugin hashing).
40+
// The code already has a browser fallback, so we treat it as external in the browser build.
41+
external: ['crypto'],
42+
output: {
43+
globals: {
44+
crypto: '{}',
45+
},
46+
},
3947
}
4048
}
4149
});

0 commit comments

Comments
 (0)