diff --git a/app/assets/javascripts/admin/package.json b/app/assets/javascripts/admin/package.json index fc492de38b5..d9d9c3b721f 100644 --- a/app/assets/javascripts/admin/package.json +++ b/app/assets/javascripts/admin/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0", "xss": "^1.0.14" }, diff --git a/app/assets/javascripts/dialog-holder/package.json b/app/assets/javascripts/dialog-holder/package.json index c152cc9c9ef..19a98c90fe3 100644 --- a/app/assets/javascripts/dialog-holder/package.json +++ b/app/assets/javascripts/dialog-holder/package.json @@ -11,7 +11,7 @@ "a11y-dialog": "7.5.2", "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1" + "ember-cli-htmlbars": "^6.2.0" }, "devDependencies": { "webpack": "^5.75.0" diff --git a/app/assets/javascripts/discourse-common/package.json b/app/assets/javascripts/discourse-common/package.json index 9d6379a1398..601c9033c8c 100644 --- a/app/assets/javascripts/discourse-common/package.json +++ b/app/assets/javascripts/discourse-common/package.json @@ -23,7 +23,7 @@ "@uppy/xhr-upload": "^3.1.0", "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "ember-resolver": "^8.0.3", "handlebars": "^4.7.0", "truth-helpers": "1.0.0", diff --git a/app/assets/javascripts/discourse-hbr/package.json b/app/assets/javascripts/discourse-hbr/package.json index 9e242720491..22585a07020 100644 --- a/app/assets/javascripts/discourse-hbr/package.json +++ b/app/assets/javascripts/discourse-hbr/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "handlebars": "^4.7.6", "webpack": "^5.75.0" }, diff --git a/app/assets/javascripts/discourse-js-processor.js b/app/assets/javascripts/discourse-js-processor.js index 0e038ec87fa..e642b5cacaf 100644 --- a/app/assets/javascripts/discourse-js-processor.js +++ b/app/assets/javascripts/discourse-js-processor.js @@ -2,7 +2,7 @@ // This is executed in mini_racer to provide the JS logic for lib/discourse_js_processor.rb -const makeEmberTemplateCompilerPlugin = +const HTMLBarsInlinePrecompile = require("babel-plugin-ember-template-compilation").default; const colocatedBabelPlugin = require("colocated-babel-plugin").default; const precompile = require("ember-template-compiler").precompile; @@ -38,9 +38,10 @@ function buildEmberTemplateManipulatorPlugin(themeId) { } function buildTemplateCompilerBabelPlugins({ themeId }) { - let compileFunction = precompile; + const compiler = { precompile }; + if (themeId) { - compileFunction = (src, opts) => { + compiler.precompile = (src, opts) => { return precompile(src, { ...opts, plugins: { @@ -54,8 +55,11 @@ function buildTemplateCompilerBabelPlugins({ themeId }) { colocatedBabelPlugin, require("widget-hbs-compiler").WidgetHbsCompiler, [ - makeEmberTemplateCompilerPlugin(() => compileFunction), - { enableLegacyModules: ["ember-cli-htmlbars"] }, + HTMLBarsInlinePrecompile, + { + compiler, + enableLegacyModules: ["ember-cli-htmlbars"], + }, ], ]; } diff --git a/app/assets/javascripts/discourse-plugins/package.json b/app/assets/javascripts/discourse-plugins/package.json index 2a82ec65eb9..49f90b7e453 100644 --- a/app/assets/javascripts/discourse-plugins/package.json +++ b/app/assets/javascripts/discourse-plugins/package.json @@ -13,7 +13,7 @@ "ember-auto-import": "^2.6.1", "ember-cli": "~3.28.5", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0" }, "devDependencies": { diff --git a/app/assets/javascripts/discourse-widget-hbs/package.json b/app/assets/javascripts/discourse-widget-hbs/package.json index 7141511c172..2b3db5c11c5 100644 --- a/app/assets/javascripts/discourse-widget-hbs/package.json +++ b/app/assets/javascripts/discourse-widget-hbs/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "handlebars": "^4.7.6", "webpack": "^5.75.0" }, diff --git a/app/assets/javascripts/discourse/package.json b/app/assets/javascripts/discourse/package.json index 57316f231ce..5a21e553ccf 100644 --- a/app/assets/javascripts/discourse/package.json +++ b/app/assets/javascripts/discourse/package.json @@ -59,7 +59,7 @@ "ember-cli-babel": "^7.26.10", "ember-cli-dependency-checker": "^3.3.1", "ember-cli-deprecation-workflow": "^2.1.0", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "ember-cli-inject-live-reload": "^2.1.0", "ember-cli-progress-ci": "1.0.0", "ember-cli-sri": "^2.1.1", diff --git a/app/assets/javascripts/pretty-text/package.json b/app/assets/javascripts/pretty-text/package.json index c0e39f6c649..054ba983c5b 100644 --- a/app/assets/javascripts/pretty-text/package.json +++ b/app/assets/javascripts/pretty-text/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0", "xss": "^1.0.14" }, diff --git a/app/assets/javascripts/select-kit/package.json b/app/assets/javascripts/select-kit/package.json index 52adacdda4e..709b62afe04 100644 --- a/app/assets/javascripts/select-kit/package.json +++ b/app/assets/javascripts/select-kit/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0" }, "devDependencies": { diff --git a/app/assets/javascripts/truth-helpers/package.json b/app/assets/javascripts/truth-helpers/package.json index a80317d411b..bc24d32f402 100644 --- a/app/assets/javascripts/truth-helpers/package.json +++ b/app/assets/javascripts/truth-helpers/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0" }, "devDependencies": { diff --git a/app/assets/javascripts/wizard/package.json b/app/assets/javascripts/wizard/package.json index f0e2066c1ec..4624b72c859 100644 --- a/app/assets/javascripts/wizard/package.json +++ b/app/assets/javascripts/wizard/package.json @@ -17,7 +17,7 @@ "dependencies": { "ember-auto-import": "^2.6.1", "ember-cli-babel": "^7.26.10", - "ember-cli-htmlbars": "^6.1.1", + "ember-cli-htmlbars": "^6.2.0", "webpack": "^5.75.0", "xss": "^1.0.14" }, diff --git a/app/assets/javascripts/yarn.lock b/app/assets/javascripts/yarn.lock index 88c70071605..6e765102905 100644 --- a/app/assets/javascripts/yarn.lock +++ b/app/assets/javascripts/yarn.lock @@ -2174,7 +2174,7 @@ available-typed-arrays@^1.0.5: resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== -babel-import-util@^1.1.0, babel-import-util@^1.2.0, babel-import-util@^1.2.2, babel-import-util@^1.3.0: +babel-import-util@^1.1.0, babel-import-util@^1.2.2, babel-import-util@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/babel-import-util/-/babel-import-util-1.3.0.tgz#dc9251ea39a7747bd586c1c13b8d785a42797f8e" integrity sha512-PPzUT17eAI18zn6ek1R3sB4Krc/MbnmT1MkZQFmyhjoaEGBVwNABhfVU9+EKcDSKrrOm9OIpGhjxukx1GCiy1g== @@ -2224,16 +2224,6 @@ babel-plugin-ember-modules-api-polyfill@^3.5.0: dependencies: ember-rfc176-data "^0.3.17" -babel-plugin-ember-template-compilation@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/babel-plugin-ember-template-compilation/-/babel-plugin-ember-template-compilation-1.0.2.tgz#e0695b8ad5a8fe6b2cbdff1eadb01cf402731ad6" - integrity sha512-4HBMksmlYsWEf/C/n3uW5rkBRbUp4FNaspzdQTAHgLbfCJnkLze8R6i6sUSge48y/Wne7mx+vcImI1o6rlUwXQ== - dependencies: - babel-import-util "^1.2.0" - line-column "^1.0.2" - magic-string "^0.26.0" - string.prototype.matchall "^4.0.5" - babel-plugin-ember-template-compilation@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/babel-plugin-ember-template-compilation/-/babel-plugin-ember-template-compilation-2.0.0.tgz#41d895874ba6119dd461f61993c16d1154bf8a57" @@ -3900,13 +3890,13 @@ ember-cli-htmlbars@^5.3.2, ember-cli-htmlbars@^5.7.1: strip-bom "^4.0.0" walk-sync "^2.2.0" -ember-cli-htmlbars@^6.1.1: - version "6.1.1" - resolved "https://registry.yarnpkg.com/ember-cli-htmlbars/-/ember-cli-htmlbars-6.1.1.tgz#f5b588572a5d18ad087560122b8dabc90145173d" - integrity sha512-DKf2rjzIVw9zWCuFsBGJScrgf5Mz7dSg08Cq+FWFYIxnpssINUbNUoB0NHWnUJK4QqCvaExOyOmjm0kO455CPg== +ember-cli-htmlbars@^6.1.1, ember-cli-htmlbars@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/ember-cli-htmlbars/-/ember-cli-htmlbars-6.2.0.tgz#18ec48ee1c93f9eed862a64eb24a9d14604f1dfc" + integrity sha512-j5EGixjGau23HrqRiW/JjoAovg5UBHfjbyN7wX5ekE90knIEqUUj1z/Mo/cTx/J2VepQ2lE6HdXW9LWQ/WdMtw== dependencies: "@ember/edition-utils" "^1.2.0" - babel-plugin-ember-template-compilation "^1.0.0" + babel-plugin-ember-template-compilation "^2.0.0" babel-plugin-htmlbars-inline-precompile "^5.3.0" broccoli-debug "^0.6.5" broccoli-persistent-filter "^3.1.2" @@ -6827,13 +6817,6 @@ magic-string@^0.25.7: dependencies: sourcemap-codec "^1.4.4" -magic-string@^0.26.0: - version "0.26.2" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.2.tgz#5331700e4158cd6befda738bb6b0c7b93c0d4432" - integrity sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A== - dependencies: - sourcemap-codec "^1.4.8" - make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" @@ -8631,7 +8614,7 @@ source-map@~0.1.x: dependencies: amdefine ">=0.0.4" -sourcemap-codec@^1.4.4, sourcemap-codec@^1.4.8: +sourcemap-codec@^1.4.4: version "1.4.8" resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== diff --git a/lib/discourse_js_processor.rb b/lib/discourse_js_processor.rb index d7bfb8abf42..cd81e6cc9f0 100644 --- a/lib/discourse_js_processor.rb +++ b/lib/discourse_js_processor.rb @@ -160,6 +160,16 @@ class DiscourseJsProcessor "node_modules/babel-plugin-ember-template-compilation/src/expression-parser.js", wrap_in_module: "babel-plugin-ember-template-compilation/expression-parser", ) + load_file_in_context( + ctx, + "node_modules/babel-plugin-ember-template-compilation/src/js-utils.js", + wrap_in_module: "babel-plugin-ember-template-compilation/js-utils", + ) + load_file_in_context( + ctx, + "node_modules/babel-plugin-ember-template-compilation/src/public-types.js", + wrap_in_module: "babel-plugin-ember-template-compilation/public-types", + ) load_file_in_context( ctx, "node_modules/babel-import-util/src/index.js", diff --git a/spec/lib/discourse_js_processor_spec.rb b/spec/lib/discourse_js_processor_spec.rb index 90748d3aae4..2ada7714f9a 100644 --- a/spec/lib/discourse_js_processor_spec.rb +++ b/spec/lib/discourse_js_processor_spec.rb @@ -121,7 +121,7 @@ RSpec.describe DiscourseJsProcessor do { "id": null, "block": "[[[1,[34,0]]],[],false,[\\"somevalue\\"]]", - "moduleName": "(unknown template module)", + "moduleName": "/blah/mymodule", "isStrictMode": false }); });