dotenv-webpack: ๐ [bug] after update to v2 -> v3 "SyntaxError: Unexpected token '.'"
[INFO] 22:11:43 Restarting
SyntaxError: Unexpected token '.'
at Object../src/server/server.production.js (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:1778:1)
at __webpack_require__ (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:2089:32)
at fn (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:2225:21)
at eval (webpack-internal:///./src/index.js:7:83)
at Module../src/index.js (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:1514:1)
at __webpack_require__ (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:2089:32)
at C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:2992:11
at Object.<anonymous> (C:\FRONTEND\www\group-dashboard\group-dashboard-api\dist\main.js:2993:12)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
[ERROR] 22:11:43 SyntaxError
and my process.env = empty
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 25
- Comments: 33 (8 by maintainers)
I got
Uncaught SyntaxError: Unexpected token ':'
And here it is in bundle.js:
Wow, Iโm so sorry everyone. My notifications got out of whack and I missed all of this.
I just rolled-back the support for webpack 5. This should be released as
dotenv-webpack@v4.0.0
(essentially the same thing inv2.0.0
with updated dependencies).Because of this, anyone looking for support for webpack 5 wont have it. Any ideas?
The previous major version (2.3.2, locked as ^2.0.0) works fine for me with webpack 4
@flo-sch they are actually all supported up to this version. The gotchas are still gotchas from v4 as they are on v5.
Fortunately nothing changed, except that in webpack v5 you get an error if you reference an undefined variable (thatโs on webpack because they removed support for declaring an empty process.env object when bundling).
@sacummings91 I see it working too, just still no destructing: https://github.com/mrsteele/dotenv-webpack/pull/261
@BeeeQueue consider to replace it with proxy, something like:
In this way:
process.env.foo.bar.x
orprocess.env.foo.bar[Symbol('y')]
I think there are 2 issues. One that in webpack 5 all node polyfills will be removed meaning that any code using process, global etc. will need to remove them or provide your own polyfill etc. The other is that by providing the DefinePlugin with the value
process = '{"env": {}}'
will overwrite any value likeprocess.env.VAR_NAME: "someValue"
so any other plugin/user will not be able to add their own values. So I think #241 will fix this issue for webpack 4 users and allow users of webpack 5 to provide process.env.variable with other plugins etc. ๐ค