Skip to content

Commit 6332450

Browse files
authored
Merge branch 'master' into work-out-of-the-box
2 parents ebf9dd3 + a635ffb commit 6332450

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,24 +528,37 @@ The `ts:clean` command will remove the generated `.js` and `.d.ts` files, leavin
528528

529529
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).
530530

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:
532532

533533
* ensure `ember-cli-typescript` is installed and set up in the host app
534534
* 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+
```
535545

536546
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.
537547

538548
**Note**: remember to remove your `isDevelopingAddon` override before publishing!
539549

540550
### In-Repo Addons
541551

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:
543556

544557
```js
545558
paths: {
546559
// ...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';
549562
}
550563
```
551564

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939

4040
registry.add('js', {
4141
name: 'ember-cli-typescript',
42+
ext: 'ts',
4243
toTree: (original, inputPath, outputPath) => {
4344
if (!this.compiler || inputPath !== '/') {
4445
return original;

0 commit comments

Comments
 (0)