hard-source-webpack-plugin icon indicating copy to clipboard operation
hard-source-webpack-plugin copied to clipboard

About mini-css-extract-plugin compatible

Open Beven91 opened this issue 6 years ago • 1 comments

Expected Behavior

The mini-css-extract-plugin should be cached well when webpack is hot built。

Actual Behavior

Cause Error Could not freeze xxx/xx.scss Cannot read property 'hash' of undefined

Maybe Question

The event _hardSourceFreezeModule is not compatible when webpack is hot built scss( use mini-css-extract-plugin)。

With code:

 if (module.request &&
          (cacheable(module) || !module.built) &&
          module instanceof NormalModule &&
          (!frozen ||
            (schema >= 4 && module.hash !== frozen.build.hash) ||
            (schema < 4 &&
              module.getHashDigest(extra.compilation.dependencyTemplates) !==
                frozen.hash))
)

And segment:

module.hash !== frozen.build.hash

Scenes

The scss module hash was changed ,but the module maybe not be built (module.built===false)。

let serialModule = serialNormalModule;
if (!module.built) {
  serialModule = serialNormalModule4PreBuild;
}

And only try this code

let serialModule = serialNormalModule;
if (!module.built) {
  if (module.hash) {
    return null;
  }
  serialModule = serialNormalModule4PreBuild;
}

It's could work。

But this maybe not a foundmental problem, just a possibility。

Beven91 avatar Jan 14 '19 10:01 Beven91

👍 happens to me as well screen shot 2019-02-25 at 18 26 23

sk91 avatar Feb 25 '19 18:02 sk91