message: chore: reworking the modulescope config
diff: @@ -139,14 +139,24 @@ export async function createConfig(
  new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
  ];
  - if (!isDev) {
  + // These files are required by the transpiled code when using React Refresh.
  + // They need to be excluded to the module scope plugin which ensures that files
  + // that exist in the package are required.
  + const reactRefreshFiles = [
  + require.resolve(
  + '@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js',
  + ),
  + require.resolve('@pmmmwh/react-refresh-webpack-plugin/overlay/index.js'),
  + require.resolve('react-refresh'),
  + ];
  +
  resolvePlugins.push(
  new ModuleScopePlugin(
  [paths.targetSrc, paths.targetDev],
  - [paths.targetPackageJson],
  + [paths.targetPackageJson, ...reactRefreshFiles],
  ),
  );
  - }
  +
  return {
  mode: isDev ? 'development' : 'production',
  profile: false,
  @@ -228,16 +238,11 @@ export async function createBackendConfig(
  const resolvePlugins: webpack.ResolvePluginInstance[] = [
  new LinkedPackageResolvePlugin(paths.rootNodeModules, externalPkgs),
  - ];
  -
  - if (!isDev) {
  - resolvePlugins.push(
  new ModuleScopePlugin(
  [paths.targetSrc, paths.targetDev],
  [paths.targetPackageJson],
  ),
  - );
  - }
  + ];
  return {
  mode: isDev ? 'development' : 'production',
  