Skip to content

Commit fb505d0

Browse files
committed
Merge branch 'master' into pr-723
2 parents 56ce489 + 2e94551 commit fb505d0

File tree

13 files changed

+4722
-2781
lines changed

13 files changed

+4722
-2781
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
strategy:
3434
matrix:
3535
os: [ubuntu, windows]
36-
node-version: [10.x, 12.x, 13.x, 14.x]
36+
node-version: [12.x, 13.x, 14.x]
3737

3838
steps:
3939
- uses: actions/checkout@v1
@@ -89,7 +89,7 @@ jobs:
8989
- uses: actions/checkout@v1
9090
- uses: actions/setup-node@v1
9191
with:
92-
node-version: 10.x
92+
node-version: 12.x
9393
- name: install dependencies
9494
run: yarn install
9595
- name: test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
* Ember.js v3.8 or above
88
* Ember CLI v3.8 or above
9-
* Node.js v10 or above
9+
* Node.js v12 or above
1010

1111
## Tagged Template Usage / Migrating from `htmlbars-inline-precompile`
1212

ember-cli-build.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@ module.exports = function (defaults) {
4040
],
4141
],
4242
},
43-
44-
'ember-cli-htmlbars': {
45-
// This is an option intended to be used only be `ember-template-imports`.
46-
// DO NOT USE THIS
47-
_customInlineModules: {
48-
'ember-template-imports': {
49-
export: 'hbs',
50-
useTemplateLiteralProposalSemantics: 1,
51-
},
52-
53-
'TEMPLATE-TAG-MODULE': {
54-
export: 'GLIMMER_TEMPLATE',
55-
debugName: '<template>',
56-
useTemplateTagProposalSemantics: 1,
57-
},
58-
},
59-
},
6043
});
6144

6245
/*

lib/ember-addon-main.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,6 @@ module.exports = {
173173
let checker = new VersionChecker(this.parent).for('ember-source', 'npm');
174174
this._requiresModuleApiPolyfill = checker.exists() && checker.lt('3.27.0-alpha.1');
175175

176-
// This is an option intended to be used only be `ember-template-imports`.
177-
// DO NOT USE THIS
178-
let customModules =
179-
addonOptions['ember-cli-htmlbars'] && addonOptions['ember-cli-htmlbars']._customInlineModules;
180-
181176
// add the babel-plugin-htmlbars-inline-precompile to the list of plugins
182177
// used by `ember-cli-babel` addon
183178
if (!utils.isInlinePrecompileBabelPluginRegistered(babelPlugins)) {
@@ -194,7 +189,6 @@ module.exports = {
194189
this.projectConfig(),
195190
templateCompilerPath,
196191
isProduction,
197-
customModules,
198192
this._requiresModuleApiPolyfill
199193
);
200194

@@ -209,7 +203,6 @@ module.exports = {
209203
isProduction,
210204
projectConfig: this.projectConfig(),
211205
templateCompilerPath,
212-
modules: customModules,
213206
requiresModuleApiPolyfill: this._requiresModuleApiPolyfill,
214207
});
215208

lib/utils.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ function isInlinePrecompileBabelPluginRegistered(plugins) {
3737
typeof plugin === 'object' &&
3838
plugin._parallelBabel !== undefined
3939
) {
40-
return (
41-
plugin._parallelBabel.requireFile === require.resolve('./require-from-worker') &&
42-
typeof plugin._parallelBabel.params === 'object' &&
43-
typeof plugin._parallelBabel.params.modules === 'object' &&
44-
plugin._parallelBabel.params.modules['ember-cli-htmlbars'] === 'hbs'
45-
);
40+
return plugin._parallelBabel.requireFile === require.resolve('./require-from-worker');
4641
} else {
4742
return false;
4843
}
@@ -62,7 +57,6 @@ function buildParalleizedBabelPlugin(
6257
projectConfig,
6358
templateCompilerPath,
6459
isProduction,
65-
customModules,
6660
requiresModuleApiPolyfill
6761
) {
6862
let parallelBabelInfo = {
@@ -73,7 +67,6 @@ function buildParalleizedBabelPlugin(
7367
isProduction,
7468
projectConfig,
7569
parallelConfigs: pluginInfo.parallelConfigs,
76-
modules: Object.assign({}, customModules, INLINE_PRECOMPILE_MODULES),
7770
requiresModuleApiPolyfill,
7871
},
7972
};
@@ -262,16 +255,32 @@ function setup(pluginInfo, options) {
262255
cacheKey;
263256
};
264257

265-
let plugin = [
266-
require.resolve('babel-plugin-htmlbars-inline-precompile'),
267-
{
268-
precompile,
269-
isProduction: options.isProduction,
270-
ensureModuleApiPolyfill: options.requiresModuleApiPolyfill,
271-
modules: Object.assign({}, options.modules, INLINE_PRECOMPILE_MODULES),
272-
},
273-
'ember-cli-htmlbars:inline-precompile',
274-
];
258+
let plugin;
259+
if (options.requiresModuleApiPolyfill) {
260+
plugin = [
261+
require.resolve('babel-plugin-htmlbars-inline-precompile'),
262+
{
263+
precompile,
264+
isProduction: options.isProduction,
265+
ensureModuleApiPolyfill: options.requiresModuleApiPolyfill,
266+
modules: INLINE_PRECOMPILE_MODULES,
267+
},
268+
'ember-cli-htmlbars:inline-precompile',
269+
];
270+
} else {
271+
plugin = [
272+
require.resolve('babel-plugin-ember-template-compilation'),
273+
{
274+
precompile,
275+
enableLegacyModules: [
276+
'ember-cli-htmlbars',
277+
'ember-cli-htmlbars-inline-precompile',
278+
'htmlbars-inline-precompile',
279+
],
280+
},
281+
'ember-cli-htmlbars:inline-precompile',
282+
];
283+
}
275284

276285
return plugin;
277286
}

node-tests/colocated-babel-plugin-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ describe('ColocatedBabelPlugin', function () {
5252
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
5353
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
5454
55-
var _class, _descriptor, _temp;
55+
var _class, _descriptor;
5656
5757
import Component from '@glimmer/component';
5858
const __COLOCATED_TEMPLATE__ = 'ok';
59-
let MyComponent = (_class = (_temp = class MyComponent extends Component {
59+
let MyComponent = (_class = class MyComponent extends Component {
6060
constructor(...args) {
6161
super(...args);
6262
6363
_initializerDefineProperty(this, "data", _descriptor, this);
6464
}
6565
66-
}, _temp), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "data", [tracked], {
66+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "data", [tracked], {
6767
configurable: true,
6868
enumerable: true,
6969
writable: true,
@@ -224,19 +224,19 @@ describe('ColocatedBabelPlugin', function () {
224224
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
225225
import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
226226
227-
var _class, _descriptor, _temp;
227+
var _class, _descriptor;
228228
229229
import { setComponentTemplate as _setComponentTemplate } from "@ember/component";
230230
import Component from '@glimmer/component';
231231
const __COLOCATED_TEMPLATE__ = 'ok';
232-
let MyComponent = (_class = (_temp = class MyComponent extends Component {
232+
let MyComponent = (_class = class MyComponent extends Component {
233233
constructor(...args) {
234234
super(...args);
235235
236236
_initializerDefineProperty(this, "data", _descriptor, this);
237237
}
238238
239-
}, _temp), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "data", [tracked], {
239+
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "data", [tracked], {
240240
configurable: true,
241241
enumerable: true,
242242
writable: true,

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"test:node:debug": "mocha debug node-tests/*.js"
3333
},
3434
"dependencies": {
35+
"babel-plugin-ember-template-compilation": "^1.0.0",
3536
"@ember/edition-utils": "^1.2.0",
3637
"babel-plugin-htmlbars-inline-precompile": "^5.3.0",
3738
"broccoli-debug": "^0.6.5",
@@ -55,6 +56,7 @@
5556
"@babel/plugin-transform-typescript": "^7.10.1",
5657
"@babel/runtime": "^7.13.8",
5758
"@ember/optional-features": "^2.0.0",
59+
"@ember/test-helpers": "^2.4.2",
5860
"babel-eslint": "^10.1.0",
5961
"babel-plugin-debug-macros": "^0.3.3",
6062
"broccoli-merge-trees": "^4.2.0",
@@ -64,16 +66,16 @@
6466
"common-tags": "^1.8.0",
6567
"console-ui": "^3.1.2",
6668
"core-object": "^3.1.5",
69+
"ember-auto-import": "^2.2.0",
6770
"ember-cli": "~3.25.2",
6871
"ember-cli-app-version": "^4.0.0",
6972
"ember-cli-babel": "^7.25.0",
7073
"ember-cli-dependency-checker": "^3.2.0",
7174
"ember-cli-inject-live-reload": "^2.1.0",
72-
"ember-compatibility-helpers": "^1.2.2",
7375
"ember-export-application-global": "^2.0.1",
7476
"ember-load-initializers": "^2.1.1",
7577
"ember-maybe-import-regenerator": "^0.1.6",
76-
"ember-qunit": "^4.6.0",
78+
"ember-qunit": "^5.1.4",
7779
"ember-resolver": "^8.0.2",
7880
"ember-source": "~3.25.0",
7981
"ember-source-channel-url": "^3.0.0",
@@ -90,12 +92,14 @@
9092
"mocha": "^8.4.0",
9193
"module-name-inliner": "link:./tests/dummy/lib/module-name-inliner",
9294
"prettier": "^2.3.2",
93-
"qunit-dom": "^1.6.0",
95+
"qunit": "^2.17.2",
96+
"qunit-dom": "^2.0.0",
9497
"release-it": "^14.2.1",
95-
"release-it-lerna-changelog": "^3.1.0"
98+
"release-it-lerna-changelog": "^3.1.0",
99+
"webpack": "^5.58.2"
96100
},
97101
"engines": {
98-
"node": "10.* || >= 12.*"
102+
"node": ">= 12.*"
99103
},
100104
"publishConfig": {
101105
"registry": "https://registry.npmjs.org"

tests/dummy/lib/module-name-inliner/index.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
setupPreprocessorRegistry(type, registry) {
1111
// can only add the plugin with this style on newer Ember versions
1212
registry.add('htmlbars-ast-plugin', this.buildPlugin());
13-
registry.add('htmlbars-ast-plugin', this.buildLegacyPlugin());
1413
},
1514

1615
buildPlugin() {
@@ -44,42 +43,4 @@ module.exports = {
4443
},
4544
};
4645
},
47-
48-
// this type of plugin has worked since at least Ember 2.4+
49-
buildLegacyPlugin() {
50-
return {
51-
name: 'module-name-inliner',
52-
baseDir() {
53-
return __dirname;
54-
},
55-
parallelBabel: {
56-
requireFile: __filename,
57-
buildUsing: 'buildLegacyPlugin',
58-
params: {},
59-
},
60-
61-
plugin: class LegacyPlugin {
62-
constructor(options) {
63-
this.options = options;
64-
}
65-
66-
transform(ast) {
67-
let { meta } = this.options;
68-
let b = this.syntax.builders;
69-
70-
this.syntax.traverse(ast, {
71-
// replacing the mustache with text, like this
72-
// {{module-name-reverser}} -> `some-module-name`
73-
MustacheStatement(node) {
74-
if (node.path.original === 'module-name-reverser') {
75-
return b.text(meta.moduleName.split('').reverse().join(''));
76-
}
77-
},
78-
});
79-
80-
return ast;
81-
}
82-
},
83-
};
84-
},
8546
};

tests/index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
{{content-for "body"}}
2222
{{content-for "test-body"}}
2323

24+
<div id="qunit"></div>
25+
<div id="qunit-fixture">
26+
<div id="ember-testing-container">
27+
<div id="ember-testing"></div>
28+
</div>
29+
</div>
30+
2431
<script src="/testem.js" integrity=""></script>
2532
<script src="{{rootURL}}assets/vendor.js"></script>
2633
<script src="{{rootURL}}assets/test-support.js"></script>

tests/integration/components/ast-plugins-test.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@ import { hbs } from 'ember-cli-htmlbars';
66
module('tests/integration/components/ast-plugins-test', function (hooks) {
77
setupRenderingTest(hooks);
88

9-
test('stand alone templates have "legacy" AST plugins ran', async function (assert) {
10-
await render(hbs`{{x-module-name-reversed-component}}`);
11-
12-
assert.equal(
13-
this.element.textContent.trim(),
14-
'sbh.tnenopmoc-desrever-eman-eludom-x/stnenopmoc/setalpmet/ymmud'
15-
);
16-
});
17-
189
test('stand alone templates have AST plugins ran', async function (assert) {
1910
await render(hbs`{{x-module-name-inlined-component}}`);
2011

0 commit comments

Comments
 (0)