Skip to content

Commit 721737e

Browse files
authored
Merge pull request #528 from objectstack-ai/copilot/fix-sourcemap-resolution-errors
2 parents f3e3a92 + 259067f commit 721737e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.storybook/main.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const config: StorybookConfig = {
1919
autodocs: "tag",
2020
},
2121
async viteFinal(config) {
22-
return mergeConfig(config, {
22+
const merged = mergeConfig(config, {
2323
define: {
2424
'process.env': {},
2525
'process.platform': '"browser"',
@@ -35,6 +35,9 @@ const config: StorybookConfig = {
3535
// Alias components package to source to avoid circular dependency during build
3636
'@object-ui/core': path.resolve(__dirname, '../packages/core/src/index.ts'),
3737
'@object-ui/react': path.resolve(__dirname, '../packages/react/src/index.ts'),
38+
'@object-ui/types': path.resolve(__dirname, '../packages/types/src/index.ts'),
39+
'@object-ui/i18n': path.resolve(__dirname, '../packages/i18n/src/index.ts'),
40+
'@object-ui/mobile': path.resolve(__dirname, '../packages/mobile/src/index.ts'),
3841
'@object-ui/components': path.resolve(__dirname, '../packages/components/src/index.ts'),
3942
'@object-ui/fields': path.resolve(__dirname, '../packages/fields/src/index.tsx'),
4043
'@object-ui/layout': path.resolve(__dirname, '../packages/layout/src/index.ts'),
@@ -81,6 +84,28 @@ const config: StorybookConfig = {
8184
target: 'esnext',
8285
},
8386
});
87+
88+
// Apply onwarn directly to avoid mergeConfig potentially dropping function callbacks
89+
merged.build ??= {};
90+
merged.build.rollupOptions ??= {};
91+
const existingOnwarn = merged.build.rollupOptions.onwarn;
92+
merged.build.rollupOptions.onwarn = (warning, warn) => {
93+
// Suppress "use client" directive warnings (from Radix UI, react-router, etc.)
94+
// and sourcemap resolution errors from dependencies with incomplete sourcemaps
95+
if (
96+
warning.code === 'MODULE_LEVEL_DIRECTIVE' ||
97+
warning.message?.includes("Can't resolve original location of error")
98+
) {
99+
return;
100+
}
101+
if (existingOnwarn) {
102+
existingOnwarn(warning, warn);
103+
} else {
104+
warn(warning);
105+
}
106+
};
107+
108+
return merged;
84109
},
85110
};
86111
export default config;

0 commit comments

Comments
 (0)