You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-4Lines changed: 17 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -528,24 +528,37 @@ The `ts:clean` command will remove the generated `.js` and `.d.ts` files, leavin
528
528
529
529
Often when developing an addon, it can be useful to run that addon in the context of some other host app so you can make sure it will integrate the way you expect, e.g. using [`yarn link`](https://yarnpkg.com/en/docs/cli/link#search) or [`npm link`](https://docs.npmjs.com/cli/link).
530
530
531
-
When you do this for a TypeScript addon, by default your `.ts` files won't be consumed by the host app. In order for a linked addon to work, you need to take two steps:
531
+
When you do this for a TypeScript addon, by default your `.ts` files won't be consumed by the host app. In order for a linked addon to work, you need to take a few steps:
532
532
533
533
* ensure `ember-cli-typescript` is installed and set up in the host app
534
534
* override [`isDevelopingAddon()`](https://ember-cli.com/api/classes/Addon.html#method_isDevelopingAddon) in the linked addon to return `true`
535
+
* add `"node_modules/my-addon/addon"` to the `include` entry in `tsconfig.json`
536
+
* update the `paths` entry in your `tsconfig.json` to instruct the compiler how to resolve imports:
537
+
538
+
```js
539
+
paths: {
540
+
// ...other entries e.g. for your app/ and tests/ trees
541
+
"my-addon": ["node_modules/my-addon/addon"], // resolve `import x from 'my-addon';
542
+
"my-addon/*": ["node_modules/my-addon/addon/*"] // resolve `import y from 'my-addon/utils/y';
543
+
}
544
+
```
535
545
536
546
This will cause `ember-cli-typescript` in the host app to take over compiling the TS files in the addon as well, automatically rebuilding any time you make a change.
537
547
538
548
**Note**: remember to remove your `isDevelopingAddon` override before publishing!
539
549
540
550
### In-Repo Addons
541
551
542
-
[In-repo addons](https://ember-cli.com/extending/#detailed-list-of-blueprints-and-their-use) work in much the same way as linked ones: their TypeScript compilation is managed by the host app. They have `isDevelopingAddon` return `true` by default, so the only thing you should need to do for an in-repo addon is update the `paths` entry in your `tsconfig.json` so instruct the compiler how to resolve imports:
552
+
[In-repo addons](https://ember-cli.com/extending/#detailed-list-of-blueprints-and-their-use) work in much the same way as linked ones: their TypeScript compilation is managed by the host app. They have `isDevelopingAddon` return `true` by default, so you only have to:
553
+
554
+
* add `"lib/my-addon/addon"` to the `include` entry in `tsconfig.json`
555
+
* update the `paths` entry in your `tsconfig.json` to instruct the compiler how to resolve imports:
543
556
544
557
```js
545
558
paths: {
546
559
// ...other entries e.g. for your app/ and tests/ trees
547
-
'my-addon': ['lib/my-addon/addon'], // resolve `import x from 'my-addon';
548
-
'my-addon/*': ['lib/my-addon/addon/*'] // resolve `import y from 'my-addon/utils/y';
560
+
"my-addon": ["lib/my-addon/addon"], // resolve `import x from 'my-addon';
561
+
"my-addon/*": ["lib/my-addon/addon/*"] // resolve `import y from 'my-addon/utils/y';
0 commit comments