ember-cli / ember-cli/ember-addon-blueprint

Unbuilt self-package-name-imports

Open
#126 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5
Forks
10
PR merge metrics
No merged PRs in 30d

Description

It's nice to allow addons to import themselves by name, especially so that their tests and demos are importing things the same way a consuming app would, which aids learning.

The main reason it doesn't already work nicely is that package.json `exports` points at `dist`, not `src`.

One option is to create a dedicated export condition:

```json
"exports": {
".": {
"addon-development": "./src/index.ts",
"default": "./dist/index.js"
},
```

which can be enabled in vite.config.js like:

```js
resolve: {
conditions: ['addon-development']
}
```

However, I realized this creates a hazard. When your addon is consumed by another addon, that addon may also opt into the `"addon-development"` condition and then it will try to consume your unbuilt sources, which is definitely not desirable.

So it seems that if we want to use this pattern, we'd have to either put the package name into the condition name:

```json
"exports": {
".": {
"developing-@ef4/example-package": "./src/index.ts",
"default": "./dist/index.js"
},
```

Or have a prepublish step that deletes these extra conditions so that people installing your package never see them.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.