From d6ebc48cd98c3edac8b0ce73d9b137c420293351 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Wed, 3 Dec 2025 14:38:26 -0500 Subject: [PATCH 01/14] Expanding ember-source test coverage --- .github/workflows/nodejs.yml | 3 + __tests__/all.test.ts | 13 +- .../raise-on-deprecated-template-compiler.ts | 8 ++ pnpm-lock.yaml | 131 ++++++++++-------- scripts/set-ember-version.mjs | 4 + 5 files changed, 94 insertions(+), 65 deletions(-) create mode 100644 __tests__/raise-on-deprecated-template-compiler.ts create mode 100644 scripts/set-ember-version.mjs diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 010af4d..fd8c59d 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -44,6 +44,7 @@ jobs: strategy: matrix: node: ['18', '20', '22'] + ember: ['~6.9.0', '6.10.0-beta.1'] os: ['ubuntu-latest', 'windows-latest'] runs-on: ${{ matrix.os }} steps: @@ -53,5 +54,7 @@ jobs: with: cache: 'pnpm' node-version: ${{ matrix.node }} + - name: Set ember version + run: node ./scripts/set-ember-version.mjs ${{ matrix.ember }} - run: pnpm install --no-lockfile - run: pnpm test diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index dcf461c..fe0771d 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -1,3 +1,4 @@ +import './raise-on-deprecated-template-compiler.js'; import path from 'path'; import * as babel from '@babel/core'; import HTMLBarsInlinePrecompile, { Options } from '../src/node-main.js'; @@ -14,18 +15,14 @@ import { Preprocessor } from 'content-tag'; import { ALLOWED_GLOBALS } from '../src/scope-locals.js'; import { fileURLToPath } from 'url'; import { describe, it, beforeEach, afterEach, expect, chai } from 'vitest'; -import { codeEquality } from 'code-equality-assertions/chai'; +import { codeEquality, type CodeEqualityAssertions } from 'code-equality-assertions/chai'; chai.use(codeEquality); -// @ts-expect-error no upstream types -import * as _compiler from 'ember-source/dist/ember-template-compiler.js'; - -const compiler: EmberTemplateCompiler = _compiler.default; +const compiler: EmberTemplateCompiler = // @ts-expect-error no upstream types + await import('ember-source/dist/ember-template-compiler.js'); declare module 'vitest' { - interface Assertion { - equalCode(expectedCode: string, message?: string): void; - } + interface Assertion extends CodeEqualityAssertions {} } describe('htmlbars-inline-precompile', function () { diff --git a/__tests__/raise-on-deprecated-template-compiler.ts b/__tests__/raise-on-deprecated-template-compiler.ts new file mode 100644 index 0000000..9cbd670 --- /dev/null +++ b/__tests__/raise-on-deprecated-template-compiler.ts @@ -0,0 +1,8 @@ +const orig = console.log; +console.log = function (message, ...rest) { + orig.call(this, `customized console.log for ${message}`); + if (message.includes('Your app is using the legacy ember-template-compiler.js AMD bundle')) { + throw new Error(`We tried to use the deprecated ember-template-compiler.js`); + } + return orig.call(this, message, ...rest); +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c716c5f..490861c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,7 +59,7 @@ importers: version: 7.18.0(eslint@8.57.1)(typescript@5.8.2) code-equality-assertions: specifier: ^1.0.1 - version: 1.0.1 + version: 1.1.0 common-tags: specifier: ^1.8.0 version: 1.8.2 @@ -71,7 +71,7 @@ importers: version: 7.0.3 ember-source: specifier: ^6.4.0-beta.1 - version: 6.4.0-beta.2(rsvp@4.8.5) + version: 6.9.0(rsvp@4.8.5) eslint: specifier: ^8.57.0 version: 8.57.1 @@ -844,8 +844,8 @@ packages: '@gar/promisify@1.1.3': resolution: {integrity: sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==} - '@glimmer/compiler@0.94.10': - resolution: {integrity: sha512-SrWiaKM3AND2FQ732wtjAKol7XhCnRqit3tJShG4X0mT27Jb3zuhTI2dkfYVVMTJ23pjT/+0y+s/uGaBSirnBg==} + '@glimmer/compiler@0.94.11': + resolution: {integrity: sha512-t9eyLZIFsiwAib8Zyfu67yBep5Vn2bd5DScIE2hharPE/OKKI7cpQYi6BzQhSGYEBVU82ITd/2TLvJ1K8eIahA==} engines: {node: '>= 18.0.0'} '@glimmer/destroyable@0.94.8': @@ -863,38 +863,41 @@ packages: '@glimmer/interfaces@0.94.6': resolution: {integrity: sha512-sp/1WePvB/8O+jrcUHwjboNPTKrdGicuHKA9T/lh0vkYK2qM5Xz4i25lQMQ38tEMiw7KixrjHiTUiaXRld+IwA==} - '@glimmer/manager@0.94.9': - resolution: {integrity: sha512-AQT90eSRbgx6O4VnyRgR+y3SqKChPrpZs5stENa0UnqOSbt7dF6XdqAmllfznKFpLlKmJSV7JaVpCarVTR/JQQ==} + '@glimmer/manager@0.94.10': + resolution: {integrity: sha512-Hqi92t6vtVg4nSRGWTvCJ+0Vg3iF1tiTG9RLzuUtZac7DIAzuQAxjhGbtu82miT+liCqU+MFmB3nkfNH0Zz74g==} - '@glimmer/node@0.94.9': - resolution: {integrity: sha512-X90Xyru/TNi/ocq27ttT4zlMGK931J+pGL0eDYEkUX2fJYHd9Wm1idAB7MLJYIJarv/kuoxteiGThGIYkeNVaQ==} + '@glimmer/node@0.94.10': + resolution: {integrity: sha512-8kw6K+RoKhjfprMO059M7x5yRZRK7WGLzD2056/G+65wV7gnJVDuh4qQirekaagjtskz6OdRBVWrSmrbICWtzQ==} - '@glimmer/opcode-compiler@0.94.9': - resolution: {integrity: sha512-LlBniSmtBoIlkxzPKHyOw4Nj946Cczelo8RAnqoG/egkHuk4hoO/7ycSgNpPvV3G14BA4Fpy5ExBffx6iuRxQQ==} + '@glimmer/opcode-compiler@0.94.10': + resolution: {integrity: sha512-KYsaODjkgtpUzMR1chyI0IRcvo4ewnjW8Dy+5833+OIG7rx6INl7HvKtooLzjHv+uJOZ74fd/s/0XfaY6eNEww==} '@glimmer/owner@0.93.4': resolution: {integrity: sha512-xoclaVdCF4JH/yx8dHplCj6XFAa7ggwc7cyeOthRvTNGsp/J/CNKHT6NEkdERBYqy6tvg5GoONvWFdm8Wd5Uig==} - '@glimmer/program@0.94.9': - resolution: {integrity: sha512-KA3TXYL2iDdR92pPnB/sw1tgIC7B40l2P60iD1sqkYbyxAbrUPHSToA1ycmK4DwmxDOT3Hz9dvpceoCMbh0xjA==} + '@glimmer/program@0.94.10': + resolution: {integrity: sha512-a5rpsvBwrcAn0boV4ONy+dHr8tWSTvLAPTR1T1KxF0OBHRVciCAfBPRFemVO6Q3H117At9ifn3uoevtQ6H0M+Q==} - '@glimmer/reference@0.94.8': - resolution: {integrity: sha512-FPoXBRMXJupO9nAq/Vw3EY/FCY3xbd+VALqZupyu6ds9vjNiKAkD9+ujIjYa1f+d/ez2ONhy8QjEFoBsyW2flA==} + '@glimmer/reference@0.94.9': + resolution: {integrity: sha512-qlgTYxgEOpgxuyb13u2qwqhibpfktlk08F+nfwuNxtuhodsItBi3YxjFMPrVP0zOjTnhUObR8OYtMsD5WFOddA==} - '@glimmer/runtime@0.94.10': - resolution: {integrity: sha512-eRe9TmP02ESVXJn2ZOOEm/Hm/Ro7X0kRvZsU8OVtXOqWU8JxeKMwjCEiLbJBQKbYfycRy1u8jZ2wuH0qM/d3EQ==} + '@glimmer/runtime@0.94.11': + resolution: {integrity: sha512-96PqfxnkEW8k8dMydDmaXgijD7yvtIfjMkHoJ7ljUmE1icZ7jj6f+UIZ0LThpXMzkKaBe1xEapjr91Ldsvmqbg==} '@glimmer/syntax@0.94.9': resolution: {integrity: sha512-OBw8DqMzKO4LX4kJBhwfTUqtpbd7O9amQXNTfb1aS7pufio5Vu5Qi6mRTfdFj6RyJ//aSI/l0kxWt6beYW0Apg==} + '@glimmer/syntax@0.95.0': + resolution: {integrity: sha512-W/PHdODnpONsXjbbdY9nedgIHpglMfOzncf/moLVrKIcCfeQhw2vG07Rs/YW8KeJCgJRCLkQsi+Ix7XvrurGAg==} + '@glimmer/util@0.94.8': resolution: {integrity: sha512-HfCKeZ74clF9BsPDBOqK/yRNa/ke6niXFPM6zRn9OVYw+ZAidLs7V8He/xljUHlLRL322kaZZY8XxRW7ALEwyg==} - '@glimmer/validator@0.94.8': - resolution: {integrity: sha512-vTP6hAcrxE5/0dG2w+tHSteXxgWmkBwMzu5ZTxMg+EkqthWl8B5r5skLiviQ6SdKAOBJGhzf6tF4ltHo5y83hQ==} + '@glimmer/validator@0.95.0': + resolution: {integrity: sha512-xF3K5voKeRqhONztfMHDd2wHDYD6UUI9pFPd+RMGtW6DXYv31G0zUm2pGsOwQ9dyNeE6khaXy7e3FtNjDrSmvQ==} - '@glimmer/vm-babel-plugins@0.93.4': - resolution: {integrity: sha512-+MjT+U/MsP7O32rXTYlvcmuiKtwI/PflokpVIW0M9wrkfFrsqgdhLQKvA+tNNxFW9LQ55zbhOtJweFNblHOvxg==} + '@glimmer/vm-babel-plugins@0.93.5': + resolution: {integrity: sha512-xwVRgDjuadOB9qV1jyTKBrUgE/cpmixD/wIYnFf4+hNJRD39urteKRPw98xJSAt7Bw/6y5B8zsgwFS18Nknlrg==} engines: {node: '>=18.18.0'} '@glimmer/vm@0.94.8': @@ -906,6 +909,10 @@ packages: '@handlebars/parser@2.0.0': resolution: {integrity: sha512-EP9uEDZv/L5Qh9IWuMUGJRfwhXJ4h1dqKTT4/3+tY0eu7sPis7xh23j61SYUnNF4vqCQvvUXpDo9Bh/+q1zASA==} + '@handlebars/parser@2.2.2': + resolution: {integrity: sha512-n/SZW+12rwikx/f8YcSv9JCi5p9vn1Bnts9ZtVvfErG4h0gbjHI1H1ZMhVUnaOC7yzFc6PtsCKIK8XeTnL90Gw==} + engines: {node: ^18 || ^20 || ^22 || >=24} + '@humanwhocodes/config-array@0.13.0': resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==} engines: {node: '>=10.10.0'} @@ -1828,8 +1835,8 @@ packages: resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==} engines: {node: '>=0.8'} - code-equality-assertions@1.0.1: - resolution: {integrity: sha512-QVoPdv5s17cGlCy2gd2Z0D9PXIYJd3VYilOK+6iTomzoel7xNUiIZOYYRNe3LbEncK0wuSJ9tvVByhySHrpO9w==} + code-equality-assertions@1.1.0: + resolution: {integrity: sha512-EoGPlzdu6iiL5N9HCnXN+rrYu8gsvhZBr4zHr1MIs7qLLYo29WxuLX+9tFDYAobLH82TWg8J4Ek/YiZXUvfq2g==} peerDependencies: '@types/jest': '2' '@types/qunit': '2' @@ -2075,8 +2082,8 @@ packages: resolution: {integrity: sha512-89oVHVJwmLDvGvAUWgS87KpBoRhy3aZ6U0Ql6HOmU4TrPkyaa8pM0W81wj9cIwjYprcQtN9EwzZMHnq46+oUyw==} engines: {node: 8.* || 10.* || >= 12} - ember-source@6.4.0-beta.2: - resolution: {integrity: sha512-lqH22QIPKOPCC5xuhoUR7/DooS1hKt73VjNe9QNi3euOWgwRcX+jgOu1y36xc9hj36oHlZ6SRIuphq4fnVIJRw==} + ember-source@6.9.0: + resolution: {integrity: sha512-d/P2/z5Y82/EEn95JRkwYy/JckZTCAgfZZC3dhWWzzXt5ZGHbHbAhole0c4wuUyYz42thM6isJa3C97b/1PdcA==} engines: {node: '>= 18.*'} peerDependencies: '@glimmer/component': '>= 1.1.2' @@ -5500,10 +5507,10 @@ snapshots: '@gar/promisify@1.1.3': {} - '@glimmer/compiler@0.94.10': + '@glimmer/compiler@0.94.11': dependencies: '@glimmer/interfaces': 0.94.6 - '@glimmer/syntax': 0.94.9 + '@glimmer/syntax': 0.95.0 '@glimmer/util': 0.94.8 '@glimmer/wire-format': 0.94.8 @@ -5526,61 +5533,61 @@ snapshots: '@simple-dom/interface': 1.4.0 type-fest: 4.38.0 - '@glimmer/manager@0.94.9': + '@glimmer/manager@0.94.10': dependencies: '@glimmer/destroyable': 0.94.8 '@glimmer/global-context': 0.93.4 '@glimmer/interfaces': 0.94.6 - '@glimmer/reference': 0.94.8 + '@glimmer/reference': 0.94.9 '@glimmer/util': 0.94.8 - '@glimmer/validator': 0.94.8 + '@glimmer/validator': 0.95.0 '@glimmer/vm': 0.94.8 - '@glimmer/node@0.94.9': + '@glimmer/node@0.94.10': dependencies: '@glimmer/interfaces': 0.94.6 - '@glimmer/runtime': 0.94.10 + '@glimmer/runtime': 0.94.11 '@glimmer/util': 0.94.8 '@simple-dom/document': 1.4.0 - '@glimmer/opcode-compiler@0.94.9': + '@glimmer/opcode-compiler@0.94.10': dependencies: '@glimmer/encoder': 0.93.8 '@glimmer/interfaces': 0.94.6 - '@glimmer/manager': 0.94.9 + '@glimmer/manager': 0.94.10 '@glimmer/util': 0.94.8 '@glimmer/vm': 0.94.8 '@glimmer/wire-format': 0.94.8 '@glimmer/owner@0.93.4': {} - '@glimmer/program@0.94.9': + '@glimmer/program@0.94.10': dependencies: '@glimmer/interfaces': 0.94.6 - '@glimmer/manager': 0.94.9 - '@glimmer/opcode-compiler': 0.94.9 + '@glimmer/manager': 0.94.10 + '@glimmer/opcode-compiler': 0.94.10 '@glimmer/util': 0.94.8 '@glimmer/vm': 0.94.8 '@glimmer/wire-format': 0.94.8 - '@glimmer/reference@0.94.8': + '@glimmer/reference@0.94.9': dependencies: '@glimmer/global-context': 0.93.4 '@glimmer/interfaces': 0.94.6 '@glimmer/util': 0.94.8 - '@glimmer/validator': 0.94.8 + '@glimmer/validator': 0.95.0 - '@glimmer/runtime@0.94.10': + '@glimmer/runtime@0.94.11': dependencies: '@glimmer/destroyable': 0.94.8 '@glimmer/global-context': 0.93.4 '@glimmer/interfaces': 0.94.6 - '@glimmer/manager': 0.94.9 + '@glimmer/manager': 0.94.10 '@glimmer/owner': 0.93.4 - '@glimmer/program': 0.94.9 - '@glimmer/reference': 0.94.8 + '@glimmer/program': 0.94.10 + '@glimmer/reference': 0.94.9 '@glimmer/util': 0.94.8 - '@glimmer/validator': 0.94.8 + '@glimmer/validator': 0.95.0 '@glimmer/vm': 0.94.8 '@glimmer/syntax@0.94.9': @@ -5591,16 +5598,24 @@ snapshots: '@handlebars/parser': 2.0.0 simple-html-tokenizer: 0.5.11 + '@glimmer/syntax@0.95.0': + dependencies: + '@glimmer/interfaces': 0.94.6 + '@glimmer/util': 0.94.8 + '@glimmer/wire-format': 0.94.8 + '@handlebars/parser': 2.2.2 + simple-html-tokenizer: 0.5.11 + '@glimmer/util@0.94.8': dependencies: '@glimmer/interfaces': 0.94.6 - '@glimmer/validator@0.94.8': + '@glimmer/validator@0.95.0': dependencies: '@glimmer/global-context': 0.93.4 '@glimmer/interfaces': 0.94.6 - '@glimmer/vm-babel-plugins@0.93.4(@babel/core@7.26.10)': + '@glimmer/vm-babel-plugins@0.93.5(@babel/core@7.26.10)': dependencies: babel-plugin-debug-macros: 0.3.4(@babel/core@7.26.10) transitivePeerDependencies: @@ -5616,6 +5631,8 @@ snapshots: '@handlebars/parser@2.0.0': {} + '@handlebars/parser@2.2.2': {} + '@humanwhocodes/config-array@0.13.0': dependencies: '@humanwhocodes/object-schema': 2.0.3 @@ -6705,7 +6722,7 @@ snapshots: clone@2.1.2: {} - code-equality-assertions@1.0.1: + code-equality-assertions@1.1.0: dependencies: '@babel/core': 7.26.10 '@babel/plugin-syntax-typescript': 7.25.9(@babel/core@7.26.10) @@ -6977,27 +6994,27 @@ snapshots: transitivePeerDependencies: - supports-color - ember-source@6.4.0-beta.2(rsvp@4.8.5): + ember-source@6.9.0(rsvp@4.8.5): dependencies: '@babel/core': 7.26.10 '@ember/edition-utils': 1.2.0 '@embroider/addon-shim': 1.9.0 - '@glimmer/compiler': 0.94.10 + '@glimmer/compiler': 0.94.11 '@glimmer/destroyable': 0.94.8 '@glimmer/global-context': 0.93.4 '@glimmer/interfaces': 0.94.6 - '@glimmer/manager': 0.94.9 - '@glimmer/node': 0.94.9 - '@glimmer/opcode-compiler': 0.94.9 + '@glimmer/manager': 0.94.10 + '@glimmer/node': 0.94.10 + '@glimmer/opcode-compiler': 0.94.10 '@glimmer/owner': 0.93.4 - '@glimmer/program': 0.94.9 - '@glimmer/reference': 0.94.8 - '@glimmer/runtime': 0.94.10 - '@glimmer/syntax': 0.94.9 + '@glimmer/program': 0.94.10 + '@glimmer/reference': 0.94.9 + '@glimmer/runtime': 0.94.11 + '@glimmer/syntax': 0.95.0 '@glimmer/util': 0.94.8 - '@glimmer/validator': 0.94.8 + '@glimmer/validator': 0.95.0 '@glimmer/vm': 0.94.8 - '@glimmer/vm-babel-plugins': 0.93.4(@babel/core@7.26.10) + '@glimmer/vm-babel-plugins': 0.93.5(@babel/core@7.26.10) '@simple-dom/interface': 1.4.0 backburner.js: 2.8.0 broccoli-file-creator: 2.1.1 diff --git a/scripts/set-ember-version.mjs b/scripts/set-ember-version.mjs new file mode 100644 index 0000000..f9e9694 --- /dev/null +++ b/scripts/set-ember-version.mjs @@ -0,0 +1,4 @@ +import fs from 'node:fs'; +let pkg = JSON.parse(fs.readFileSync('package.json')); +pkg.devDependencies['ember-source'] = process.argv[2]; +fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); From 2caba0046aa20f125bc9b580281ca702e09a17a5 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Thu, 4 Dec 2025 14:09:34 -0500 Subject: [PATCH 02/14] fail-fast false --- .github/workflows/nodejs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index fd8c59d..2e6640b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -42,6 +42,7 @@ jobs: floating-test: name: Floating dependencies strategy: + fail-fast: false matrix: node: ['18', '20', '22'] ember: ['~6.9.0', '6.10.0-beta.1'] From 77db5a44d7bb07d7f2e000fc7d11e17f7fd1706c Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 10:41:00 -0500 Subject: [PATCH 03/14] switch test mocking to vitest so it will work with our new module-based template compiler --- __tests__/all.test.ts | 181 +++++++++++++++--------------------------- package.json | 2 - pnpm-lock.yaml | 119 --------------------------- 3 files changed, 63 insertions(+), 239 deletions(-) diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index fe0771d..2bd192a 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -9,17 +9,30 @@ import TransformUnicodeEscapes from '@babel/plugin-transform-unicode-escapes'; import TransformTypescript from '@babel/plugin-transform-typescript'; import { stripIndent } from 'common-tags'; import { EmberTemplateCompiler } from '../src/ember-template-compiler.js'; -import sinon from 'sinon'; import { ExtendedPluginBuilder } from '../src/js-utils.js'; import { Preprocessor } from 'content-tag'; import { ALLOWED_GLOBALS } from '../src/scope-locals.js'; import { fileURLToPath } from 'url'; -import { describe, it, beforeEach, afterEach, expect, chai } from 'vitest'; +import { describe, it, beforeEach, afterEach, expect, chai, vi, type Mock } from 'vitest'; import { codeEquality, type CodeEqualityAssertions } from 'code-equality-assertions/chai'; + chai.use(codeEquality); -const compiler: EmberTemplateCompiler = // @ts-expect-error no upstream types - await import('ember-source/dist/ember-template-compiler.js'); +let precompileSpy: Mock; + +async function mockTemplateCompiler(importOriginal: () => Promise) { + const mod = await importOriginal(); + precompileSpy = vi.spyOn(mod, 'precompile'); + return { + // the plugin probes for the existence of this, and if we don't stick a key + // here Vitest injects a failure + default: null, + ...mod, + }; +} + +vi.mock('ember-source/ember-template-compiler/index.js', mockTemplateCompiler); +vi.mock('ember-source/dist/ember-template-compiler.js', mockTemplateCompiler); declare module 'vitest' { interface Assertion extends CodeEqualityAssertions {} @@ -37,17 +50,20 @@ describe('htmlbars-inline-precompile', function () { } beforeEach(function () { - plugins = [[HTMLBarsInlinePrecompile, { compiler }]]; + plugins = [[HTMLBarsInlinePrecompile, {}]]; }); afterEach(function () { - sinon.restore(); + vi.resetAllMocks(); }); it('supports compilation that returns a non-JSON.parseable object', async function () { - sinon.replace(compiler, 'precompile', (template) => { - return `function() { return "${template}"; }`; - }); + plugins = [ + [ + HTMLBarsInlinePrecompile, + { compilerPath: fileURLToPath(new URL('./mock-precompile', import.meta.url)) }, + ], + ]; let transpiled = await transform( "import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('hello');" @@ -59,9 +75,8 @@ describe('htmlbars-inline-precompile', function () { /* hello */ - function () { - return "hello"; - }); + precompiledFromPath(hello) + ) `); }); @@ -89,35 +104,32 @@ describe('htmlbars-inline-precompile', function () { it('passes options when used as a call expression', async function () { let source = 'hello'; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}');` ); - expect(spy.firstCall.lastArg).toHaveProperty('contents', source); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('contents', source); }); it('uses the user provided isProduction option if present', async function () { let source = 'hello'; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { isProduction: true });` ); - expect(spy.firstCall.lastArg).toHaveProperty('isProduction', true); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('isProduction', true); }); it('allows a template string literal when used as a call expression', async function () { let source = 'hello'; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate(\`${source}\`);` ); - expect(spy.firstCall.lastArg).toHaveProperty('contents', source); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('contents', source); }); it('errors when the template string contains placeholders', async function () { @@ -133,7 +145,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['htmlbars-inline-precompile'], }, ], @@ -145,7 +156,6 @@ describe('htmlbars-inline-precompile', function () { it('allows static userland options when used as a call expression', async function () { let source = 'hello'; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { parseOptions: { srcName: 'bar.hbs' }, moduleName: 'foo/bar.hbs', xyz: 123, qux: true, stringifiedThing: ${JSON.stringify( @@ -153,39 +163,18 @@ describe('htmlbars-inline-precompile', function () { )}});` ); - expect(spy.firstCall.lastArg).toHaveProperty('parseOptions', { srcName: 'bar.hbs' }); - expect(spy.firstCall.lastArg).toHaveProperty('moduleName', 'foo/bar.hbs'); - expect(spy.firstCall.lastArg).toHaveProperty('xyz', 123); - expect(spy.firstCall.lastArg).toHaveProperty('qux', true); - expect(spy.firstCall.lastArg).toHaveProperty('stringifiedThing', { foo: 'baz' }); - }); - - it('adds a comment with the original template string', async function () { - sinon.replace(compiler, 'precompile', (template) => { - return `precompiled("${template}")`; - }); - - let transformed = await transform(stripIndent` - import { precompileTemplate } from '@ember/template-compilation'; - if ('foo') { - const template = precompileTemplate('hello'); - } - `); - - expect(transformed).toEqual(stripIndent` - import { createTemplateFactory } from "@ember/template-factory"; - if ('foo') { - const template = createTemplateFactory( - /* - hello - */ - precompiled("hello")); - } - `); + let lastArg = precompileSpy.mock.lastCall?.at(-1); + expect(lastArg).toHaveProperty('parseOptions', { srcName: 'bar.hbs' }); + expect(lastArg).toHaveProperty('moduleName', 'foo/bar.hbs'); + expect(lastArg).toHaveProperty('xyz', 123); + expect(lastArg).toHaveProperty('qux', true); + expect(lastArg).toHaveProperty('stringifiedThing', { foo: 'baz' }); }); it('avoids a build time error when passed `insertRuntimeErrors`', async function () { - sinon.stub(compiler, 'precompile').throws(new Error('NOOOOOOOOOOOOOOOOOOOOOO')); + precompileSpy.mockImplementation(() => { + throw new Error('NOOOOOOOOOOOOOOOOOOOOOO'); + }); let transformed = await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('hello', { insertRuntimeErrors: true });` @@ -199,11 +188,9 @@ describe('htmlbars-inline-precompile', function () { }); it('escapes any */ included in the template string', async function () { - plugins = [ - [HTMLBarsInlinePrecompile, { compiler, enableLegacyModules: ['htmlbars-inline-precompile'] }], - ]; + plugins = [[HTMLBarsInlinePrecompile, { enableLegacyModules: ['htmlbars-inline-precompile'] }]]; - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -228,18 +215,15 @@ describe('htmlbars-inline-precompile', function () { }); it('passes options when used as a tagged template string', async function () { - plugins = [ - [HTMLBarsInlinePrecompile, { compiler, enableLegacyModules: ['htmlbars-inline-precompile'] }], - ]; + plugins = [[HTMLBarsInlinePrecompile, { enableLegacyModules: ['htmlbars-inline-precompile'] }]]; let source = 'hello'; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs\`${source}\`;` ); - expect(spy.firstCall.lastArg).toHaveProperty('contents', source); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('contents', source); }); it("strips import statement for '@ember/template-precompilation' module", async function () { @@ -252,7 +236,7 @@ describe('htmlbars-inline-precompile', function () { }); it('replaces tagged template expressions with precompiled version', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -260,7 +244,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['htmlbars-inline-precompile'], }, ], @@ -280,7 +263,7 @@ describe('htmlbars-inline-precompile', function () { }); it('replaces tagged template expressions with precompiled version when ember-cli-htmlbars is enabled', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -288,7 +271,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['ember-cli-htmlbars'], }, ], @@ -325,7 +307,7 @@ describe('htmlbars-inline-precompile', function () { }); it('works with multiple imports', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -356,8 +338,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, - targetFormat: 'wire', enableLegacyModules: [ 'ember-cli-htmlbars', @@ -437,7 +417,7 @@ describe('htmlbars-inline-precompile', function () { }); it('works properly when used along with modules transform', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -467,7 +447,7 @@ describe('htmlbars-inline-precompile', function () { }); it('does not error when reusing a preexisting import', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -490,7 +470,7 @@ describe('htmlbars-inline-precompile', function () { }); it('works properly when used after modules transform', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -513,7 +493,7 @@ describe('htmlbars-inline-precompile', function () { }); it('works properly when used along with @babel/plugin-transform-unicode-escapes', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -533,7 +513,7 @@ describe('htmlbars-inline-precompile', function () { }); it('replaces tagged template expressions when before babel-plugin-transform-es2015-template-literals', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -541,7 +521,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['htmlbars-inline-precompile'], }, ], @@ -567,7 +546,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['htmlbars-inline-precompile'], }, ], @@ -585,7 +563,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, enableLegacyModules: ['htmlbars-inline-precompile'], }, ], @@ -598,7 +575,7 @@ describe('htmlbars-inline-precompile', function () { }); it('works with glimmer modules', async function () { - sinon.replace(compiler, 'precompile', (template) => { + precompileSpy.mockImplementation((template) => { return `precompiled("${template}")`; }); @@ -606,7 +583,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, outputModuleOverrides: { '@ember/template-factory': { createTemplateFactory: ['createTemplateFactory', '@glimmer/core'], @@ -764,7 +740,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, transforms: [expressionTransform], }, ], @@ -820,7 +795,7 @@ describe('htmlbars-inline-precompile', function () { it('JS import added by ast transform survives typescript interoperability, in wire targetFormat', async function () { plugins = [ - [HTMLBarsInlinePrecompile, { targetFormat: 'wire', compiler, transforms: [importTransform] }], + [HTMLBarsInlinePrecompile, { targetFormat: 'wire', transforms: [importTransform] }], TransformTypescript, ]; @@ -1239,7 +1214,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', transforms: [color], enableLegacyModules: ['ember-cli-htmlbars'], @@ -1262,7 +1236,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', transforms: [color], enableLegacyModules: ['ember-cli-htmlbars'], @@ -1393,7 +1366,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', transforms: [expressionTransform], enableLegacyModules: ['ember-cli-htmlbars'], @@ -1422,7 +1394,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', transforms: [expressionTransform], enableLegacyModules: ['ember-cli-htmlbars'], @@ -1711,7 +1682,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'wire', transforms: [], }, @@ -1749,7 +1719,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'wire', transforms: [], }, @@ -1797,54 +1766,49 @@ describe('htmlbars-inline-precompile', function () { describe('scope', function () { it('correctly handles scope function (non-block arrow function)', async function () { let source = ''; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { scope: () => ({ foo, bar }) });` ); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('correctly handles scope function (block arrow function)', async function () { let source = ''; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { scope: () => { return { foo, bar }; }});` ); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('correctly handles scope function (normal function)', async function () { let source = ''; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { scope: function() { return { foo, bar }; }});` ); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('correctly handles scope function (object method)', async function () { let source = ''; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { scope() { return { foo, bar }; }});` ); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('correctly handles scope function with coverage', async function () { let source = ''; - let spy = sinon.spy(compiler, 'precompile'); await transform( `import { precompileTemplate } from '@ember/template-compilation';\nvar compiled = precompileTemplate('${source}', { scope() { ++cov_2rkfh72wo; return { foo, bar }; }});` ); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('correctly handles scope if it contains keys and values', async function () { @@ -1895,34 +1859,31 @@ describe('htmlbars-inline-precompile', function () { }); it('correctly removes not used scope', async function () { - let spy = sinon.spy(compiler, 'precompile'); await transform(` import { precompileTemplate } from '@ember/template-compilation'; let foo, bar; var compiled = precompileTemplate('', { scope: () => ({ foo, bar, baz }) }); `); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['foo', 'bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['foo', 'bar']); }); it('does not automagically add to scope when not using implicit-scope-form', async function () { - let spy = sinon.spy(compiler, 'precompile'); await transform(` import { precompileTemplate } from '@ember/template-compilation'; let foo, bar; var compiled = precompileTemplate('', { scope: () => ({ bar }) }); `); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['bar']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['bar']); }); it('can pass lexically scoped "this"', async function () { - let spy = sinon.spy(compiler, 'precompile'); let transformed = await transform(` import { precompileTemplate } from '@ember/template-compilation'; export function example() { return precompileTemplate('{{this.message}}', { scope: () => ({ "this": this }) }); } `); - expect(spy.firstCall.lastArg).toHaveProperty('locals', ['this']); + expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['this']); expect(normalizeWireFormat(transformed)).equalCode(` import { createTemplateFactory } from "@ember/template-factory"; export function example() { @@ -1949,7 +1910,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -1978,7 +1938,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2011,7 +1970,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2038,7 +1996,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2065,7 +2022,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2111,7 +2067,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2154,7 +2109,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2195,7 +2149,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2254,7 +2207,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2279,7 +2231,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'wire', }, ], @@ -2320,7 +2271,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2348,7 +2298,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2390,7 +2339,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'wire', }, ], @@ -2435,7 +2383,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2465,7 +2412,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2498,7 +2444,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2533,7 +2478,6 @@ describe('htmlbars-inline-precompile', function () { [ HTMLBarsInlinePrecompile, { - compiler, targetFormat: 'hbs', }, ], @@ -2572,5 +2516,6 @@ describe('htmlbars-inline-precompile', function () { function normalizeWireFormat(src: string): string { return src .replace(/"moduleName":\s"[^"]+"/, '"moduleName": ""') - .replace(/"id":\s"[^"]+"/, '"id": ""'); + .replace(/"id":\s"[^"]+"/, '"id": ""') + .replace(`"id": null`, '"id": ""'); } diff --git a/package.json b/package.json index 8eee1a7..26911a3 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "@types/babel__core": "^7.20.1", "@types/babel__traverse": "^7.11.1", "@types/node": "^20.5.7", - "@types/sinon": "^10.0.13", "@typescript-eslint/eslint-plugin": "^7.14.1", "@typescript-eslint/parser": "^7.14.1", "code-equality-assertions": "^1.0.1", @@ -58,7 +57,6 @@ "release-it": "^14.10.0", "release-it-lerna-changelog": "^3.1.0", "release-plan": "^0.16.0", - "sinon": "^14.0.0", "typescript": "^5.8.2", "vitest": "^4.0.15" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 490861c..88e1cbf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,9 +48,6 @@ importers: '@types/node': specifier: ^20.5.7 version: 20.17.27 - '@types/sinon': - specifier: ^10.0.13 - version: 10.0.20 '@typescript-eslint/eslint-plugin': specifier: ^7.14.1 version: 7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.8.2))(eslint@8.57.1)(typescript@5.8.2) @@ -96,9 +93,6 @@ importers: release-plan: specifier: ^0.16.0 version: 0.16.0 - sinon: - specifier: ^14.0.0 - version: 14.0.2 typescript: specifier: ^5.8.2 version: 5.8.2 @@ -1239,27 +1233,6 @@ packages: resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} engines: {node: '>=18'} - '@sinonjs/commons@1.8.6': - resolution: {integrity: sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==} - - '@sinonjs/commons@2.0.0': - resolution: {integrity: sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==} - - '@sinonjs/commons@3.0.1': - resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} - - '@sinonjs/fake-timers@11.3.1': - resolution: {integrity: sha512-EVJO7nW5M/F5Tur0Rf2z/QoMo+1Ia963RiMtapiQrEWvY0iBUvADo8Beegwjpnle5BHkyHuoxSTW3jF43H1XRA==} - - '@sinonjs/fake-timers@9.1.2': - resolution: {integrity: sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==} - - '@sinonjs/samsam@7.0.1': - resolution: {integrity: sha512-zsAk2Jkiq89mhZovB2LLOdTCxJF4hqqTToGP0ASWlhp4I1hqOjcfmZGafXntCN7MDC6yySH0mFHrYtHceOeLmw==} - - '@sinonjs/text-encoding@0.7.3': - resolution: {integrity: sha512-DE427ROAphMQzU4ENbliGYrBSYPXF+TtLg9S8vzeA+OF4ZKzoDdzfL8sxuMUGS/lgRhM6j1URSk9ghf7Xo1tyA==} - '@standard-schema/spec@1.0.0': resolution: {integrity: sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==} @@ -1310,12 +1283,6 @@ packages: '@types/responselike@1.0.3': resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} - '@types/sinon@10.0.20': - resolution: {integrity: sha512-2APKKruFNCAZgx3daAyACGzWuJ028VVCUDk6o2rw/Z4PXT0ogwdV4KUegW0MwVs0Zu59auPXbbuBJHF12Sx1Eg==} - - '@types/sinonjs__fake-timers@8.1.5': - resolution: {integrity: sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==} - '@types/symlink-or-copy@1.2.2': resolution: {integrity: sha512-MQ1AnmTLOncwEf9IVU+B2e4Hchrku5N67NkgcAHW0p3sdzPe0FNMANxEm6OJUzPniEQGkeT3OROLlCwZJLWFZA==} @@ -3054,9 +3021,6 @@ packages: jsonify@0.0.1: resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==} - just-extend@6.2.0: - resolution: {integrity: sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==} - keyv@3.1.0: resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==} @@ -3102,10 +3066,6 @@ packages: lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} - lodash.get@4.4.2: - resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==} - deprecated: This package is deprecated. Use the optional chaining (?.) operator instead. - lodash.merge@4.6.2: resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} @@ -3312,9 +3272,6 @@ packages: nice-try@1.0.5: resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - nise@5.1.9: - resolution: {integrity: sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww==} - node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -3555,9 +3512,6 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} - path-to-regexp@6.3.0: - resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} - path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -4019,10 +3973,6 @@ packages: simple-html-tokenizer@0.5.11: resolution: {integrity: sha512-C2WEK/Z3HoSFbYq8tI7ni3eOo/NneSPRoPpcM7WdLjFOArFuyXEjAoCdOC3DgMfRyziZQ1hCNR4mrNdWEvD0og==} - sinon@14.0.2: - resolution: {integrity: sha512-PDpV0ZI3ZCS3pEqx0vpNp6kzPhHrLx72wA0G+ZLaaJjLIYeE0n8INlgaohKuGy7hP0as5tbUd23QWu5U233t+w==} - deprecated: 16.1.1 - slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -4279,14 +4229,6 @@ packages: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} - type-detect@4.0.8: - resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} - engines: {node: '>=4'} - - type-detect@4.1.0: - resolution: {integrity: sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==} - engines: {node: '>=4'} - type-fest@0.20.2: resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} engines: {node: '>=10'} @@ -5971,34 +5913,6 @@ snapshots: '@sindresorhus/merge-streams@4.0.0': {} - '@sinonjs/commons@1.8.6': - dependencies: - type-detect: 4.0.8 - - '@sinonjs/commons@2.0.0': - dependencies: - type-detect: 4.0.8 - - '@sinonjs/commons@3.0.1': - dependencies: - type-detect: 4.0.8 - - '@sinonjs/fake-timers@11.3.1': - dependencies: - '@sinonjs/commons': 3.0.1 - - '@sinonjs/fake-timers@9.1.2': - dependencies: - '@sinonjs/commons': 1.8.6 - - '@sinonjs/samsam@7.0.1': - dependencies: - '@sinonjs/commons': 2.0.0 - lodash.get: 4.4.2 - type-detect: 4.1.0 - - '@sinonjs/text-encoding@0.7.3': {} - '@standard-schema/spec@1.0.0': {} '@szmarczak/http-timer@1.1.2': @@ -6057,12 +5971,6 @@ snapshots: dependencies: '@types/node': 20.17.27 - '@types/sinon@10.0.20': - dependencies: - '@types/sinonjs__fake-timers': 8.1.5 - - '@types/sinonjs__fake-timers@8.1.5': {} - '@types/symlink-or-copy@1.2.2': {} '@types/unist@2.0.11': {} @@ -8203,8 +8111,6 @@ snapshots: jsonify@0.0.1: {} - just-extend@6.2.0: {} - keyv@3.1.0: dependencies: json-buffer: 3.0.0 @@ -8260,8 +8166,6 @@ snapshots: lodash.debounce@4.0.8: {} - lodash.get@4.4.2: {} - lodash.merge@4.6.2: {} lodash@4.17.21: {} @@ -8492,14 +8396,6 @@ snapshots: nice-try@1.0.5: {} - nise@5.1.9: - dependencies: - '@sinonjs/commons': 3.0.1 - '@sinonjs/fake-timers': 11.3.1 - '@sinonjs/text-encoding': 0.7.3 - just-extend: 6.2.0 - path-to-regexp: 6.3.0 - node-fetch@2.7.0(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 @@ -8761,8 +8657,6 @@ snapshots: lru-cache: 10.4.3 minipass: 7.1.2 - path-to-regexp@6.3.0: {} - path-type@4.0.0: {} pathe@2.0.3: {} @@ -9319,15 +9213,6 @@ snapshots: simple-html-tokenizer@0.5.11: {} - sinon@14.0.2: - dependencies: - '@sinonjs/commons': 2.0.0 - '@sinonjs/fake-timers': 9.1.2 - '@sinonjs/samsam': 7.0.1 - diff: 5.2.0 - nise: 5.1.9 - supports-color: 7.2.0 - slash@3.0.0: {} smart-buffer@4.2.0: {} @@ -9587,10 +9472,6 @@ snapshots: dependencies: prelude-ls: 1.2.1 - type-detect@4.0.8: {} - - type-detect@4.1.0: {} - type-fest@0.20.2: {} type-fest@0.21.3: {} From d7bc561ad8a519d8eb5925d67a6815235085115f Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 10:48:25 -0500 Subject: [PATCH 04/14] fix deprecation on ember beta --- src/node-main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/node-main.ts b/src/node-main.ts index ad608c1..6a67d9d 100644 --- a/src/node-main.ts +++ b/src/node-main.ts @@ -57,7 +57,17 @@ async function handleNodeSpecificOptions(opts: Options): Promise assertTemplateCompiler(opts.compiler); compiler = opts.compiler; } else if ((opts.targetFormat ?? 'wire') === 'wire') { - let mod: any = await cwdImport('ember-source/dist/ember-template-compiler.js'); + let mod: any; + try { + // the newer path + mod = await cwdImport('ember-source/ember-template-compiler/index.js'); + } catch (err: any) { + if (err.code !== 'ERR_MODULE_NOT_FOUND') { + throw err; + } + // the deprecated path + mod = await cwdImport('ember-source/dist/ember-template-compiler.js'); + } assertTemplateCompiler(mod); compiler = mod; } From bb30d47643bfa0958b8a5cb0b69ca528e5328f5f Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 10:57:36 -0500 Subject: [PATCH 05/14] adjusting matrix --- .github/workflows/nodejs.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 2e6640b..71df7cc 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -45,8 +45,16 @@ jobs: fail-fast: false matrix: node: ['18', '20', '22'] - ember: ['~6.9.0', '6.10.0-beta.1'] - os: ['ubuntu-latest', 'windows-latest'] + ember: ['~3.28.0', '~4.12.0', '~5.12.0', '~6.4.0', 'latest', 'beta'] + os: ['ubuntu-latest'] + include: + - node: 22 + ember: '~6.4.0' + os: windows-latest + - node: 22 + ember: latest + os: windows-latest + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From abe861656f63259f06d16fda071ec0481554eb31 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:12:55 -0500 Subject: [PATCH 06/14] normalize out "block' --- __tests__/all.test.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index 2bd192a..40f11e0 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -386,7 +386,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [Setup], isStrictMode: true, @@ -813,7 +813,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: '[[[8,[39,0],null,[["@text"],[[32,0]]],null]],[],["message"]]', + block: "", moduleName: "", scope: () => [two], isStrictMode: false, @@ -1705,7 +1705,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [HelloWorld], isStrictMode: true, @@ -1750,7 +1750,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [HelloWorld], isStrictMode: true, @@ -1829,7 +1829,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null],[8,[32,1],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [bar, MyButton], isStrictMode: false, @@ -1893,7 +1893,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: '[[[1,[32,0,["message"]]]],[],[]]', + block: "", moduleName: "", scope: () => [this], isStrictMode: false, @@ -2255,7 +2255,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [HelloWorld], isStrictMode: true, @@ -2365,7 +2365,7 @@ describe('htmlbars-inline-precompile', function () { */ { id: "", - block: "[[[8,[32,0],null,null,null]],[],[]]", + block: "", moduleName: "", scope: () => [HelloWorld], isStrictMode: true, @@ -2517,5 +2517,6 @@ function normalizeWireFormat(src: string): string { return src .replace(/"moduleName":\s"[^"]+"/, '"moduleName": ""') .replace(/"id":\s"[^"]+"/, '"id": ""') - .replace(`"id": null`, '"id": ""'); + .replace(`"id": null`, '"id": ""') + .replace(/"block":.+,\n/, '"block": "",'); } From 92b690d050e4958eba59dd8a1327fea73869a995 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:32:20 -0500 Subject: [PATCH 07/14] try scenarios --- .github/workflows/nodejs.yml | 21 +++---- .try.mjs | 111 ++++++++++++++++++++++++++++++++++ __tests__/all.test.ts | 33 +++++----- scripts/set-ember-version.mjs | 4 -- 4 files changed, 137 insertions(+), 32 deletions(-) create mode 100644 .try.mjs delete mode 100644 scripts/set-ember-version.mjs diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 71df7cc..956504b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -38,23 +38,17 @@ jobs: cache: 'pnpm' - run: pnpm install - run: pnpm test + # For the Try Scenarios + - id: set-matrix + run: | + echo "matrix=$(pnpm -s dlx @embroider/try list)" >> $GITHUB_OUTPUT floating-test: name: Floating dependencies + needs: 'test' strategy: fail-fast: false - matrix: - node: ['18', '20', '22'] - ember: ['~3.28.0', '~4.12.0', '~5.12.0', '~6.4.0', 'latest', 'beta'] - os: ['ubuntu-latest'] - include: - - node: 22 - ember: '~6.4.0' - os: windows-latest - - node: 22 - ember: latest - os: windows-latest - + matrix: ${{fromJson(needs.test.outputs.matrix)}} runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -63,7 +57,6 @@ jobs: with: cache: 'pnpm' node-version: ${{ matrix.node }} - - name: Set ember version - run: node ./scripts/set-ember-version.mjs ${{ matrix.ember }} + - run: pnpm dlx @embroider/try apply ${{ matrix.name }} - run: pnpm install --no-lockfile - run: pnpm test diff --git a/.try.mjs b/.try.mjs new file mode 100644 index 0000000..91f0891 --- /dev/null +++ b/.try.mjs @@ -0,0 +1,111 @@ +/* + matrix: + node: ['18', '20', '22'] + ember: ['~3.28.0', '~4.12.0', '~5.12.0', '~6.4.0', 'latest', 'beta'] + os: ['ubuntu-latest'] + include: + - node: 22 + ember: '~6.4.0' + os: windows-latest + - node: 22 + ember: latest + os: windows-latest + +*/ + +const embers = [ + { + name: 'ember-lts-3.28', + npm: { + devDependencies: { + 'ember-source': '~3.28.0', + }, + }, + env: { + NO_LEXICAL_THIS: true, + }, + }, + { + name: 'ember-lts-4.12', + npm: { + devDependencies: { + 'ember-source': '~4.12.0', + }, + }, + env: { + NO_LEXICAL_THIS: true, + }, + }, + { + name: 'ember-lts-5.12', + npm: { + devDependencies: { + 'ember-source': '~5.12.0', + }, + }, + env: { + NO_LEXICAL_THIS: true, + }, + }, + { + name: 'ember-lts-6.4', + npm: { + devDependencies: { + 'ember-source': 'npm:ember-source@~6.4.0', + }, + }, + }, + { + name: 'ember-latest', + npm: { + devDependencies: { + 'ember-source': 'npm:ember-source@latest', + }, + }, + }, + { + name: 'ember-beta', + npm: { + devDependencies: { + 'ember-source': 'npm:ember-source@beta', + }, + }, + }, +]; + +const nodes = ['18', '20', '22']; + +const scenarios = nodes.flatMap((node) => + embers.map((s) => ({ + ...s, + node, + name: s.name + `-node-${node}`, + os: 'ubuntu-latest', + })) +); + +/* Windows spot checks */ +scenarios.push({ + name: 'ember-latest-windows', + os: 'windows-latest', + node: '22', + npm: { + devDependencies: { + 'ember-source': 'npm:ember-source@latest', + }, + }, +}); +scenarios.push({ + name: 'ember-lts-6.4-windows', + os: 'windows-latest', + node: '22', + npm: { + devDependencies: { + 'ember-source': 'npm:ember-source@~6.4.0', + }, + }, +}); + +export default { + scenarios, +}; diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index 40f11e0..76443d3 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -18,6 +18,8 @@ import { codeEquality, type CodeEqualityAssertions } from 'code-equality-asserti chai.use(codeEquality); +const noLexicalThis = process.env.NO_LEXICAL_THIS; + let precompileSpy: Mock; async function mockTemplateCompiler(importOriginal: () => Promise) { @@ -2017,27 +2019,29 @@ describe('htmlbars-inline-precompile', function () { `); }); - it('captures lexical "this" in mustache when template is used as an expression', async function () { - plugins = [ - [ - HTMLBarsInlinePrecompile, - { - targetFormat: 'hbs', - }, - ], - ]; + it.skipIf(noLexicalThis)( + 'captures lexical "this" in mustache when template is used as an expression', + async function () { + plugins = [ + [ + HTMLBarsInlinePrecompile, + { + targetFormat: 'hbs', + }, + ], + ]; - let transformed = await transform( - `import { template } from '@ember/template-compiler'; + let transformed = await transform( + `import { template } from '@ember/template-compiler'; function upper(s) { return s.toUpperCase() } export function exampleTest() { this.message = "hello"; render(template('{{upper this.message}}', { eval: function() { return eval(arguments[0]) } })) } ` - ); + ); - expect(transformed).equalCode(` + expect(transformed).equalCode(` import { precompileTemplate } from "@ember/template-compilation"; import { setComponentTemplate } from "@ember/component"; import templateOnly from "@ember/component/template-only"; @@ -2060,7 +2064,8 @@ describe('htmlbars-inline-precompile', function () { ); } `); - }); + } + ); it('captures lexical "this" in Element when template is used as an expression', async function () { plugins = [ diff --git a/scripts/set-ember-version.mjs b/scripts/set-ember-version.mjs deleted file mode 100644 index f9e9694..0000000 --- a/scripts/set-ember-version.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import fs from 'node:fs'; -let pkg = JSON.parse(fs.readFileSync('package.json')); -pkg.devDependencies['ember-source'] = process.argv[2]; -fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)); From f102d475c49d6c3b42d81be0c6f70ca4abf83afc Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:35:20 -0500 Subject: [PATCH 08/14] guard lexical this tests --- __tests__/all.test.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index 76443d3..de8d1e8 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -2067,27 +2067,29 @@ describe('htmlbars-inline-precompile', function () { } ); - it('captures lexical "this" in Element when template is used as an expression', async function () { - plugins = [ - [ - HTMLBarsInlinePrecompile, - { - targetFormat: 'hbs', - }, - ], - ]; + it.skipIf(noLexicalThis)( + 'captures lexical "this" in Element when template is used as an expression', + async function () { + plugins = [ + [ + HTMLBarsInlinePrecompile, + { + targetFormat: 'hbs', + }, + ], + ]; - let transformed = await transform( - `import { template } from '@ember/template-compiler'; + let transformed = await transform( + `import { template } from '@ember/template-compiler'; import SomeComponent from './elsewhere.js'; export function exampleTest() { this.message = SomeComponent; render(template('', { eval: function() { return eval(arguments[0]) } })) } ` - ); + ); - expect(transformed).equalCode(` + expect(transformed).equalCode(` import SomeComponent from './elsewhere.js'; import { precompileTemplate } from "@ember/template-compilation"; import { setComponentTemplate } from "@ember/component"; @@ -2107,7 +2109,8 @@ describe('htmlbars-inline-precompile', function () { ); } `); - }); + } + ); it('does not captures lexical "this" when template is used in class body', async function () { plugins = [ @@ -2412,7 +2415,7 @@ describe('htmlbars-inline-precompile', function () { `); }); - it('expression form can capture lexical "this"', async function () { + it.skipIf(noLexicalThis)('expression form can capture lexical "this"', async function () { plugins = [ [ HTMLBarsInlinePrecompile, From a54adedfcef88d486887627adb4883136bbc4069 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:37:25 -0500 Subject: [PATCH 09/14] fix matrix output --- .github/workflows/nodejs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 956504b..09f3bb2 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -29,7 +29,8 @@ jobs: test: name: Tests runs-on: ubuntu-latest - + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 From 250d93de4d233be745a276e01cc093904d1e80ff Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:38:00 -0500 Subject: [PATCH 10/14] apply matrix env --- .github/workflows/nodejs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 09f3bb2..6c39be6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -61,3 +61,4 @@ jobs: - run: pnpm dlx @embroider/try apply ${{ matrix.name }} - run: pnpm install --no-lockfile - run: pnpm test + env: ${{ matrix.env }} From 02f8c8c54ee1283921041ffa9f33e7a490531358 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:42:54 -0500 Subject: [PATCH 11/14] another lexical this guard --- __tests__/all.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index de8d1e8..b2a8d6c 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -1878,7 +1878,7 @@ describe('htmlbars-inline-precompile', function () { expect(precompileSpy.mock.lastCall?.at(-1)).toHaveProperty('locals', ['bar']); }); - it('can pass lexically scoped "this"', async function () { + it.skipIf(noLexicalThis)('can pass lexically scoped "this"', async function () { let transformed = await transform(` import { precompileTemplate } from '@ember/template-compilation'; export function example() { From 12c729aca1b696e0189bc4e2dfd1b481bdf333ba Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:54:15 -0500 Subject: [PATCH 12/14] some versions of glimmer/syntax have an undeclared dependency on @glimmer/env, and some ember-source versions don't cause that to be accidentally resolvable --- .try.mjs | 15 --------------- package.json | 1 + pnpm-lock.yaml | 3 +++ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.try.mjs b/.try.mjs index 91f0891..1745431 100644 --- a/.try.mjs +++ b/.try.mjs @@ -1,18 +1,3 @@ -/* - matrix: - node: ['18', '20', '22'] - ember: ['~3.28.0', '~4.12.0', '~5.12.0', '~6.4.0', 'latest', 'beta'] - os: ['ubuntu-latest'] - include: - - node: 22 - ember: '~6.4.0' - os: windows-latest - - node: 22 - ember: latest - os: windows-latest - -*/ - const embers = [ { name: 'ember-lts-3.28', diff --git a/package.json b/package.json index 26911a3..284ac27 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "test": "vitest --dir __tests__" }, "dependencies": { + "@glimmer/env": "^0.1.7", "@glimmer/syntax": ">= 0.94.9", "babel-import-util": "^3.0.0", "import-meta-resolve": "^4.1.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 88e1cbf..a878ca8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + '@glimmer/env': + specifier: ^0.1.7 + version: 0.1.7 '@glimmer/syntax': specifier: '>= 0.94.9' version: 0.94.9 From d08b7f83e4c23001bceb7f1f2e4c5845712bee7e Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 9 Dec 2025 21:55:13 -0500 Subject: [PATCH 13/14] moving to devDeps on the theory that it's only vitest that's loading the "dev" versions of @glimmer/syntax that refers to @glimmer/env --- package.json | 2 +- pnpm-lock.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 284ac27..f25106b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "test": "vitest --dir __tests__" }, "dependencies": { - "@glimmer/env": "^0.1.7", "@glimmer/syntax": ">= 0.94.9", "babel-import-util": "^3.0.0", "import-meta-resolve": "^4.1.0" @@ -40,6 +39,7 @@ "@babel/plugin-transform-typescript": "^7.22.11", "@babel/plugin-transform-unicode-escapes": "^7.14.5", "@babel/traverse": "^7.14.5", + "@glimmer/env": "^0.1.7", "@types/babel__core": "^7.20.1", "@types/babel__traverse": "^7.11.1", "@types/node": "^20.5.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a878ca8..00f32fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - '@glimmer/env': - specifier: ^0.1.7 - version: 0.1.7 '@glimmer/syntax': specifier: '>= 0.94.9' version: 0.94.9 @@ -42,6 +39,9 @@ importers: '@babel/traverse': specifier: ^7.14.5 version: 7.27.0 + '@glimmer/env': + specifier: ^0.1.7 + version: 0.1.7 '@types/babel__core': specifier: ^7.20.1 version: 7.20.5 From 721a09d1261794130427a7526fb4b30914c45d28 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 13 Jan 2026 09:54:19 -0500 Subject: [PATCH 14/14] change mocking strategy --- __tests__/all.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/__tests__/all.test.ts b/__tests__/all.test.ts index b2a8d6c..f3bb95d 100644 --- a/__tests__/all.test.ts +++ b/__tests__/all.test.ts @@ -24,12 +24,13 @@ let precompileSpy: Mock; async function mockTemplateCompiler(importOriginal: () => Promise) { const mod = await importOriginal(); - precompileSpy = vi.spyOn(mod, 'precompile'); + precompileSpy = vi.fn(mod.precompile); return { // the plugin probes for the existence of this, and if we don't stick a key // here Vitest injects a failure default: null, ...mod, + precompile: precompileSpy, }; }