Fix storybook

This commit is contained in:
Fedor Indutny
2025-09-18 11:56:10 -07:00
committed by GitHub
parent 93ae2a4c48
commit 753d34ee6b

View File

@@ -3,6 +3,13 @@
import type { StorybookConfig } from '@storybook/react-webpack5';
import { ProvidePlugin } from 'webpack';
import { builtinModules } from 'node:module';
const EXTERNALS = new Set(builtinModules);
// We have polyfills for these
EXTERNALS.delete('buffer');
EXTERNALS.delete('url');
const config: StorybookConfig = {
typescript: {
@@ -91,7 +98,10 @@ const config: StorybookConfig = {
config.node = { global: true };
config.externals = ({ request }, callback) => {
if (/^node:/.test(request) && request !== 'node:buffer') {
if (
(/^node:/.test(request) && request !== 'node:buffer') ||
EXTERNALS.has(request)
) {
// Keep Node.js imports unchanged
return callback(null, 'commonjs ' + request);
}