Skip to content

Commit

Permalink
[BUGFIX] Ensures the classic transform only runs once (#16)
Browse files Browse the repository at this point in the history
[BUGFIX] Ensures the classic transform only runs once
  • Loading branch information
Chris Garrett authored Oct 29, 2019
2 parents ae1ec6b + 5d309f6 commit 2004ef9
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {

if (!hasPlugin) {
parentOptions.babel.plugins.push(
require.resolve('./lib/classic-decorator-transform-v2')
require.resolve('./lib/classic-decorator-transform-v3')
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ module.exports = function(babel) {
);
},

ClassDeclaration(path) {
ClassDeclaration(path, state) {
if (state.classicDecoratorAnalysisAdded === true) {
return;
}

if (path.node.id) {
path.insertAfter(
t.expressionStatement(
Expand Down Expand Up @@ -75,5 +79,9 @@ module.exports = function(babel) {
}
},
},

post(state) {
state.classicDecoratorAnalysisAdded = true;
}
};
};
8 changes: 6 additions & 2 deletions tests/unit/classic-decorator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ module('@classic', () => {
const FooController = Controller.extend();

@classic
class BarController extends FooController {}
class BarController extends FooController {
foo = 123;
}

class BazController extends BarController {}
class BazController extends BarController {
foo = 456;
}

@classic
class QuxController extends BazController {}
Expand Down
56 changes: 56 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,13 @@ babel-plugin-debug-macros@^0.3.0:
dependencies:
semver "^5.3.0"

babel-plugin-ember-modules-api-polyfill@^2.12.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-2.12.0.tgz#a5e703205ba4e625a7fab9bb1aea64ef3222cf75"
integrity sha512-ZQU4quX0TJ1yYyosPy5PFigKdCFEVHJ6H0b3hwjxekIP9CDwzk0OhQuKhCOPti+d52VWjjCjxu2BrXEih29mFw==
dependencies:
ember-rfc176-data "^0.3.12"

babel-plugin-ember-modules-api-polyfill@^2.6.0, babel-plugin-ember-modules-api-polyfill@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-2.9.0.tgz#8503e7b4192aeb336b00265e6235258ff6b754aa"
Expand Down Expand Up @@ -1840,6 +1847,23 @@ broccoli-babel-transpiler@^7.1.2, broccoli-babel-transpiler@^7.2.0:
rsvp "^4.8.4"
workerpool "^3.1.1"

broccoli-babel-transpiler@^7.3.0:
version "7.3.0"
resolved "https://registry.yarnpkg.com/broccoli-babel-transpiler/-/broccoli-babel-transpiler-7.3.0.tgz#a0ad3a37dbf74469664bbca403d652070c2c1317"
integrity sha512-tsXNvDf3gp6g8rGkz234AhbaIRUsCdd6CM3ikfkJVB0EpC8ZAczGsFKTjENLy1etx4s7FkruW/QjI7Wfdhx6Ng==
dependencies:
"@babel/core" "^7.3.3"
"@babel/polyfill" "^7.0.0"
broccoli-funnel "^2.0.2"
broccoli-merge-trees "^3.0.2"
broccoli-persistent-filter "^2.2.1"
clone "^2.1.2"
hash-for-dep "^1.4.7"
heimdalljs-logger "^0.1.9"
json-stable-stringify "^1.0.1"
rsvp "^4.8.4"
workerpool "^3.1.1"

broccoli-builder@^0.18.14:
version "0.18.14"
resolved "https://registry.yarnpkg.com/broccoli-builder/-/broccoli-builder-0.18.14.tgz#4b79e2f844de11a4e1b816c3f49c6df4776c312d"
Expand Down Expand Up @@ -2975,6 +2999,33 @@ ember-cli-babel@^7.0.0, ember-cli-babel@^7.1.2, ember-cli-babel@^7.1.3, ember-cl
ensure-posix-path "^1.0.2"
semver "^5.5.0"

ember-cli-babel@^7.11.1:
version "7.12.0"
resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-7.12.0.tgz#064997d199384be8c88d251f30ef67953d3bddc5"
integrity sha512-+EGQsbPvh19nNXHCm6rVBx2CdlxQlzxMyhey5hsGViDPriDI4PFYXYaFWdGizDrmZoDcG/Ywpeph3hl0NxGQTg==
dependencies:
"@babel/core" "^7.0.0"
"@babel/plugin-proposal-class-properties" "^7.3.4"
"@babel/plugin-proposal-decorators" "^7.3.0"
"@babel/plugin-transform-modules-amd" "^7.0.0"
"@babel/plugin-transform-runtime" "^7.2.0"
"@babel/polyfill" "^7.0.0"
"@babel/preset-env" "^7.0.0"
"@babel/runtime" "^7.2.0"
amd-name-resolver "^1.2.1"
babel-plugin-debug-macros "^0.3.0"
babel-plugin-ember-modules-api-polyfill "^2.12.0"
babel-plugin-module-resolver "^3.1.1"
broccoli-babel-transpiler "^7.3.0"
broccoli-debug "^0.6.4"
broccoli-funnel "^2.0.1"
broccoli-source "^1.1.0"
clone "^2.1.2"
ember-cli-babel-plugin-helpers "^1.1.0"
ember-cli-version-checker "^2.1.2"
ensure-posix-path "^1.0.2"
semver "^5.5.0"

ember-cli-broccoli-sane-watcher@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ember-cli-broccoli-sane-watcher/-/ember-cli-broccoli-sane-watcher-3.0.0.tgz#dc1812c047e1ceec4413d3c41b51a9ffc61b4cfe"
Expand Down Expand Up @@ -3296,6 +3347,11 @@ ember-resolver@^5.0.1:
ember-cli-version-checker "^3.0.0"
resolve "^1.10.0"

ember-rfc176-data@^0.3.12:
version "0.3.12"
resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.12.tgz#90d82878e69e2ac9a5438e8ce14d12c6031c5bd2"
integrity sha512-g9HeZj/gU5bfIIrGXkP7MhS2b3Vu5DfNUrYr14hy99TgIvtZETO+96QF4WOEUXGjIJdfTRjerVnQlqngPQSv1g==

ember-rfc176-data@^0.3.9:
version "0.3.9"
resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.9.tgz#44b6e051ead6c044ea87bd551f402e2cf89a7e3d"
Expand Down

0 comments on commit 2004ef9

Please sign in to comment.