Imagine I have some library called shared , shared have a lot of files inside , I want to divide this library on 2 different builds shared/es , shared/node . First one for browser use , second one for node use , and depend on enviroment I want to export different folder, lets see some example :
shared/index.js
if (process.env.SERVER) {require('shared/es')}
else {require('shared/node`)}
and then I want to have opportunity to make exports from this shared/index.js file same I way as if I would make it from shared/es, I mean , imagine in root I have index.js file, and I want to import from shared some code
index.js
import {isEmpty} from 'shared/utils/lodashAlternative'
and it will mean the same as shared/es/utils/lodashAlternative or shared/node/utils/lodashAlternative . Is it possible to make somehow ?