From db498bb05be9850a4040c851cd376d66e766d574 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Thu, 29 Apr 2021 14:37:39 -0400 Subject: [PATCH 1/3] bug repro: Association does not happen --- .../babel-preset/test/fixtures/debug/code.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js b/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js index 14b57928..fed4abcd 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js @@ -1,7 +1,7 @@ import { DEBUG } from '@glimmer/env'; import { assert, deprecate } from '@glimmer/debug'; -import { precompileTemplate } from '@glimmer/core'; -import { tracked } from '@glimmer/tracking'; +import { tracked } from '@glimmerx/tracking'; +import Component, { hbs } from '@glimmerx/component'; if (DEBUG) { console.log('DEBUG!'); @@ -11,12 +11,13 @@ assert(true, 'is true'); deprecate('this is deprecated', false, { id: 'foo' }); -class Test { +export default class Test extends Component { @tracked bar = 123; + static template = hbs`Hello World`; #cantTouchThis = 'mc hammer'; #hammerTime() {} -} -precompileTemplate('Hello, world!', { strictMode: true, scope: { Test } }); + +} From 706f7c71bdefbf9dd6218b5d70348197cc02d572 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Thu, 29 Apr 2021 14:42:44 -0400 Subject: [PATCH 2/3] what is expected --- packages/@glimmerx/babel-preset/test/fixtures/debug/output.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js b/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js index 747d30cd..3e101f9e 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js @@ -1,6 +1,6 @@ var _class, _descriptor, _cantTouchThis, _hammerTime; -import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core"; +import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } @@ -46,7 +46,7 @@ let Test = (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet( function _hammerTime2() {} -_createTemplateFactory( +_setComponentTemplate(Test, /* Hello, world! */ From 2d068bf99b6ec63042b0ca0d935fbeea3e40e77c Mon Sep 17 00:00:00 2001 From: Chris Garrett Date: Thu, 29 Apr 2021 11:58:14 -0700 Subject: [PATCH 3/3] fix tests --- .../babel-preset/test/fixtures/debug/.babelrc | 2 +- .../babel-preset/test/fixtures/debug/code.js | 2 - .../test/fixtures/debug/output.js | 38 ++++++++++--------- .../test/fixtures/production/.babelrc | 2 +- .../test/fixtures/production/code.js | 9 ++--- .../test/fixtures/production/output.js | 38 ++++++++++--------- 6 files changed, 48 insertions(+), 43 deletions(-) diff --git a/packages/@glimmerx/babel-preset/test/fixtures/debug/.babelrc b/packages/@glimmerx/babel-preset/test/fixtures/debug/.babelrc index c74aa0d9..3c3df58f 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/debug/.babelrc +++ b/packages/@glimmerx/babel-preset/test/fixtures/debug/.babelrc @@ -1,5 +1,5 @@ { "presets": [ - ["@glimmer/babel-preset", { "isDebug": true }] + ["@glimmerx/babel-preset", { "isDebug": true }] ] } diff --git a/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js b/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js index fed4abcd..f1054be7 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/debug/code.js @@ -18,6 +18,4 @@ export default class Test extends Component { #cantTouchThis = 'mc hammer'; #hammerTime() {} - - } diff --git a/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js b/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js index 3e101f9e..1be57fe7 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/debug/output.js @@ -1,7 +1,5 @@ var _class, _descriptor, _cantTouchThis, _hammerTime; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; - function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -10,8 +8,11 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } +import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; +import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core"; import { assert, deprecate } from '@glimmer/debug'; -import { tracked } from '@glimmer/tracking'; +import { tracked } from '@glimmerx/tracking'; +import Component from '@glimmerx/component'; if (true /* DEBUG */ @@ -23,8 +24,21 @@ if (true (true && !(false) && deprecate('this is deprecated', false, { id: 'foo' })); -let Test = (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet(), class Test { - constructor() { + +let Test = _setComponentTemplate(_createTemplateFactory( +/* + Hello World +*/ +{ + "id": null, + "block": "[[[1,\"Hello World\"]],[],false,[]]", + "moduleName": "(unknown template module)", + "scope": null, + "isStrictMode": true +}), (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet(), class Test extends Component { + constructor(...args) { + super(...args); + _hammerTime.add(this); _initializerDefineProperty(this, "bar", _descriptor, this); @@ -42,18 +56,8 @@ let Test = (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet( initializer: function () { return 123; } -})), _class); +})), _class)); function _hammerTime2() {} -_setComponentTemplate(Test, -/* - Hello, world! -*/ -{ - "id": null, - "block": "[[[1,\"Hello, world!\"]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}); +export { Test as default }; diff --git a/packages/@glimmerx/babel-preset/test/fixtures/production/.babelrc b/packages/@glimmerx/babel-preset/test/fixtures/production/.babelrc index 3b1e4c06..aad794ca 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/production/.babelrc +++ b/packages/@glimmerx/babel-preset/test/fixtures/production/.babelrc @@ -1,5 +1,5 @@ { "presets": [ - ["@glimmer/babel-preset", { "isDebug": false }] + ["@glimmerx/babel-preset", { "isDebug": false }] ] } diff --git a/packages/@glimmerx/babel-preset/test/fixtures/production/code.js b/packages/@glimmerx/babel-preset/test/fixtures/production/code.js index 14b57928..f1054be7 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/production/code.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/production/code.js @@ -1,7 +1,7 @@ import { DEBUG } from '@glimmer/env'; import { assert, deprecate } from '@glimmer/debug'; -import { precompileTemplate } from '@glimmer/core'; -import { tracked } from '@glimmer/tracking'; +import { tracked } from '@glimmerx/tracking'; +import Component, { hbs } from '@glimmerx/component'; if (DEBUG) { console.log('DEBUG!'); @@ -11,12 +11,11 @@ assert(true, 'is true'); deprecate('this is deprecated', false, { id: 'foo' }); -class Test { +export default class Test extends Component { @tracked bar = 123; + static template = hbs`Hello World`; #cantTouchThis = 'mc hammer'; #hammerTime() {} } - -precompileTemplate('Hello, world!', { strictMode: true, scope: { Test } }); diff --git a/packages/@glimmerx/babel-preset/test/fixtures/production/output.js b/packages/@glimmerx/babel-preset/test/fixtures/production/output.js index 5644a6f2..f04ce15d 100644 --- a/packages/@glimmerx/babel-preset/test/fixtures/production/output.js +++ b/packages/@glimmerx/babel-preset/test/fixtures/production/output.js @@ -1,7 +1,5 @@ var _class, _descriptor, _cantTouchThis, _hammerTime; -import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core"; - function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } @@ -10,8 +8,11 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } +import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; +import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core"; import { assert, deprecate } from '@glimmer/debug'; -import { tracked } from '@glimmer/tracking'; +import { tracked } from '@glimmerx/tracking'; +import Component from '@glimmerx/component'; if (false /* DEBUG */ @@ -23,8 +24,21 @@ if (false (false && !(false) && deprecate('this is deprecated', false, { id: 'foo' })); -let Test = (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet(), class Test { - constructor() { + +let Test = _setComponentTemplate(_createTemplateFactory( +/* + Hello World +*/ +{ + "id": null, + "block": "[[[1,\"Hello World\"]],[],false,[]]", + "moduleName": "(unknown template module)", + "scope": null, + "isStrictMode": true +}), (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet(), class Test extends Component { + constructor(...args) { + super(...args); + _hammerTime.add(this); _initializerDefineProperty(this, "bar", _descriptor, this); @@ -42,18 +56,8 @@ let Test = (_class = (_cantTouchThis = new WeakMap(), _hammerTime = new WeakSet( initializer: function () { return 123; } -})), _class); +})), _class)); function _hammerTime2() {} -_createTemplateFactory( -/* - Hello, world! -*/ -{ - "id": null, - "block": "[[[1,\"Hello, world!\"]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}); +export { Test as default };