-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Class constructor ConfigList cannot be invoked without 'new' #1097
Comments
Thanks for opening this!! If you have an idea about how to fix this we would love to review a PR ❤️ |
@guilleiguaran Looking into it |
We just need to return native types back, didn't realise it's going to be used outside of webpacker though :) |
@rossta Would be interesting to know your use case with clonedeep |
@gauravtiwari We've been using |
You could use built-in methods for merging custom configs: https://github.com/rails/webpacker/blob/master/docs/webpack.md#configuration Is this enough? |
// config/webpack/custom.js
module.exports = {
resolve: {
alias: {
jquery: 'jquery/src/jquery',
vue: 'vue/dist/vue.js',
React: 'react',
ReactDOM: 'react-dom',
vue_resource: 'vue-resource/dist/vue-resource',
}
}
}
// config/webpack/environment.js
const environment = require('./environment')
const customConfig = require('./custom')
// Set nested object prop using path notation
environment.config.set('resolve.extensions', ['.foo', '.bar'])
environment.config.set('output.filename', '[name].js')
// Merge custom config
environment.config.merge(customConfig) |
+1 in support for It might seem a bit surprising that |
Yep, made a PR but we ship a new method |
Whether or not |
Another use-case is for const webpackConfigForHMR = require('webpacker-react/configure-hot-module-replacement.js')
const config = environment.toWebpackConfig()
module.exports = webpackConfigForHMR(config) I guess we should switch to something else that uses Webpacker's the new API. Something like: const patchWebpackerConfigForHMR = require('webpacker-react/patch-webpacker-config-for-hmr')
patchWebpackerConfigForHMR(environment)
module.exports = environment.toWebpackConfig() |
@renchap This should be fixed on master |
System:
•
@rails/webpacker
version:3.1.1
• node version:
v6.11.5
• lodash version:
4.14.2
Steps to reproduce:
Sample output:
/dev/node_modules/lodash/lodash.js:5763 result = array.constructor(length); ^ TypeError: Class constructor ConfigList cannot be invoked without 'new' at initCloneArray (/dev/node_modules/lodash/lodash.js:5763:26) at baseClone (/dev/node_modules/lodash/lodash.js:2396:18) at /dev/node_modules/lodash/lodash.js:2439:34 at arrayEach (/dev/node_modules/lodash/lodash.js:485:11) at baseClone (/dev/node_modules/lodash/lodash.js:2433:7) at /dev/node_modules/lodash/lodash.js:2439:34 at arrayEach (/dev/node_modules/lodash/lodash.js:485:11) at baseClone (/dev/node_modules/lodash/lodash.js:2433:7) at cloneDeep (/dev/node_modules/lodash/lodash.js:10650:14) at Object.<anonymous> (/dev/tmp/webpacker_clonedeep.js:4:18)
Attempting a deep clone of the object returned by
environment.toWebpackConfig()
results in aTypeError
. I came across this error by usingwebpack-merge
, which delegates to lodashcloneDeep
, to update the Webpack config.Perhaps it makes sense to ensure that once
toWebpackConfig
is called, instances of Webpacker base type subclasses, e.g.,ConfigList
,ConfigObject
, are converted back to their base types to avoid surprising results.The text was updated successfully, but these errors were encountered: