@norith/glimmerx-babel-preset 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +36 -0
- package/package.json +25 -0
- package/test/fixtures/debug/.babelrc +5 -0
- package/test/fixtures/debug/code.js +21 -0
- package/test/fixtures/debug/output.js +68 -0
- package/test/fixtures/production/.babelrc +5 -0
- package/test/fixtures/production/code.js +21 -0
- package/test/fixtures/production/output.js +68 -0
- package/test/index.js +19 -0
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function defaultTo(value, defaultVal) {
|
|
2
|
+
return value === undefined ? defaultVal : value;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
module.exports = function (api, options) {
|
|
6
|
+
let __loadPlugins = defaultTo(options.__loadPlugins, false);
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
[
|
|
11
|
+
__loadPlugins ? require('@glimmer/babel-preset') : require.resolve('@glimmer/babel-preset'),
|
|
12
|
+
{
|
|
13
|
+
...options,
|
|
14
|
+
__customInlineTemplateModules: {
|
|
15
|
+
// Support both the original and renamed import paths
|
|
16
|
+
// (consumer apps may use npm aliases to keep '@glimmerx/component')
|
|
17
|
+
'@glimmerx/component': {
|
|
18
|
+
export: 'hbs',
|
|
19
|
+
useTemplateLiteralProposalSemantics: 1,
|
|
20
|
+
},
|
|
21
|
+
'@norith/glimmerx-component': {
|
|
22
|
+
export: 'hbs',
|
|
23
|
+
useTemplateLiteralProposalSemantics: 1,
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
'TEMPLATE-TAG-MODULE': {
|
|
27
|
+
export: 'GLIMMER_TEMPLATE',
|
|
28
|
+
debugName: '<template>',
|
|
29
|
+
useTemplateTagProposalSemantics: 1,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@norith/glimmerx-babel-preset",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GlimmerX Babel Preset",
|
|
5
|
+
"repository": "https://github.com/snorith/glimmer-experimental",
|
|
6
|
+
"author": "Tom Dale <tom@tomdale.net>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"private": false,
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "mocha -r esm"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@norith/glimmer-babel-preset": "1.0.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"babel-plugin-tester": "^6.4.0",
|
|
17
|
+
"chai": "^4.2.0",
|
|
18
|
+
"esm": "^3.2.25",
|
|
19
|
+
"mocha": "^6.2.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEBUG } from '@glimmer/env';
|
|
2
|
+
import { assert, deprecate } from '@glimmer/debug';
|
|
3
|
+
import { tracked } from '@glimmerx/tracking';
|
|
4
|
+
import Component, { hbs } from '@norith/glimmerx-component';
|
|
5
|
+
|
|
6
|
+
if (DEBUG) {
|
|
7
|
+
console.log('DEBUG!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
assert(true, 'is true');
|
|
11
|
+
deprecate('this is deprecated', false, { id: 'foo' });
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default class Test extends Component {
|
|
15
|
+
@tracked bar = 123;
|
|
16
|
+
static template = hbs`Hello World`;
|
|
17
|
+
|
|
18
|
+
#cantTouchThis = 'mc hammer';
|
|
19
|
+
|
|
20
|
+
#hammerTime() {}
|
|
21
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var _class, _descriptor, _cantTouchThis, _hammerTime;
|
|
2
|
+
|
|
3
|
+
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 }); }
|
|
4
|
+
|
|
5
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
6
|
+
|
|
7
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
|
+
|
|
9
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
14
|
+
|
|
15
|
+
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.'); }
|
|
16
|
+
|
|
17
|
+
import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core";
|
|
18
|
+
import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core";
|
|
19
|
+
import { assert, deprecate } from '@glimmer/debug';
|
|
20
|
+
import { tracked } from '@glimmerx/tracking';
|
|
21
|
+
import Component from '@norith/glimmerx-component';
|
|
22
|
+
|
|
23
|
+
if (true
|
|
24
|
+
/* DEBUG */
|
|
25
|
+
) {
|
|
26
|
+
console.log('DEBUG!');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
(true && assert(true, 'is true'));
|
|
30
|
+
(true && !(false) && deprecate('this is deprecated', false, {
|
|
31
|
+
id: 'foo'
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
let Test = _setComponentTemplate(_createTemplateFactory(
|
|
35
|
+
/*
|
|
36
|
+
Hello World
|
|
37
|
+
*/
|
|
38
|
+
{
|
|
39
|
+
"id": null,
|
|
40
|
+
"block": "[[[1,\"Hello World\"]],[],false,[]]",
|
|
41
|
+
"moduleName": "(unknown template module)",
|
|
42
|
+
"isStrictMode": true
|
|
43
|
+
}), (_class = (_cantTouchThis = /*#__PURE__*/new WeakMap(), _hammerTime = /*#__PURE__*/new WeakSet(), class Test extends Component {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
|
|
47
|
+
_classPrivateMethodInitSpec(this, _hammerTime);
|
|
48
|
+
|
|
49
|
+
_initializerDefineProperty(this, "bar", _descriptor, this);
|
|
50
|
+
|
|
51
|
+
_classPrivateFieldInitSpec(this, _cantTouchThis, {
|
|
52
|
+
writable: true,
|
|
53
|
+
value: 'mc hammer'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "bar", [tracked], {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
initializer: function () {
|
|
62
|
+
return 123;
|
|
63
|
+
}
|
|
64
|
+
})), _class));
|
|
65
|
+
|
|
66
|
+
function _hammerTime2() {}
|
|
67
|
+
|
|
68
|
+
export { Test as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DEBUG } from '@glimmer/env';
|
|
2
|
+
import { assert, deprecate } from '@glimmer/debug';
|
|
3
|
+
import { tracked } from '@glimmerx/tracking';
|
|
4
|
+
import Component, { hbs } from '@norith/glimmerx-component';
|
|
5
|
+
|
|
6
|
+
if (DEBUG) {
|
|
7
|
+
console.log('DEBUG!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
assert(true, 'is true');
|
|
11
|
+
deprecate('this is deprecated', false, { id: 'foo' });
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default class Test extends Component {
|
|
15
|
+
@tracked bar = 123;
|
|
16
|
+
static template = hbs`Hello World`;
|
|
17
|
+
|
|
18
|
+
#cantTouchThis = 'mc hammer';
|
|
19
|
+
|
|
20
|
+
#hammerTime() {}
|
|
21
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var _class, _descriptor, _cantTouchThis, _hammerTime;
|
|
2
|
+
|
|
3
|
+
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 }); }
|
|
4
|
+
|
|
5
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
6
|
+
|
|
7
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
|
+
|
|
9
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
14
|
+
|
|
15
|
+
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.'); }
|
|
16
|
+
|
|
17
|
+
import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core";
|
|
18
|
+
import { createTemplateFactory as _createTemplateFactory } from "@glimmer/core";
|
|
19
|
+
import { assert, deprecate } from '@glimmer/debug';
|
|
20
|
+
import { tracked } from '@glimmerx/tracking';
|
|
21
|
+
import Component from '@norith/glimmerx-component';
|
|
22
|
+
|
|
23
|
+
if (false
|
|
24
|
+
/* DEBUG */
|
|
25
|
+
) {
|
|
26
|
+
console.log('DEBUG!');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
(false && assert(true, 'is true'));
|
|
30
|
+
(false && !(false) && deprecate('this is deprecated', false, {
|
|
31
|
+
id: 'foo'
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
let Test = _setComponentTemplate(_createTemplateFactory(
|
|
35
|
+
/*
|
|
36
|
+
Hello World
|
|
37
|
+
*/
|
|
38
|
+
{
|
|
39
|
+
"id": null,
|
|
40
|
+
"block": "[[[1,\"Hello World\"]],[],false,[]]",
|
|
41
|
+
"moduleName": "(unknown template module)",
|
|
42
|
+
"isStrictMode": true
|
|
43
|
+
}), (_class = (_cantTouchThis = /*#__PURE__*/new WeakMap(), _hammerTime = /*#__PURE__*/new WeakSet(), class Test extends Component {
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
|
|
47
|
+
_classPrivateMethodInitSpec(this, _hammerTime);
|
|
48
|
+
|
|
49
|
+
_initializerDefineProperty(this, "bar", _descriptor, this);
|
|
50
|
+
|
|
51
|
+
_classPrivateFieldInitSpec(this, _cantTouchThis, {
|
|
52
|
+
writable: true,
|
|
53
|
+
value: 'mc hammer'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "bar", [tracked], {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
initializer: function () {
|
|
62
|
+
return 123;
|
|
63
|
+
}
|
|
64
|
+
})), _class));
|
|
65
|
+
|
|
66
|
+
function _hammerTime2() {}
|
|
67
|
+
|
|
68
|
+
export { Test as default };
|
package/test/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import pluginTester from 'babel-plugin-tester';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
// For correct .babelrc detection inside the fixture directory we need to force babel's cwd and root to be the package root.
|
|
5
|
+
// This will ensure that the tests will run correctly from the mono repo root or package root.
|
|
6
|
+
const packageRootPath = path.resolve(__dirname, '..');
|
|
7
|
+
|
|
8
|
+
pluginTester({
|
|
9
|
+
plugin() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'dummy plugin',
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
babelOptions: {
|
|
15
|
+
cwd: packageRootPath,
|
|
16
|
+
root: packageRootPath,
|
|
17
|
+
},
|
|
18
|
+
fixtures: path.join(__dirname, 'fixtures'),
|
|
19
|
+
});
|