How to make webpack not use the window object when bundling?

I’m making a React component library to abstract out some components I use in multiple projects. Some projects are made with CRA, some with Gatsby, some might be something else, etc. I used the Neutrino.js framework/toolchain as it was linked on the React docs site, but the issue I ran into is that by default the output files of the build all use the window object, which causes gatsby build to break as window doesn’t exist in Node/SSR. Is there a way to make Neutrino/webpack output a bundle that doesn’t use window? While searching for a solution and comparing to

NodeJs heap-js module: Heap is not a constructor

I am trying to initialize a minimum heap/priority queue in my server.js using the head-js module (https://github.com/ignlg/heap-js). When I run my code, I receive the following error: TypeError: Heap is not a constructor However, according to the documentation, I am initializing the heap correctly, putting in a custom constructor as the parameter. Below is my code: Answer There’s a difference between using heap-js library in CommonJS and ES6 modules. When requireing (i.e. CommonJS) you need to destruct out the Heap class from the object returned, like so: Whereas, you have to do the opposite in ES6, as shown below:

How to exports many mongoose models modules in node.js

I have 2 models like this Now I want to export them. First I export Db and everything is fine. I can do an HTTP request with it. However, when I try to export ´the 2nd one outside, it stops functioning. The functions below will return a blank JSON file as a response. This won’t work either. It returns an error handler saying all my functions in the handler is not function. This is the function on the file I import the models. The return from the handler is Db.findOne is not a function. Is there any way to export

Javascript – Where are ‘import’ and ‘export’ statements legal?

I’m studying the new import, export feature in Javascript but was wondering, where in code will these statements be syntactically legal? I understand something like the following won’t be legal: (function(){ import thing from ‘./thing.js’; })(); but does this mean import is only legal at the top of the module script? Or in the global scope? E.g., what about this: import a from ‘./a.js’; (function(){ // … do something with a … })(); import b from ‘./b.js’; // … Also, does this limitation apply to export? E.g., will the following be legal? (function(){ function internalFunc() { // … } export