Skip to content

Commit 5c30ee1

Browse files
committed
Use new inline babel plugin when we don't need modules api polyfill
1 parent 6b69fef commit 5c30ee1

7 files changed

Lines changed: 102 additions & 76 deletions

File tree

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('@ef4/babel-plugin-htmlbars-inline-precompile'),
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/utils_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('utils', function () {
159159
assert.strictEqual(utils.isInlinePrecompileBabelPluginRegistered(plugins), true);
160160
});
161161

162-
it('detects when the parallelizable version of the plugin has been installed', function () {
162+
it.only('detects when the parallelizable version of the plugin has been installed', function () {
163163
let plugins = [parallelizablePlugin];
164164

165165
assert.strictEqual(utils.isInlinePrecompileBabelPluginRegistered(plugins), true);

package.json

Lines changed: 1 addition & 1 deletion
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+
"@ef4/babel-plugin-htmlbars-inline-precompile": "^6.0.0-alpha.3",
3536
"@ember/edition-utils": "^1.2.0",
3637
"babel-plugin-htmlbars-inline-precompile": "^5.3.0",
3738
"broccoli-debug": "^0.6.5",
@@ -70,7 +71,6 @@
7071
"ember-cli-babel": "^7.25.0",
7172
"ember-cli-dependency-checker": "^3.2.0",
7273
"ember-cli-inject-live-reload": "^2.1.0",
73-
"ember-compatibility-helpers": "^1.2.2",
7474
"ember-export-application-global": "^2.0.1",
7575
"ember-load-initializers": "^2.1.1",
7676
"ember-maybe-import-regenerator": "^0.1.6",

tests/integration/components/test-inline-precompile-test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import hbsOne from 'htmlbars-inline-precompile';
55
import hbsTwo from 'ember-cli-htmlbars-inline-precompile';
66
import { hbs as hbsThree } from 'ember-cli-htmlbars';
77
import { precompileTemplate } from '@ember/template-compilation';
8-
import { hbs } from 'ember-template-imports';
9-
import { gte } from 'ember-compatibility-helpers';
108

119
module('tests/integration/components/test-inline-precompile', function (hooks) {
1210
setupRenderingTest(hooks);
@@ -35,24 +33,6 @@ module('tests/integration/components/test-inline-precompile', function (hooks) {
3533
assert.equal(this.element.textContent.trim(), 'Wheeeee');
3634
});
3735

38-
if (gte('3.25.0')) {
39-
test('template literal proposal works', async function (assert) {
40-
// eslint-disable-next-line no-undef
41-
const Bar = [GLIMMER_TEMPLATE('world')];
42-
43-
const Foo = hbs`Hello`;
44-
45-
await render(
46-
precompileTemplate(`<Foo/>, <Bar/>!`, {
47-
strictMode: true,
48-
scope: { Foo, Bar },
49-
})
50-
);
51-
52-
assert.equal(this.element.textContent.trim(), 'Hello, world!');
53-
});
54-
}
55-
5636
test('inline templates have "legacy" AST plugins ran', async function (assert) {
5737
await render(hbsThree('{{module-name-reverser}}', { moduleName: 'hello-template.hbs' }));
5838

yarn.lock

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,16 @@
10281028
exec-sh "^0.3.2"
10291029
minimist "^1.2.0"
10301030

1031+
"@ef4/babel-plugin-htmlbars-inline-precompile@^6.0.0-alpha.3":
1032+
version "6.0.0-alpha.3"
1033+
resolved "https://registry.yarnpkg.com/@ef4/babel-plugin-htmlbars-inline-precompile/-/babel-plugin-htmlbars-inline-precompile-6.0.0-alpha.3.tgz#9a1301f16bd0c4943ec36812b88434b86d188d74"
1034+
integrity sha512-PosYrbpYyEszLXKOAKbMbPOL7K/F9weut/VDAPWxjWJV/3i7wNx3E1bNVCAa24hb3IUKvj8dR8K0o+fJwJxaUA==
1035+
dependencies:
1036+
babel-import-util "^0.2.0"
1037+
line-column "^1.0.2"
1038+
magic-string "^0.25.7"
1039+
string.prototype.matchall "^4.0.5"
1040+
10311041
"@ember-data/rfc395-data@^0.0.4":
10321042
version "0.0.4"
10331043
resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843"
@@ -2001,6 +2011,11 @@ babel-helpers@^6.24.1:
20012011
babel-runtime "^6.22.0"
20022012
babel-template "^6.24.1"
20032013

2014+
babel-import-util@^0.2.0:
2015+
version "0.2.0"
2016+
resolved "https://registry.yarnpkg.com/babel-import-util/-/babel-import-util-0.2.0.tgz#b468bb679919601a3570f9e317536c54f2862e23"
2017+
integrity sha512-CtWYYHU/MgK88rxMrLfkD356dApswtR/kWZ/c6JifG1m10e7tBBrs/366dFzWMAoqYmG5/JSh+94tUSpIwh+ag==
2018+
20042019
babel-messages@^6.23.0:
20052020
version "6.23.0"
20062021
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
@@ -2015,7 +2030,7 @@ babel-plugin-check-es2015-constants@^6.22.0:
20152030
dependencies:
20162031
babel-runtime "^6.22.0"
20172032

2018-
babel-plugin-debug-macros@^0.2.0, babel-plugin-debug-macros@^0.2.0-beta.6:
2033+
babel-plugin-debug-macros@^0.2.0-beta.6:
20192034
version "0.2.0"
20202035
resolved "https://registry.yarnpkg.com/babel-plugin-debug-macros/-/babel-plugin-debug-macros-0.2.0.tgz#0120ac20ce06ccc57bf493b667cf24b85c28da7a"
20212036
integrity sha512-Wpmw4TbhR3Eq2t3W51eBAQSdKlr+uAyF0GI4GtPfMCD12Y4cIdpKC9l0RjNTH/P9isFypSqqewMPm7//fnZlNA==
@@ -4495,15 +4510,6 @@ ember-cli@~3.25.2:
44954510
workerpool "^6.0.3"
44964511
yam "^1.0.0"
44974512

4498-
ember-compatibility-helpers@^1.2.2:
4499-
version "1.2.2"
4500-
resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.2.tgz#839e0c24190b7a2ec8c39b80e030811b1a95b6d3"
4501-
integrity sha512-EKyCGOGBvKkBsk6wKfg3GhjTvTTkcEwzl/cv4VYvZM18cihmjGNpliR4BymWsKRWrv4VJLyq15Vhk3NHkSNBag==
4502-
dependencies:
4503-
babel-plugin-debug-macros "^0.2.0"
4504-
ember-cli-version-checker "^5.1.1"
4505-
semver "^5.4.1"
4506-
45074513
ember-export-application-global@^2.0.1:
45084514
version "2.0.1"
45094515
resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.1.tgz#b120a70e322ab208defc9e2daebe8d0dfc2dcd46"
@@ -4843,6 +4849,28 @@ es-abstract@^1.18.0-next.2:
48434849
string.prototype.trimstart "^1.0.4"
48444850
unbox-primitive "^1.0.0"
48454851

4852+
es-abstract@^1.18.2:
4853+
version "1.18.3"
4854+
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.3.tgz#25c4c3380a27aa203c44b2b685bba94da31b63e0"
4855+
integrity sha512-nQIr12dxV7SSxE6r6f1l3DtAeEYdsGpps13dR0TwJg1S8gyp4ZPgy3FZcHBgbiQqnoqSTb+oC+kO4UQ0C/J8vw==
4856+
dependencies:
4857+
call-bind "^1.0.2"
4858+
es-to-primitive "^1.2.1"
4859+
function-bind "^1.1.1"
4860+
get-intrinsic "^1.1.1"
4861+
has "^1.0.3"
4862+
has-symbols "^1.0.2"
4863+
is-callable "^1.2.3"
4864+
is-negative-zero "^2.0.1"
4865+
is-regex "^1.1.3"
4866+
is-string "^1.0.6"
4867+
object-inspect "^1.10.3"
4868+
object-keys "^1.1.1"
4869+
object.assign "^4.1.2"
4870+
string.prototype.trimend "^1.0.4"
4871+
string.prototype.trimstart "^1.0.4"
4872+
unbox-primitive "^1.0.1"
4873+
48464874
es-to-primitive@^1.2.1:
48474875
version "1.2.1"
48484876
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a"
@@ -6830,6 +6858,14 @@ is-regex@^1.1.2:
68306858
call-bind "^1.0.2"
68316859
has-symbols "^1.0.1"
68326860

6861+
is-regex@^1.1.3:
6862+
version "1.1.3"
6863+
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f"
6864+
integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==
6865+
dependencies:
6866+
call-bind "^1.0.2"
6867+
has-symbols "^1.0.2"
6868+
68336869
is-retry-allowed@^1.0.0, is-retry-allowed@^1.1.0:
68346870
version "1.2.0"
68356871
resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4"
@@ -6857,6 +6893,11 @@ is-string@^1.0.5:
68576893
resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6"
68586894
integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==
68596895

6896+
is-string@^1.0.6:
6897+
version "1.0.6"
6898+
resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.6.tgz#3fe5d5992fb0d93404f32584d4b0179a71b54a5f"
6899+
integrity sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==
6900+
68606901
is-symbol@^1.0.2:
68616902
version "1.0.2"
68626903
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38"
@@ -7910,7 +7951,8 @@ mocha@^8.4.0:
79107951
yargs-unparser "2.0.0"
79117952

79127953
"module-name-inliner@link:./tests/dummy/lib/module-name-inliner":
7913-
version "0.1.0"
7954+
version "0.0.0"
7955+
uid ""
79147956

79157957
morgan@^1.10.0:
79167958
version "1.10.0"
@@ -8175,6 +8217,11 @@ object-hash@^1.3.1:
81758217
resolved "https://registry.yarnpkg.com/object-hash/-/object-hash-1.3.1.tgz#fde452098a951cb145f039bb7d455449ddc126df"
81768218
integrity sha512-OSuu/pU4ENM9kmREg0BdNrUDIl1heYa4mBZacJc+vVWz4GtAwu7jO8s4AIt2aGRUTqxykpWzI3Oqnsm13tTMDA==
81778219

8220+
object-inspect@^1.10.3:
8221+
version "1.11.0"
8222+
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1"
8223+
integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==
8224+
81788225
object-inspect@^1.7.0:
81798226
version "1.7.0"
81808227
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67"
@@ -9923,6 +9970,20 @@ string.prototype.matchall@^4.0.4:
99239970
regexp.prototype.flags "^1.3.1"
99249971
side-channel "^1.0.4"
99259972

9973+
string.prototype.matchall@^4.0.5:
9974+
version "4.0.5"
9975+
resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.5.tgz#59370644e1db7e4c0c045277690cf7b01203c4da"
9976+
integrity sha512-Z5ZaXO0svs0M2xd/6By3qpeKpLKd9mO4v4q3oMEQrk8Ck4xOD5d5XeBOOjGrmVZZ/AHB1S0CgG4N5r1G9N3E2Q==
9977+
dependencies:
9978+
call-bind "^1.0.2"
9979+
define-properties "^1.1.3"
9980+
es-abstract "^1.18.2"
9981+
get-intrinsic "^1.1.1"
9982+
has-symbols "^1.0.2"
9983+
internal-slot "^1.0.3"
9984+
regexp.prototype.flags "^1.3.1"
9985+
side-channel "^1.0.4"
9986+
99269987
string.prototype.trimend@^1.0.4:
99279988
version "1.0.4"
99289989
resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80"
@@ -10413,7 +10474,7 @@ uglify-js@^3.1.4:
1041310474
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.13.5.tgz#5d71d6dbba64cf441f32929b1efce7365bb4f113"
1041410475
integrity sha512-xtB8yEqIkn7zmOyS2zUNBsYCBRhDkvlNxMMY2smuJ/qA8NCHeQvKCF3i9Z4k8FJH4+PJvZRtMrPynfZ75+CSZw==
1041510476

10416-
unbox-primitive@^1.0.0:
10477+
unbox-primitive@^1.0.0, unbox-primitive@^1.0.1:
1041710478
version "1.0.1"
1041810479
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"
1041910480
integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==

0 commit comments

Comments
 (0)