Issue with the webpack blocks exports
marcofugaro opened this issue · 9 comments
Hi, I'm trying to set up a project using the release 1.0 branch, and I encountered some issues I wasn't able to resolve, here is the error stack.
module.js:487
throw err;
^
Error: Cannot find module 'webpack/lib/Chunk'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/mf/Code/accurapp/packages/webpack-preset-accurapp/node_modules/@webpack-blocks/extract-text/node_modules/extract-text-webpack-plugin/index.js:9:13)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
I think it's an issue with the extract-text-webpack-plugin
version, and probably related to #190, but I'm not using the extract-text
package in my config.
Anyway, if you want to check out the config I'm working on here it is, to replicate that issue I just ran node index.js
.
Instead, when testing the config in the complete build process, this error pops up:
TypeError: Cannot read property 'DefinePlugin' of undefined
at accuPreset (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/index.js:67:18)
at Object.<anonymous> (/Users/accurat_mf/Code/accurapp/test-app/webpack.config.js:2:18)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at readWebpackConfig (/Users/accurat_mf/Code/accurapp/test-app/node_modules/accurapp-scripts/scripts/_utils.js:60:10)
at Object.<anonymous> (/Users/accurat_mf/Code/accurapp/test-app/node_modules/accurapp-scripts/scripts/build.js:13:16)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
It's telling me the variable webpack
I require from webpack-blocks is undefined.
Feel free to ask any question about our usage of webpack blocks, might be useful some feedback, to test the configuration there is a yarn create-test-app
command in the root.
Hey @marcofugaro. Thanks for reporting the issue!
The 2nd issue you mentioned (the DefinePlugin
) is related to a recent change in the webpack-blocks 1.0 beta.
Unfortunately it seems that this change hasn't been documented which apparently is a footgun. Need to document that.
So please do const webpack = require('webpack')
instead of const { webpack } = require('webpack-blocks')
in order to fix this :)
That's a really reasonable change, because I don't need to rely on webpack-blocks for the webpack version, good job!
Anyway, thank you, I was able to solve both of my issues, you can close this issue as it gets documented.
Another small issue, I am getting a Expected a function, instead got a undefined. Beware that the block API changed since version 0.x.
error now, I am guessing it's because I am not passing the webpack instance to createConfig
.
How do I do that?
I found this in the createConfig doc comment
/**
* @param {object} initialContext The blueprint for the initial context object.
* @param {object} initialContext.webpack Webpack instance
*/
You are talking about the core
package, right? Why do you use the core
's createConfig
and not the createConfig
exposed by @webpack-blocks/webpack
?
It's not exactly the same function, since the API varies a bit. Might be a bit misleading that they have the same name.
Oh my bad, I'm just doing const { createConfig } = require('webpack-blocks')
, got lost in the source code tracing the Expected a function, instead got a undefined
error.
Here is the error trace, do you have any ideas what it might be?
Error: Expected a function, instead got a undefined. Beware that the block API changed since version 0.x.
Dump of what should have been a function: undefined
at configSetters.reduce (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:172:15)
at Array.reduce (native)
at invokeConfigSetters (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:167:24)
at config (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:111:43)
at configSetters.reduce (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:179:14)
at Array.reduce (native)
at invokeConfigSetters (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:167:24)
at Object.createConfig (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/core/lib/index.js:72:18)
at createConfig (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/node_modules/@webpack-blocks/webpack/index.js:45:15)
at accuPreset (/Users/mf/Code/accurapp/test-app/node_modules/webpack-preset-accurapp/index.js:40:10)
at Object.<anonymous> (/Users/mf/Code/accurapp/test-app/webpack.config.js:2:18)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
Could you publish the whole config? Or better a repo that we can debug?
Sure thing @sapegin, here is the config, here are the steps on how to replicate the issue, it's not that hard:
git clone git@github.com:accurat/accurapp.git
cd accurapp/
git checkout webpack-updates
yarn
(this will run lerna on the packages)yarn create-test-app
cd test-app/
yarn start
Thank you for your help!
Don't worry, it was an issue on our part, webpack-blocks is fine! Thanks anyway for the interest
That is good to hear! Thx for the heads-up 😊