From 70ac46be328712a9f7f0c812388289b035c30101 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Thu, 24 Nov 2022 11:00:17 +0100 Subject: [PATCH 1/3] Clarified how to set enableTypeScriptTransform in Ember apps, addons, and engines --- README.md | 121 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c12cbbb0..d8acb43a 100755 --- a/README.md +++ b/README.md @@ -242,35 +242,120 @@ module.exports = function(defaults) { #### Enabling TypeScript Transpilation -The transform plugin required for Babel to transpile TypeScript will -automatically be enabled when `ember-cli-typescript` >= 4.0 is installed. +Babel needs a transform plugin in order to transpile TypeScript. When you +install `ember-cli-typescript >= 4.0`, this plugin is automatically enabled. -You can enable the TypeScript Babel transform manually *without* -`ember-cli-typescript` by setting the `enableTypeScriptTransform` to `true`. +If you don't want to install `ember-cli-typescript`, you can still enable +the TypeScript-Babel transform. You will need to set `enableTypeScriptTransform` +to `true` in select file(s). -NOTE: Setting this option to `true` is not compatible with -`ember-cli-typescript` < 4.0 because of conflicting Babel plugin ordering -constraints and is unnecessary because `ember-cli-typescript` < 4.0 adds the -TypeScript Babel transform itself. -NOTE: Setting this option to `true` does *not* enable type-checking. For -integrated type-checking, you will need -[`ember-cli-typescript`](https://ember-cli-typescript.com). +
+Apps + +```js +/* ember-cli-build.js */ + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); -In an app, manually enabling the TypeScript transform would look like: +module.exports = function (defaults) { + const app = new EmberApp(defaults, { + // Add options here + 'ember-cli-babel': { + enableTypeScriptTransform: true, + }, + }); + + return app.toTree(); +}; +``` + +
+ + +
+Addons ```js -// ember-cli-build.js -module.exports = function(defaults) { - let app = new EmberApp(defaults, { +/* ember-cli-build.js */ + +const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); + +module.exports = function (defaults) { + const app = new EmberAddon(defaults, { + // Add options here 'ember-cli-babel': { - enableTypeScriptTransform: true - } + enableTypeScriptTransform: true, + }, }); return app.toTree(); -} +}; +``` + +```js +/* index.js */ + +module.exports = { + name: require('./package').name, + + options: { + 'ember-cli-babel': { + enableTypeScriptTransform: true, + }, + }, +}; +``` + +
+ + +
+Engines + +```js +/* ember-cli-build.js */ + +const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); + +module.exports = function (defaults) { + const app = new EmberAddon(defaults, { + // Add options here + 'ember-cli-babel': { + enableTypeScriptTransform: true, + }, + }); + + return app.toTree(); +}; +``` + +```js +/* index.js */ + +const EngineAddon = require('ember-engines/lib/engine-addon'); + +module.exports = EngineAddon.extend({ + name: require('./package').name, + + 'ember-cli-babel': { + enableTypeScriptTransform: true, + }, +}); ``` + +
+ + +NOTE: Setting `enableTypeScriptTransform` to `true` does *not* enable +type-checking. For integrated type-checking, you will need +[`ember-cli-typescript`](https://ember-cli-typescript.com). + +NOTE: Setting `enableTypeScriptTransform` to `true` is not compatible with +`ember-cli-typescript < 4.0` because of conflicting Babel plugin ordering +constraints. It is also unnecessary because `ember-cli-typescript < 4.0` +adds the TypeScript-Babel transform. + ### Babel config usage If you want to use the existing babel config from your project instead of the auto-generated one from this addon, then you would need to *opt-in* by passing the config `useBabelConfig: true` as a child property of `ember-cli-babel` in your `ember-cli-build.js` file. From c17b59181a937fca0a7965f6e2b206ffc677b667 Mon Sep 17 00:00:00 2001 From: Isaac Lee <16869656+ijlee2@users.noreply.github.com> Date: Fri, 9 Dec 2022 10:01:35 +0100 Subject: [PATCH 2/3] feedback: Removed paragraph Co-authored-by: Chris Krycho --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index d8acb43a..f367df1f 100755 --- a/README.md +++ b/README.md @@ -351,11 +351,6 @@ NOTE: Setting `enableTypeScriptTransform` to `true` does *not* enable type-checking. For integrated type-checking, you will need [`ember-cli-typescript`](https://ember-cli-typescript.com). -NOTE: Setting `enableTypeScriptTransform` to `true` is not compatible with -`ember-cli-typescript < 4.0` because of conflicting Babel plugin ordering -constraints. It is also unnecessary because `ember-cli-typescript < 4.0` -adds the TypeScript-Babel transform. - ### Babel config usage If you want to use the existing babel config from your project instead of the auto-generated one from this addon, then you would need to *opt-in* by passing the config `useBabelConfig: true` as a child property of `ember-cli-babel` in your `ember-cli-build.js` file. From 720ed88e1ccb795b8e8d54e388707e1c6609a58d Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Fri, 24 Feb 2023 12:40:07 +0100 Subject: [PATCH 3/3] feedback: Updated the code sample for ember-engines (>= v0.8.13) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f367df1f..71397623 100755 --- a/README.md +++ b/README.md @@ -333,9 +333,9 @@ module.exports = function (defaults) { ```js /* index.js */ -const EngineAddon = require('ember-engines/lib/engine-addon'); +const { buildEngine } = require('ember-engines/lib/engine-addon'); -module.exports = EngineAddon.extend({ +module.exports = buildEngine({ name: require('./package').name, 'ember-cli-babel': {