Skip to content

Commit 01fc086

Browse files
committed
Fix: fix the webpack build dev when extension is in node_module
1 parent ce92195 commit 01fc086

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

packages/evershop/src/lib/webpack/dev/createConfigClient.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { CONSTANTS } from '../../helpers.js';
66
import { createBaseConfig } from '../createBaseConfig.js';
77
import { GraphqlPlugin } from '../plugins/GraphqlPlugin.js';
88
import { ThemeWatcherPlugin } from '../plugins/ThemeWatcherPlugin.js';
9+
import { getEnabledExtensions } from '../../../bin/extension/index.js';
910

1011
export function createConfigClient(route, tailwindConfig) {
12+
const extensions = getEnabledExtensions();
1113
const config = createBaseConfig(false);
1214
config.name = route.id;
1315

@@ -121,10 +123,28 @@ export function createConfigClient(route, tailwindConfig) {
121123

122124
// Enable source maps
123125
config.devtool = 'eval-cheap-module-source-map';
126+
127+
// Configure snapshot management for better caching
128+
// Exclude @evershop/evershop core and extensions in node_modules from managed paths
129+
// This ensures webpack watches for changes in these paths
130+
const nodeModuleExtensions = extensions
131+
.filter((ext) => ext.path && ext.path.includes('node_modules'))
132+
.map((ext) => {
133+
// Extract package name from path (e.g., @vendor/package or package-name)
134+
const match = ext.path.match(
135+
/node_modules[\\/](@[^/\\]+[\\/][^/\\]+|[^/\\]+)/
136+
);
137+
return match ? match[1].replace(/\\/g, '[\\\\/]') : null;
138+
})
139+
.filter(Boolean)
140+
.join('|');
141+
142+
const managedPathsPattern = nodeModuleExtensions
143+
? `^(.+?[\\\\/]node_modules[\\\\/](?!(@evershop[\\\\/]evershop|${nodeModuleExtensions}))(@.+?[\\\\/])?.+?)[\\\\/]`
144+
: `^(.+?[\\\\/]node_modules[\\\\/](?!(@evershop[\\\\/]evershop))(@.+?[\\\\/])?.+?)[\\\\/]`;
145+
124146
config.snapshot = {
125-
managedPaths: [
126-
/^(.+?[\\/]node_modules[\\/](?!(@evershop[\\/]evershop))(@.+?[\\/])?.+?)[\\/]/
127-
]
147+
managedPaths: [new RegExp(managedPathsPattern)]
128148
};
129149

130150
return config;

0 commit comments

Comments
 (0)