I saw a few @todo comments in the code about this so thought I would have a go at implementing something.
[x] Replace _DEBUG_ with process.env.NODE_ENV
[x] Add @rollup/plugin-replace plugin
[x] For UMD and ES Module builds made with Rollup, replace process.env.NODE_ENV with development for unminified builds and production for minified builds
[x] Add not to architecture docs
I thought this change made sense as CommonJS users can have process.env.NODE_ENV controlled by Webpack/Parcel/Rollup to have debug code automatically removed in a production build similar to React. UMD/ES Module users get a similar experience by switching between the unminified and minified builds.
Going forward it means ECSY can start to add more debug code to functions for better DX but can keep bundle size low.
I saw a few
@todo
comments in the code about this so thought I would have a go at implementing something._DEBUG_
withprocess.env.NODE_ENV
@rollup/plugin-replace
pluginprocess.env.NODE_ENV
with development for unminified builds andproduction
for minified buildsI thought this change made sense as CommonJS users can have
process.env.NODE_ENV
controlled by Webpack/Parcel/Rollup to have debug code automatically removed in a production build similar to React. UMD/ES Module users get a similar experience by switching between the unminified and minified builds.Going forward it means ECSY can start to add more debug code to functions for better DX but can keep bundle size low.