Skip to content
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

Support Webpack v5 #6

Open
ivaylopetrovdev opened this issue Mar 9, 2021 · 8 comments
Open

Support Webpack v5 #6

ivaylopetrovdev opened this issue Mar 9, 2021 · 8 comments

Comments

@ivaylopetrovdev
Copy link

ivaylopetrovdev commented Mar 9, 2021

We need config-webpack to be compatible and tested with Webpack version 5.x.

When this will be possible? If not soon, when we can expect this support?

@arthanzel
Copy link
Owner

Webpack v5 seems to be compatible despite npm complaining about an unmet peer dependency. I'd prefer not pushing another trivial version just to silence a warning.

I recall that recent versions of Webpack (since v4 I think?) have better support for complex objects via DefinePlugin, which is what node-config-webpack does internally plus some workarounds. You may want to evaluate whether DefinePlugin works for you out of the box.

@ivaylopetrovdev
Copy link
Author

ivaylopetrovdev commented Mar 9, 2021

A warning? I see NPM ERROR, @arthanzel :
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^5.24.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^1.0.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" from [email protected]
npm ERR! node_modules/config-webpack
npm ERR! dev config-webpack@"^1.0.5" from the root project

Used stack:
"config-webpack": "^1.0.5",
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0",

npm -v
7.6.0
node -v
v14.16.0

@arthanzel
Copy link
Owner

arthanzel commented Mar 10, 2021

Ah, it seems I'm still using npm v6. v7 changes peer dependency resolution and errors if an incorrect version is found. Thanks for bringing this up.

I'll re-open this and investigate the DefinePlugin approach in newer Webpacks. If config-webpack provides no useful functionality over DefinePlugin then I'll just deprecate this package in favour of DefinePlugin for the appropriate versions.

@arthanzel arthanzel reopened this Mar 10, 2021
@arthanzel
Copy link
Owner

@ivaylopetrovdev Could you let me know if the DefinePlugin approach works for you, or if you find any weird edge cases where it fails?

@ivaylopetrovdev
Copy link
Author

ivaylopetrovdev commented Mar 11, 2021

@arthanzel Unfortunately I'm not familiar with the 'DefinePlugin approach' and how it should works. I will do some additional tests first so I can prepare up-to-date version of my application with Webpack4, before I switch again to Webpack5. Will let you know if I find something weird.
Let me know if you need some additional data. Can't wait to use the fixed version! :)

@arthanzel
Copy link
Owner

The Webpack docs describe it well. It takes about the same amount of effort to set up.

@ivaylopetrovdev
Copy link
Author

@arthanzel in this case, can we have a peerDependencies update or detailed description how it should be done for the Webpack v5 case please?

@SimeonC
Copy link
Contributor

SimeonC commented Aug 5, 2021

I was searching around and found this too, this seems to be the simplest solution that works with Webpack 5. I also created a codesandbox here (link) to show it working.

const config = require('config');

plugins: [new webpack.DefinePlugin({
  CONFIG: JSON.stringify(config)
})];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants