4 ms·
I wish there existed a lib for code that targets both Node and the browser, something like Eslint's "shared-node-browser" env.
by wildpeaks 9y ago
I wish there existed a lib for code that targets both Node and the browser, something like Eslint's "shared-node-browser" env.
- nailer 9y agobrowserify is the node standard API in the browser.
- wildpeaks 9y agoYes I know what Browserify (and Webpack, Require.js, Rollup, JSPM, etc..) are, I've used them extensively and even wrote extensions for them :) What I was referring to is the the "lib" setting of tsconfig.json: when you have code that is meant for both Node and the web, it would be better tested only against the smaller scope of functions and globals that are shared by both (like the eslint env "shared-node-browser"). Right now, people add the "dom" lib even when they just meant the non-DOM subset common to both (such as console), so if for example you accidentally refer to a window method in a module meant to be usable in both contexts, it won't get caught until runtime.