Socket
Socket
Sign inDemoInstall

ember-cli-babel

Package Overview
Dependencies
26
Maintainers
5
Versions
154
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.16.0 to 7.17.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## v7.17.0 (2020-02-05)
#### :rocket: Enhancement
* [#314](https://github.com/babel/ember-cli-babel/pull/314) Provide TypeScript compilation support when using ember-cli-typescript@4 or higher. ([@jamescdavis](https://github.com/jamescdavis))
#### Committers: 2
- James C. Davis ([@jamescdavis](https://github.com/jamescdavis))
- Stefan Penner ([@stefanpenner](https://github.com/stefanpenner))
## v7.16.0 (2020-02-05)

@@ -2,0 +11,0 @@

88

index.js

@@ -44,3 +44,4 @@ 'use strict';

transpileTree(inputTree, config) {
transpileTree(inputTree, _config) {
let config = _config || this._getAddonOptions();
let description = `000${++count}`.slice(-3);

@@ -55,3 +56,11 @@ let postDebugTree = this._debugTree(inputTree, `${description}:input`);

let BabelTranspiler = require('broccoli-babel-transpiler');
output = new BabelTranspiler(postDebugTree, options);
let transpilationInput = postDebugTree;
if (this._shouldHandleTypeScript(config)) {
let Funnel = require('broccoli-funnel');
let inputWithoutDeclarations = new Funnel(transpilationInput, { exclude: ['**/*.d.ts'] });
transpilationInput = this._debugTree(inputWithoutDeclarations, `${description}:filtered-input`);
}
output = new BabelTranspiler(transpilationInput, options);
}

@@ -257,4 +266,5 @@

_getExtensions(config) {
let shouldHandleTypeScript = this._shouldHandleTypeScript(config);
let emberCLIBabelConfig = config['ember-cli-babel'] || {};
return emberCLIBabelConfig.extensions || ['js'];
return emberCLIBabelConfig.extensions || (shouldHandleTypeScript ? ['js', 'ts'] : ['js']);
},

@@ -266,2 +276,3 @@

let shouldIncludeHelpers = this._shouldIncludeHelpers(config);
let shouldHandleTypeScript = this._shouldHandleTypeScript(config);
let shouldIncludeDecoratorPlugins = this._shouldIncludeDecoratorPlugins(config);

@@ -297,4 +308,8 @@

if (shouldHandleTypeScript) {
userPlugins = this._addTypeScriptPlugin(userPlugins.slice(), addonProvidedConfig.options);
}
if (shouldIncludeDecoratorPlugins) {
userPlugins = this._addDecoratorPlugins(userPlugins.slice(), addonProvidedConfig.options);
userPlugins = this._addDecoratorPlugins(userPlugins.slice(), addonProvidedConfig.options, config);
}

@@ -327,2 +342,52 @@

_shouldHandleTypeScript(config) {
let emberCLIBabelConfig = config['ember-cli-babel'] || {};
if (typeof emberCLIBabelConfig.enableTypeScriptTransform === 'boolean') {
return emberCLIBabelConfig.enableTypeScriptTransform;
}
let typeScriptAddon = this.parent.addons
&& this.parent.addons.find(a => a.name === 'ember-cli-typescript');
return typeof typeScriptAddon !== 'undefined'
&& semver.gte(typeScriptAddon.pkg.version, '4.0.0-alpha.1');
},
_buildClassFeaturePluginConstraints(constraints, config) {
// With versions of ember-cli-typescript < 4.0, class feature plugins like
// @babel/plugin-proposal-class-properties were run before the TS transform.
if (!this._shouldHandleTypeScript(config)) {
constraints.before = constraints.before || [];
constraints.before.push('@babel/plugin-transform-typescript');
}
return constraints;
},
_addTypeScriptPlugin(plugins) {
const { hasPlugin, addPlugin } = require('ember-cli-babel-plugin-helpers');
if (hasPlugin(plugins, '@babel/plugin-transform-typescript')) {
if (this.parent === this.project) {
this.project.ui.writeWarnLine(`${
this._parentName()
} has added the TypeScript transform plugin to its build, but ember-cli-babel provides this by default now when ember-cli-typescript >= 4.0 is installed! You can remove the transform, or the addon that provided it.`);
}
} else {
addPlugin(
plugins,
[
require.resolve('@babel/plugin-transform-typescript'),
{ allowDeclareFields: true },
],
{
before: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-private-methods',
'@babel/plugin-proposal-decorators',
]
}
);
}
return plugins;
},
_shouldIncludeDecoratorPlugins(config) {

@@ -334,3 +399,3 @@ let customOptions = config['ember-cli-babel'] || {};

_addDecoratorPlugins(plugins, options) {
_addDecoratorPlugins(plugins, options, config) {
const { hasPlugin, addPlugin } = require('ember-cli-babel-plugin-helpers');

@@ -348,5 +413,5 @@

[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
{
before: ['@babel/plugin-proposal-class-properties', '@babel/plugin-transform-typescript']
}
this._buildClassFeaturePluginConstraints({
before: ['@babel/plugin-proposal-class-properties']
}, config)
);

@@ -366,6 +431,5 @@ }

[require.resolve('@babel/plugin-proposal-class-properties'), { loose: options.loose || false }],
{
after: ['@babel/plugin-proposal-decorators'],
before: ['@babel/plugin-transform-typescript']
}
this._buildClassFeaturePluginConstraints({
after: ['@babel/plugin-proposal-decorators']
}, config)
);

@@ -372,0 +436,0 @@ }

3

package.json
{
"name": "ember-cli-babel",
"version": "7.16.0",
"version": "7.17.0",
"description": "Ember CLI addon for Babel",

@@ -49,2 +49,3 @@ "keywords": [

"@babel/plugin-transform-runtime": "^7.8.3",
"@babel/plugin-transform-typescript": "^7.8.3",
"@babel/polyfill": "^7.8.3",

@@ -51,0 +52,0 @@ "@babel/preset-env": "^7.8.4",

@@ -22,2 +22,3 @@ # ember-cli-babel

+ [Disabling Debug Tooling Support](#disabling-debug-tooling-support)
+ [Enabling TypeScript Transpilation](#enabling-typescript-transpilation)
* [Addon usage](#addon-usage)

@@ -126,2 +127,3 @@ + [Adding Custom Plugins](#adding-custom-plugins)

disableDecoratorTransforms?: boolean;
enableTypeScriptTransform?: boolean;
extensions?: string[];

@@ -265,2 +267,34 @@ };

#### Enabling TypeScript Transpilation
The transform plugin required for Babel to transpile TypeScript will
automatically be enabled when `ember-cli-typescript` >= 4.0 is installed.
You can enable the TypeScript Babel transform manually *without*
`ember-cli-typescript` by setting the `enableTypeScriptTransform` to `true`.
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).
In an app, manually enabling the TypeScript transform would look like:
```js
// ember-cli-build.js
module.exports = function(defaults) {
let app = new EmberApp(defaults, {
'ember-cli-babel': {
enableTypeScriptTransform: true
}
});
return app.toTree();
}
```
### Addon usage

@@ -267,0 +301,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc