Support of `NormalModuleReplacementPlugin` in turbopack
Unanswered
Red-eyed Vireo posted this in #help-forum
Red-eyed VireoOP
Hi, we are trying to move to turbopack (still using pages dir), but we are having issues with some rewrites of modules that we do with the NormalModuleReplacementPlugin.
Bellow you have one of our usages of this plugin.
Is it possible to do it in Turbopack?
Example:
module.exports = function setupNodeEnvTargetedImports(
webpackConfig,
webpack,
environment
) {
webpackConfig.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/(.).NODE_ENV_TARGET(..)?$/,
function eltest(resource) {
const isProduction = environment === "production";
resource.request = resource.request.replace(
/NODE_ENV_TARGET/,
);
}
)
);
return webpackConfig;
};
Bellow you have one of our usages of this plugin.
Is it possible to do it in Turbopack?
Example:
module.exports = function setupNodeEnvTargetedImports(
webpackConfig,
webpack,
environment
) {
webpackConfig.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/(.).NODE_ENV_TARGET(..)?$/,
function eltest(resource) {
const isProduction = environment === "production";
resource.request = resource.request.replace(
/NODE_ENV_TARGET/,
${isProduction ? "production" : "development"});
}
)
);
return webpackConfig;
};