-
Notifications
You must be signed in to change notification settings - Fork 102
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
process.env.FOLKTALE_DOCS is not replaced by Webpack 5 #229
Comments
Ah, I'm not very familiar with JS tooling at this point. Is that a new thing in WebPack? Looks like there aren't many instances of it in the source, so it should be doable to just test for |
Yes, Webpack 5 now only set
|
I just ran across this one too. Because folktale was being used by a dependency and not the current project it was not all that easy to track down the issue. Thanks for cdoublev for posting the But, yeah. I would be in favor of some kind of update which meant folktale didn't die instantly whenever you try to run it on the web. |
Spoke too soon. To get it all working I also had to add FOLKTALE_ASSERTIONS to the environment plugin:
|
This fell through my todo list. The proper fix is simple, but releasing it is going to take a while as the build system has degraded quite a bit over the years. |
By default Webpack 5 only replace
process.env.NODE_ENV
when bundling. But Folktale usesprocess.env.FOLKTALE_DOCS
andprocess.env.FOLKTALE_ASSERTIONS
in three distribution files. When executed, those bundled files throws an error becauseprocess
is undefined.Steps to reproduce
It can be reproduced by bundling with Webpack 5 a file that contains eg.
Task.of()
.Expected behaviour
Run the bundle without throwing an error.
Observed behaviour
The bundled file throws an error because
process
is undefined.Environment
Additional information
It can be fixed by adding
plugins: [new webpack.EnvironmentPlugin({ FOLKTALE_DOCS: false })]
in the Webpack configuration file. This could be documented in the Folktale documentation.Or
FOLKTALE_DOCS
andFOLKTALE_ASSERTIONS
can be moved/nested as object properties inprocess.env.NODE_ENV
, but I'm aware that browsers are not necessary the main platform target of this library, therefore this change might not be worth it. However, and to answer this comment (what most users of the library are interested in seeing), this change could lower the barrier of entry for adopting Folktale, which I should say is IMHO the best FP ADT library I found and use since a few years now.The text was updated successfully, but these errors were encountered: