Skip to content

Commit

Permalink
fix: package breaking when process.env.NODE_ENV env variable is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghustavh97 committed May 6, 2021
1 parent 882e806 commit d61d41a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/internal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const isNode =
process.versions != null &&
process.versions.node != null;
/**
* Try to detect if node or browser build in webpack
* Check if we are in a browser or being processed by webpack
*
* ! Do not use process.env.NODE_ENV === "undefined" to check for webpack
* ! it will break the script if its set and in a node enviroment.
*/
if (typeof process.env.NODE_ENV === "undefined" && isNode && !isBrowser) {
if (typeof __webpack_require__ === "undefined" && isNode && !isBrowser) {
fs = require("fs");
JSDOM = require("jsdom").JSDOM;
DOM = new JSDOM("<!DOCTYPE html></html>");
Expand Down

1 comment on commit d61d41a

@Ghustavh97
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.