hard-source-webpack-plugin
hard-source-webpack-plugin copied to clipboard
TypeError: Cannot read property 'tap' of undefined
Expected Behavior
I'd like to be able to exclude plugins on webpack v4
Actual Behavior
It crashes when I try to exclude plugins
Is an error being thrown?
TypeError: Cannot read property 'tap' of undefined
at compilerHooks.afterPlugins.tap (/Users/sontek/code/eventray/src/eventray/node_modules/hard-source-webpack-plugin/lib/ExcludeModulePlugin.js:40:50)
at SyncHook.eval (eval at create (/Users/sontek/code/eventray/src/eventray/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
at SyncHook.lazyCompileHook (/Users/sontek/code/eventray/src/eventray/node_modules/tapable/lib/Hook.js:154:20)
at WebpackOptionsApply.process (/Users/sontek/code/eventray/src/eventray/node_modules/webpack/lib/WebpackOptionsApply.js:492:31)
at webpack (/Users/sontek/code/eventray/src/eventray/node_modules/webpack/lib/webpack.js:53:48)
at processOptions (/Users/sontek/code/eventray/src/eventray/node_modules/webpack-cli/bin/cli.js:441:16)
at yargs.parse (/Users/sontek/code/eventray/src/eventray/node_modules/webpack-cli/bin/cli.js:536:3)
at Object.parse (/Users/sontek/code/eventray/src/eventray/node_modules/webpack-cli/node_modules/yargs/yargs.js:563:18)
at /Users/sontek/code/eventray/src/eventray/node_modules/webpack-cli/bin/cli.js:219:8
at Object.<anonymous> (/Users/sontek/code/eventray/src/eventray/node_modules/webpack-cli/bin/cli.js:538:3)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/sontek/code/eventray/src/eventray/node_modules/webpack/bin/webpack.js:155:2)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
at startup (internal/bootstrap/node.js:240:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)
Steps to Reproduce
Use this snippet:
.ExcludeModulePlugin([
{
// HardSource works with mini-css-extract-plugin but due to how
// mini-css emits assets, assets are not emitted on repeated builds with
// mini-css and hard-source together. Ignoring the mini-css loader
// modules, but not the other css loader modules, excludes the modules
// that mini-css needs rebuilt to output assets every time.
test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
},
])
Operating System, Node, and NPM dependency versions
OSX
node --version
v10.5.0
"devDependencies": {
"babel-core": "^7.0.0-0",
"babel-jest": "^23.6.0",
"browser-sync": "^2.18.12",
"chai": "^4.0.2",
"concurrently": "^3.5.1",
"deep-diff": "^1.0.1",
"deep-freeze": "latest",
"enzyme": "^3.2.0",
"enzyme-to-json": "^3.2.2",
"eslint-plugin-import": "^2.2.0",
"express": "^4.15.3",
"import-sort": "^5.0.0",
"import-sort-cli": "^5.0.0",
"import-sort-parser-babylon": "^5.0.0",
"import-sort-style-eslint": "^5.0.0",
"ip": "^1.1.5",
"jest": "^23.6.0",
"jest-aphrodite-react": "^2.1.0",
"jest-cli": "^23.3.0",
"jest-teamcity-reporter": "^0.9.0",
"mock-local-storage": "^1.0.5",
"nock": "^9.3.0",
"react-addons-test-utils": "^15.6.2",
"react-hot-loader": "^4.3.11",
"react-transform-catch-errors": "latest",
"redux-devtools": "^3.3.2",
"redux-devtools-dock-monitor": "^1.1.1",
"redux-devtools-log-monitor": "^1.2.0",
"redux-logger": "^3.0.1",
"redux-mock-store": "^1.2.2",
"rimraf": "^2.6.2",
"speed-measure-webpack-plugin": "^1.2.3",
"webpack-dev-middleware": "^3.4.0",
"webpack-dev-server": "^3.1.9",
"webpack-hot-middleware": "^2.24.2"
},
"dependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-decorators": "^7.1.2",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@tinymce/tinymce-react": "^2.2.6",
"aphrodite": "^2.2.1",
"autoprefixer": "^9.0.1",
"babel-eslint": "^10.0.1",
"babel-gettext-extractor": "^3.0.0",
"babel-loader": "^8.0.4",
"babel-plugin-istanbul": "^5.0.1",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"chart.js": "^2.7.2",
"classnames": "^2.2.5",
"commonmark": "^0.28.1",
"commonmark-react-renderer": "^4.3.2",
"compression-webpack-plugin": "^2.0.0",
"console-polyfill": "^0.3.0",
"cookies.js": "^2.1.15",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^1.0.0",
"css-mqpacker": "^6.0.1",
"currency-formatter": "^1.2.1",
"currency.js": "^1.1.0",
"deep-equal": "^1.0.1",
"deep-extend": "^0.6.0",
"dompurify": "^1.0.2",
"draft-js": "^0.10.4",
"draft-js-export-html": "^1.2.0",
"draft-js-import-html": "^1.2.1",
"draftjs-to-html": "^0.8.1",
"draftjs-utils": "^0.9.1",
"emoji-flags": "^1.2.0",
"env-cmd": "^8.0.2",
"enzyme-adapter-react-16": "^1.1.0",
"eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.5.1",
"eslint-teamcity": "^2.0.1",
"esprima": "^4.0.0",
"event-emitter": "^0.3.5",
"extract-hoc": "^0.0.5",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"font-awesome": "4.7.0",
"gettext-parser": "^2.0.0",
"hard-source-webpack-plugin": "^0.12.0",
"highlight.js": "^9.12.0",
"history": "^4.7.2",
"html-loader": "^0.5.1",
"html-webpack-plugin": "^3.2.0",
"husky": "^0.14.3",
"identity-obj-proxy": "^3.0.0",
"image-webpack-loader": "^4.3.0",
"immutability-helper": "^2.6.4",
"immutable": "^3.8.2",
"invariant": "^2.2.2",
"is-nil": "^1.0.1",
"isomorphic-fetch": "^2.2.1",
"istanbul": "latest",
"jed": "^1.1.1",
"js-search": "^1.4.2",
"jsdom": "^11.5.1",
"json-loader": "latest",
"leftpad": "^0.0.1",
"libphonenumber-js": "^1.4.3",
"lint-staged": "^7.1.3",
"loader-utils": "^1.1.0",
"lodash-webpack-plugin": "^0.11.5",
"lodash.assign": "^4.2.0",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "4.0.8",
"lodash.defaults": "^4.2.0",
"lodash.escaperegexp": "^4.1.2",
"lodash.every": "^4.6.0",
"lodash.find": "^4.6.0",
"lodash.findindex": "^4.6.0",
"lodash.flatten": "^4.4.0",
"lodash.frompairs": "^4.0.1",
"lodash.get": "^4.4.2",
"lodash.groupby": "^4.6.0",
"lodash.has": "^4.5.2",
"lodash.isempty": "^4.4.0",
"lodash.isfunction": "^3.0.8",
"lodash.ismatch": "^4.4.0",
"lodash.isnil": "^4.0.0",
"lodash.omit": "^4.5.0",
"lodash.omitby": "^4.6.0",
"lodash.orderby": "^4.6.0",
"lodash.pick": "4.4.0",
"lodash.set": "^4.3.2",
"lodash.some": "^4.6.0",
"lodash.sortby": "^4.7.0",
"lodash.throttle": "^4.1.1",
"lodash.unionby": "^4.8.0",
"lost": "^8.0.0",
"mini-css-extract-plugin": "^0.4.0",
"moment": "^2.22.2",
"moment-timezone": "^0.5.16",
"node-sass": "^4.7.2",
"normalize.css": "^8.0.0",
"parse-english": "^4.1.0",
"pixrem": "^4.0.1",
"po-catalog-loader": "^2.0.0",
"popper.js": "^1.12.6",
"postcss-calc": "^6.0.0",
"postcss-flexbugs-fixes": "^4.1.0",
"postcss-loader": "^3.0.0",
"prettier": "^1.13.4",
"prop-types": "^15.6.0",
"qs": "^6.4.0",
"raf": "^3.4.0",
"raven-js": "^3.24.0",
"raw-loader": "^0.5.1",
"react": "^16.2.0",
"react-addons-shallow-compare": "^15.6.2",
"react-beautiful-dnd": "^8.0.1",
"react-burger-menu": "^2.5.0",
"react-color": "^2.12.1",
"react-copy-to-clipboard": "^5.0.0",
"react-data-grid": "^4.0.7",
"react-data-grid-addons": "^4.0.8",
"react-dates": "^17.1.1",
"react-dev-utils": "^5.0.0",
"react-document-title": "^2.0.3",
"react-dom": "^16.2.0",
"react-double-scrollbar": "^0.0.15",
"react-draft-wysiwyg": "^1.12.7",
"react-dropzone": "^4.2.11",
"react-html-parser": "^2.0.2",
"react-input-range": "^1.3.0",
"react-modal": "^3.5.1",
"react-onclickoutside": "^6.1.1",
"react-pdf-js": "^3.0.7",
"react-popper": "^0.10.4",
"react-redux": "^5.0.6",
"react-responsive": "^4.0.3",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scroll": "^1.7.6",
"react-select-plus": "^1.1.0",
"react-sortable-hoc": "^0.8.3",
"react-sticky": "tchock/react-sticky#6.0.1-1",
"react-tap-event-plugin": "^3.0.2",
"react-test-renderer": "^16.2.0",
"react-tippy": "^1.2.2",
"react-toggle": "^4.0.2",
"redbox-react": "^1.4.2",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"rehype-format": "^2.2.0",
"rehype-highlight": "^2.0.1",
"rehype-raw": "^3.0.0",
"rehype-stringify": "^4.0.0",
"remark": "^9.0.0",
"remark-parse": "^5.0.0",
"remark-preset-lint-markdown-style-guide": "^2.1.1",
"remark-react": "^4.0.1",
"remark-rehype": "^3.0.0",
"remark-retext": "^3.1.0",
"resize-observer-polyfill": "^1.5.0",
"retext-english": "^3.0.0",
"retext-equality": "^3.2.0",
"retext-passive": "^1.3.0",
"retext-smartypants": "^3.0.1",
"retext-stringify": "^2.0.0",
"sanitize-html": "^1.16.1",
"sass-loader": "^6.0.6",
"slugify": "^1.2.6",
"sprintf-js": "^1.1.1",
"style-loader": "^0.23.0",
"tinycolor2": "^1.4.1",
"tinymce": "^4.8.2",
"type-detect": "^4.0.3",
"uglifyjs-webpack-plugin": "^2.0.1",
"url-join": "^4.0.0",
"url-loader": "^1.0.1",
"url-parse": "^1.1.9",
"uuid": "^3.1.0",
"vfile-reporter": "^5.0.0",
"webapp-webpack-plugin": "^2.3.1",
"webpack": "^4.20.1",
"webpack-cli": "^3.1.1",
"webpack-manifest-plugin": "^2.0.2",
"whatwg-fetch": "^2.0.4"
},
I am getting same error. (webpack 4.8.3)
Whenever I use new HardSourceWebpackPlugin()
webpack works. But ExcludeModulePlugin
variant does not.
Note that I am using mini-css-extract-plugin
.
ExcludeModulePlugin
is used like this (I've taken this from README)
new HardSourceWebpackPlugin.ExcludeModulePlugin([
{
// HardSource works with mini-css-extract-plugin but due to how
// mini-css emits assets, assets are not emitted on repeated builds with
// mini-css and hard-source together. Ignoring the mini-css loader
// modules, but not the other css loader modules, excludes the modules
// that mini-css needs rebuilt to output assets every time.
test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
},
]),
Error:
TypeError: Cannot read property 'tap' of undefined
at compilerHooks.afterPlugins.tap (/var/docker/assets/node_modules/hard-source-webpack-plugin/lib/ExcludeModulePlugin.js:40:50)
at SyncHook.eval [as call] (eval at create (/var/docker/assets/node_modules/tapable/lib/HookCodeFactory.js:17:12), <anonymous>:7:1)
at SyncHook.lazyCompileHook [as _call] (/var/docker/assets/node_modules/tapable/lib/Hook.js:35:21)
at WebpackOptionsApply.process (/var/docker/assets/node_modules/webpack/lib/WebpackOptionsApply.js:363:31)
at webpack (/var/docker/assets/node_modules/webpack/lib/webpack.js:42:48)
at processOptions (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:437:16)
at yargs.parse (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:513:3)
at Object.parse (/var/docker/assets/node_modules/yargs/yargs.js:552:18)
at /var/docker/assets/node_modules/webpack-cli/bin/webpack.js:218:8
at Object.<anonymous> (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:515:3)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/var/docker/assets/node_modules/webpack/bin/webpack.js:80:2)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
It looks like that I won't need ExcludeModulePlugin
, because, in my case, line at https://github.com/mzgoddard/hard-source-webpack-plugin/blob/master/index.js#L480 evaluates to true... Is my assumption correct @mzgoddard ?
I was able to get this working by changing my configuration. The way I interpreted the README, I thought you used a plugin like so:
plugins: [
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
]
BUT, it is required to first add just the hardsource plugin itself, and THEN add subsequent plugins
plugins: [
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
]
I also get this error even though I'm loading this way
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
If you are using 'speed-measure-webpack-plugin'... removing it fixed this problem for me.
@rsbowers I also fixed this problem after removed it... 'speed-measure-webpack-plugin' affects compiler hooks, but i do not know the reason...
If you are using 'speed-measure-webpack-plugin'... removing it fixed this problem for me.
thank you
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ParallelModulePlugin({
// How to launch the extra processes. Default:
fork: (fork, compiler, webpackBin) => fork(
webpackBin(),
['--config', __filename], {
silent: true,
}
),
numWorkers: () => 4,
minModules: 20,
}),
The production and packaging are completed directly, no errors are reported, but the printing is not actually finished. why is it so?