mzgoddard / hard-source-webpack-plugin

https://www.npmjs.com/package/hard-source-webpack-plugin
ISC License
2.7k stars 160 forks source link

Error when using with webpack 5 #514

Open daveisfera opened 4 years ago

daveisfera commented 4 years ago

Expected Behavior

Can be used with webpack 5 (currently being beta tested)

Actual Behavior

Errors out

Is an error being thrown?

Webpack Bundle Error :::: TypeError: Cannot read property 'tap' of undefined
    at Object.exports.tap (/Users/dlj/projects/my_test/web/node_modules/hard-source-webpack-plugin/lib/util/plugin-compat.js:118:25)
    at new CacheSerializerFactory (/Users/dlj/projects/my_test/web/node_modules/hard-source-webpack-plugin/lib/CacheSerializerFactory.js:94:18)
    at HardSourceWebpackPlugin.apply (/Users/dlj/projects/my_test/web/node_modules/hard-source-webpack-plugin/index.js:219:36)
    at createCompiler (/Users/dlj/projects/my_test/web/node_modules/webpack/lib/webpack.js:62:12)
    at webpack (/Users/dlj/projects/my_test/web/node_modules/webpack/lib/webpack.js:88:14)
    at /Users/dlj/projects/my_test/web/build.js:309:9
    at new Promise (<anonymous>)
    at processConfig (/Users/dlj/projects/my_test/web/build.js:307:12)
    at /Users/dlj/projects/my_test/web/build.js:357:20
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at process.runNextTicks [as _tickCallback] (internal/process/task_queues.js:62:3)
    at /Users/dlj/projects/my_test/node_modules/esm/esm.js:1:33214
    at module.exports.Q.inited.Q.module.utilSilent (/Users/dlj/projects/my_test/node_modules/esm/esm.js:1:32886)
    at process.<anonymous> (/Users/dlj/projects/my_test/node_modules/esm/esm.js:1:33184)
    at Function.<anonymous> (/Users/dlj/projects/my_test/node_modules/esm/esm.js:1:271592)
    at Function.<anonymous> (/Users/dlj/projects/my_test/node_modules/esm/esm.js:1:271332)

Steps to Reproduce

Enable hard-source-webpack-plugin with webpack 5

Operating System, Node, and NPM dependency versions

Mac OS 10.14.6
Node 12.12.0

"devDependencies": {
    "@babel/core": "~7.6.3",
    "@babel/plugin-proposal-class-properties": "~7.5.5",
    "@babel/plugin-proposal-decorators": "~7.6.0",
    "@babel/plugin-proposal-export-default-from": "~7.5.2",
    "@babel/plugin-proposal-export-namespace-from": "~7.5.2",
    "@babel/plugin-proposal-function-bind": "~7.2.0",
    "@babel/plugin-proposal-json-strings": "~7.2.0",
    "@babel/plugin-proposal-object-rest-spread": "~7.6.2",
    "@babel/plugin-syntax-dynamic-import": "~7.2.0",
    "@babel/plugin-syntax-import-meta": "~7.2.0",
    "@babel/plugin-transform-classes": "~7.5.5",
    "@babel/plugin-transform-modules-commonjs": "~7.6.0",
    "@babel/plugin-transform-spread": "~7.6.2",
    "@babel/preset-env": "~7.6.3",
    "@babel/preset-react": "~7.6.3",
    "@babel/register": "~7.6.2",
    "assets-webpack-plugin": "~3.9.10",
    "babel-loader": "~8.0.6",
    "babel-plugin-lodash": "~3.3.4",
    "clean-css": "~4.2.1",
    "css-loader": "~3.2.0",
    "hard-source-webpack-plugin": "~0.13.1",
    "less": "~3.10.3",
    "less-loader": "~5.0.0",
    "simple-progress-webpack-plugin": "~1.1.2",
    "style-loader": "~1.0.0",
    "terser-webpack-plugin": "~2.2.1",
    "thread-loader": "~2.1.3",
    "webpack": "~5.0.0-beta.1"
  } 
Jurigag commented 4 years ago

Have the same issue, did you solve it?

daveisfera commented 4 years ago

I just disabled this plugin to continue testing with webpack 5

eugeneoshepkov commented 4 years ago

Isn't new webpack persistent caching making this plugin redundant?

BuptStEve commented 4 years ago

Isn't new webpack persistent caching making this plugin redundant?

You're right~ https://github.com/webpack/webpack/issues/6527

yodfz commented 4 years ago

this is pre webpack5

alexander-akait commented 4 years ago

You don't need this plugin with webpack@5, because webpack@5 support cache out of box https://webpack.js.org/configuration/other-options/#cache

wearebear80 commented 3 years ago

@mzgoddard Could you please add this information to README.md file?

CaoKejian commented 1 year ago

In webpack5, HardSourceWebpackPlugin can be replaced by cache