I have a library which was used as follows

```
import { Foo } from '@me/core';
const foo = new Foo();

```

The `package.json` of that library looks like

```
"name": "@me/core",
"version": "1.0.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
...

```

With `dist/index.js` its entrypoint. Now, however, I would provide an import for NodeJs projects only and one for web projects. Ideally I would have something like this for NodeJs

```
import { Foo } from '@me/core/nodejs';

```

and if you're working on a web-project you could do

```
import { Foo } from '@me/core/web';

```

My understanding is that both `@me/core/nodejs` and `@me/core/web` will be different NPM packages this way, which is not what I want. I want it to be in 1 npm package.

I tried to changed the library's index.ts file, from

```
export * from './foo';

```

into

```
import * as nodejs from './nodejs';
import * as web from './web';

export { web, nodejs };

```

This actually works, but I have to use it now (in a NODEJS project) as follows

```
import { nodejs } from '@me/core';

const foo = new nodejs.Foo();

```

Is there maybe a way to import this such that I don't need the `nodejs` everytime?

As you can see I'm not so sure what I should do here so any help would be appreciated!

UPDATE: Based on the suggestions by @Klaycon I see the following error:

[![enter image description here](https://i.stack.imgur.com/KrniS.jpg)](https://i.stack.imgur.com/KrniS.jpg)