By default Webpack 5 only replace process.env.NODE_ENV when bundling. But Folktale uses process.env.FOLKTALE_DOCS and process.env.FOLKTALE_ASSERTIONS in three distribution files. When executed, those bundled files throws an error because process 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
- OS: Debian Buster
- JavaScript VM: V8 (NodeJS 15)
- Folktale version: 2.3.0
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 and FOLKTALE_ASSERTIONS can be moved/nested as object properties in process.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.
By default Webpack 5 only replace
process.env.NODE_ENVwhen bundling. But Folktale usesprocess.env.FOLKTALE_DOCSandprocess.env.FOLKTALE_ASSERTIONSin three distribution files. When executed, those bundled files throws an error becauseprocessis 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
processis 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_DOCSandFOLKTALE_ASSERTIONScan 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.