Skip to content

Commit

Permalink
Revert "Properly handle class properties proposal"
Browse files Browse the repository at this point in the history
This reverts commit 0d47e8b.

Fix #423 #425
  • Loading branch information
rwjblue committed Dec 16, 2021
1 parent 4b44a6f commit ea752c4
Show file tree
Hide file tree
Showing 6 changed files with 1,336 additions and 2,568 deletions.
22 changes: 5 additions & 17 deletions lib/babel-options-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function _getPresetEnv(config, project) {
}

function _getModulesPlugin() {
const resolvePath =
require("./relative-module-paths").resolveRelativeModulePath;
const resolvePath = require("./relative-module-paths")
.resolveRelativeModulePath;

return [
[require.resolve("babel-plugin-module-resolver"), { resolvePath }],
Expand Down Expand Up @@ -296,12 +296,7 @@ function _getHelperVersion(project) {
return APP_BABEL_RUNTIME_VERSION.get(project);
}

function _buildClassFeaturePluginConstraints(
constraints,
config,
parent,
project
) {
function _buildClassFeaturePluginConstraints(constraints, config, parent, project) {
// With versions of ember-cli-typescript < 4.0, class feature plugins like
// @babel/plugin-proposal-class-properties were run before the TS transform.
if (!_shouldHandleTypeScript(config, parent, project)) {
Expand All @@ -312,14 +307,7 @@ function _buildClassFeaturePluginConstraints(
return constraints;
}

function _addDecoratorPlugins({
plugins,
options,
config,
parent,
project,
isClassPropertiesRequired,
}) {
function _addDecoratorPlugins(plugins, options, config, parent, project) {
const { hasPlugin, addPlugin } = require("ember-cli-babel-plugin-helpers");

if (hasPlugin(plugins, "@babel/plugin-proposal-decorators")) {
Expand Down Expand Up @@ -353,7 +341,7 @@ function _addDecoratorPlugins({
)} has added the class-properties plugin to its build, but ember-cli-babel provides these by default now! You can remove the transforms, or the addon that provided them, such as @ember-decorators/babel-transforms.`
);
}
} else if (isClassPropertiesRequired) {
} else {
addPlugin(
plugins,
[
Expand Down
24 changes: 10 additions & 14 deletions lib/get-babel-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ const {
_getPresetEnv,
} = require("./babel-options-util");

module.exports = function getBabelOptions(config, cliBabelInstance) {
let { parent, project } = cliBabelInstance;
module.exports = function getBabelOptions(config, appInstance) {
let { parent, project } = appInstance;
let addonProvidedConfig = _getAddonProvidedConfig(config);
let shouldIncludeHelpers = _shouldIncludeHelpers(config, cliBabelInstance);
let shouldIncludeHelpers = _shouldIncludeHelpers(config, appInstance);
let shouldHandleTypeScript = _shouldHandleTypeScript(config, parent, project);
let shouldIncludeDecoratorPlugins = _shouldIncludeDecoratorPlugins(config);

let emberCLIBabelConfig = config["ember-cli-babel"];
let emberCLIBabelConfig = config["ember-cli-babel"];
let shouldRunPresetEnv = true;

if (emberCLIBabelConfig) {
Expand All @@ -38,16 +38,13 @@ module.exports = function getBabelOptions(config, cliBabelInstance) {
}

if (shouldIncludeDecoratorPlugins) {
userPlugins = _addDecoratorPlugins({
plugins: userPlugins.slice(),
options: addonProvidedConfig.options,
userPlugins = _addDecoratorPlugins(
userPlugins.slice(),
addonProvidedConfig.options,
config,
parent,
project,
isClassPropertiesRequired: cliBabelInstance.isPluginRequired(
"proposal-class-properties"
),
});
project
);
}

options.plugins = []
Expand All @@ -59,8 +56,7 @@ module.exports = function getBabelOptions(config, cliBabelInstance) {
_getEmberDataPackagesPolyfill(config, parent),
_shouldCompileModules(config, project) && _getModulesPlugin(),
userPostTransformPlugins
)
.filter(Boolean);
).filter(Boolean);

options.presets = [
shouldRunPresetEnv && _getPresetEnv(addonProvidedConfig, project),
Expand Down
Loading

0 comments on commit ea752c4

Please sign in to comment.