Skip to content

Commit

Permalink
why does it _want_ decorators-legacy enabled....
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Dec 7, 2018
1 parent 69873cc commit e2ca5be
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 91 deletions.
2 changes: 2 additions & 0 deletions broccoli/to-es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = function toES6(tree, _options) {
options.sourceMaps = true;
options.plugins = [
injectBabelHelpers,
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true, legacy: false }],
['@babel/plugin-proposal-class-properties'],
['@babel/transform-template-literals', { loose: true }],
['@babel/transform-literals'],
['@babel/transform-arrow-functions'],
Expand Down
28 changes: 15 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@
"resolve": "^1.6.0"
},
"devDependencies": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-proposal-decorators": "^7.2.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-block-scoping": "^7.2.0",
"@babel/plugin-transform-classes": "^7.2.0",
"@babel/plugin-transform-computed-properties": "^7.2.0",
"@babel/plugin-transform-destructuring": "^7.2.0",
"@babel/plugin-transform-literals": "^7.2.0",
"@babel/plugin-transform-modules-amd": "^7.2.0",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/plugin-transform-parameters": "^7.2.0",
"@babel/plugin-transform-shorthand-properties": "^7.2.0",
"@babel/plugin-transform-spread": "^7.2.0",
"@babel/plugin-transform-template-literals": "^7.2.0",
"@glimmer/compiler": "^0.36.4",
"@glimmer/env": "^0.1.7",
"@glimmer/interfaces": "^0.36.4",
Expand All @@ -92,19 +107,6 @@
"babel-plugin-debug-macros": "^0.2.0",
"babel-plugin-filter-imports": "^2.0.4",
"babel-plugin-module-resolver": "^3.1.1",
"@babel/helper-module-imports": "^7.0.0",
"@babel/plugin-transform-arrow-functions": "^7.2.0",
"@babel/plugin-transform-block-scoping": "^7.2.0",
"@babel/plugin-transform-classes": "^7.2.0",
"@babel/plugin-transform-computed-properties": "^7.2.0",
"@babel/plugin-transform-destructuring": "^7.2.0",
"@babel/plugin-transform-literals": "^7.2.0",
"@babel/plugin-transform-modules-amd": "^7.2.0",
"@babel/plugin-transform-parameters": "^7.2.0",
"@babel/plugin-transform-shorthand-properties": "^7.2.0",
"@babel/plugin-transform-spread": "^7.2.0",
"@babel/plugin-transform-template-literals": "^7.2.0",
"@babel/plugin-transform-object-assign": "^7.2.0",
"babel-template": "^6.26.0",
"backburner.js": "^2.4.2",
"broccoli-babel-transpiler": "^7.1.1",
Expand Down
92 changes: 30 additions & 62 deletions packages/@ember/-internals/metal/tests/computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,39 +989,27 @@ moduleFor(
}
);

function addComputedTo(klass, descriptor, dependents) {
let proto = klass.prototype;

Object.defineProperty(proto, name, descriptor);

let propertyDescriptor = Object.getOwnPropertyDescriptor(proto, name);

if (dependents) {
return computed(dependents)(proto, name, propertyDescriptor);
}

return computed(proto, name, propertyDescriptor);
}

moduleFor(
'computed - decorator - cacheable',
class extends AbstractTestCase {
beforeEach() {
class TestObj {}


count = 0;
let func = function() {
count++;
return 'bar ' + count;
};
addComputedTo(TestObj, {
key: 'foo',
descriptor: {
configurable: false,
enumerable: true,
get: func,
set: func,
},
});

class TestObj {
@computed()
get foo() {
return func();
}
set foo() {
return func();
}
}

obj = new TestObj();
}
Expand Down Expand Up @@ -1119,59 +1107,39 @@ moduleFor(
'computed - decorator',
class extends AbstractTestCase {
['@test computed property asserts the presence of a getter'](assert) {
class TestObj {}

assert.throws(() => {
addComputedTo(TestObj, {
key: 'nonGetter',
descriptor: {
configurable: false,
enumerable: true,
writeable: true,
value: () => true, // method
class TestObj {
@computed()
nonGetter() {
return true;
}
});
}

new TestObj();
}, /not a native accessor/);
}

['@test computed property works with a getter'](assert) {
class TestObj {}

addComputedTo(TestObj, {
key: 'someGetter',
descriptor: {
configurable: false,
get: () => true,
class TestObj {
@computed()
get someGetter() {
return true;
}
});
}

let instance = new TestObj();
assert.ok(instance.someGetter);
}

['@test computed property with dependent key and getter'](assert) {
class TestObj {}
class TestObj {
@computed() other = true;

addComputedTo(TestObj, {
key: 'other',
descriptor: {
value: true,
writable: true,
@computed('other')
get someGetter() {
return `${this.other}`;
}
});
addComputedTo(
TestObj,
{
key: 'someGetter',
descriptor: {
configurable: false,
get: function() {
return `${this.other}`;
},
}
},
'other'
);
}

let instance = new TestObj();
assert.equal(instance.someGetter, 'true');
Expand Down
54 changes: 38 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@
"@babel/traverse" "^7.1.0"
"@babel/types" "^7.0.0"

"@babel/helper-create-class-features-plugin@^7.2.1":
version "7.2.1"
resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.2.1.tgz#f6e8027291669ef64433220dc8327531233f1161"
integrity sha512-EsEP7XLFmcJHjcuFYBxYD1FkP0irC8C9fsrt2tX/jrAi/eTnFI6DOPgVFb+WREeg1GboF+Ib+nCHbGBodyAXSg==
dependencies:
"@babel/helper-function-name" "^7.1.0"
"@babel/helper-member-expression-to-functions" "^7.0.0"
"@babel/helper-optimise-call-expression" "^7.0.0"
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/helper-replace-supers" "^7.1.0"

"@babel/helper-define-map@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.1.0.tgz#3b74caec329b3c80c116290887c0dd9ae468c20c"
Expand Down Expand Up @@ -227,6 +238,24 @@
"@babel/helper-remap-async-to-generator" "^7.1.0"
"@babel/plugin-syntax-async-generators" "^7.2.0"

"@babel/plugin-proposal-class-properties@^7.2.1":
version "7.2.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.2.1.tgz#c734a53e0a1ec40fe5c22ee5069d26da3b187d05"
integrity sha512-/4FKFChkQ2Jgb8lBDsvFX496YTi7UWTetVgS8oJUpX1e/DlaoeEK57At27ug8Hu2zI2g8bzkJ+8k9qrHZRPGPA==
dependencies:
"@babel/helper-create-class-features-plugin" "^7.2.1"
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-proposal-decorators@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.2.0.tgz#6b4278282a6f5dd08b5d89b94f21aa1671fea071"
integrity sha512-yrDmvCsOMvNPpjCC6HMseiac2rUuQdeNqUyPU+3QbW7gLg/APX0c/7l9i/aulSICJQOkP6/4EHxkcB4d4DqZhg==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/helper-replace-supers" "^7.1.0"
"@babel/helper-split-export-declaration" "^7.0.0"
"@babel/plugin-syntax-decorators" "^7.2.0"

"@babel/plugin-proposal-json-strings@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz#568ecc446c6148ae6b267f02551130891e29f317"
Expand Down Expand Up @@ -267,6 +296,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-decorators@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.2.0.tgz#c50b1b957dcc69e4b1127b65e1c33eef61570c1b"
integrity sha512-38QdqVoXdHUQfTpZo3rQwqQdWtCn5tMv4uV6r2RMfTqNBuv4ZBhz79SfaQWKTVmxHjeFv/DnXVC/+agHCklYWA==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-syntax-json-strings@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz#72bd13f6ffe1d25938129d2a186b11fd62951470"
Expand Down Expand Up @@ -1362,11 +1398,6 @@ babel-plugin-syntax-async-functions@^6.8.0:
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
integrity sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=

babel-plugin-syntax-decorators@^6.1.18:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b"
integrity sha1-MSVjtNvePMgGzuPkFszurd0RrAs=

babel-plugin-syntax-exponentiation-operator@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de"
Expand All @@ -1386,15 +1417,6 @@ babel-plugin-transform-async-to-generator@^6.22.0:
babel-plugin-syntax-async-functions "^6.8.0"
babel-runtime "^6.22.0"

babel-plugin-transform-decorators-legacy@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-decorators-legacy/-/babel-plugin-transform-decorators-legacy-1.3.5.tgz#0e492dffa0edd70529072887f8aa86d4dd8b40a1"
integrity sha512-jYHwjzRXRelYQ1uGm353zNzf3QmtdCfvJbuYTZ4gKveK7M9H1fs3a5AKdY1JUDl0z97E30ukORW1dzhWvsabtA==
dependencies:
babel-plugin-syntax-decorators "^6.1.18"
babel-runtime "^6.2.0"
babel-template "^6.3.0"

babel-plugin-transform-es2015-arrow-functions@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221"
Expand Down Expand Up @@ -1667,15 +1689,15 @@ babel-register@^6.26.0:
mkdirp "^0.5.1"
source-map-support "^0.4.15"

babel-runtime@^6.18.0, babel-runtime@^6.2.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4=
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"

babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.3.0:
babel-template@^6.24.1, babel-template@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=
Expand Down

0 comments on commit e2ca5be

Please sign in to comment.