esm-package-browser-server
v1.0.1
Published
Example ESM package browser server
Downloads
14
Maintainers
Readme
esm-package-browser-server
Example ESM package which exports both browser and server modules and isomorphic JavaScript code which can run in browser and/or server.
Usage
For browser:
import { shared, browser } from "esm-package-browser-server";
console.log(shared('Example'));
console.log(browser('Example'));
For server:
import { shared, server } from "esm-package-browser-server";
console.log(shared('Example'));
console.log(server('Example'));
Shared function should be able to be run both browser/server, but the the other code not accessible unless on correct platform.
How it works
Using conditional exports:
"exports": {
"node": "./src/server.js",
"default": "./src/browser.js"
},
Node process will use ./src/server.js
others will fallback to ./src/browser.js
Contact
For more information please contact kmturley