From 208b2c5140286f0c379c98a8236af23ba33a0aa0 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Wed, 29 Nov 2023 14:11:18 +0100 Subject: [PATCH 1/6] test: add failing test --- .../macros/tests/glimmer/dependency-satisfies.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/macros/tests/glimmer/dependency-satisfies.test.ts b/packages/macros/tests/glimmer/dependency-satisfies.test.ts index e8c389dc8..80180f073 100644 --- a/packages/macros/tests/glimmer/dependency-satisfies.test.ts +++ b/packages/macros/tests/glimmer/dependency-satisfies.test.ts @@ -29,6 +29,14 @@ describe('dependency satisfies', () => { expect(result).toMatch(/@a=\{\{true\}\}/); }); + test('in branch', () => { + let result = transform( + `{{#if (macroDependencySatisfies 'qunit' '^2.8.0')}}
{{else}}{{/if}}`, + { filename } + ); + expect(result).toEqual('
'); + }); + test('emits false for out-of-range package', () => { let result = transform(`{{macroDependencySatisfies 'qunit' '^10.0.0'}}`, { filename }); expect(result).toEqual('{{false}}'); From c3880d9c9a68bbcc5f628a5ac9aa7bab9f903cb7 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Wed, 29 Nov 2023 16:01:35 +0100 Subject: [PATCH 2/6] fix: transform macroDependencySatisfies to a macroCondition --- packages/macros/src/glimmer/ast-transform.ts | 4 +++- packages/macros/tests/glimmer/dependency-satisfies.test.ts | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/macros/src/glimmer/ast-transform.ts b/packages/macros/src/glimmer/ast-transform.ts index b7d0a3aa9..c0a29cea5 100644 --- a/packages/macros/src/glimmer/ast-transform.ts +++ b/packages/macros/src/glimmer/ast-transform.ts @@ -97,7 +97,9 @@ export function makeFirstTransform(opts: FirstTransformParams) { ); } if (node.path.original === 'macroDependencySatisfies') { - return literal(dependencySatisfies(node, opts.packageRoot, moduleName, packageCache), env.syntax.builders); + return env.syntax.builders.sexpr('macroCondition', [ + literal(dependencySatisfies(node, opts.packageRoot, moduleName, packageCache), env.syntax.builders), + ]); } }, MustacheStatement(node: any) { diff --git a/packages/macros/tests/glimmer/dependency-satisfies.test.ts b/packages/macros/tests/glimmer/dependency-satisfies.test.ts index 80180f073..0531aa520 100644 --- a/packages/macros/tests/glimmer/dependency-satisfies.test.ts +++ b/packages/macros/tests/glimmer/dependency-satisfies.test.ts @@ -30,11 +30,8 @@ describe('dependency satisfies', () => { }); test('in branch', () => { - let result = transform( - `{{#if (macroDependencySatisfies 'qunit' '^2.8.0')}}
{{else}}{{/if}}`, - { filename } - ); - expect(result).toEqual('
'); + let result = transform(`{{#if (macroDependencySatisfies 'qunit' '^2.8.0')}}red{{else}}blue{{/if}}`, { filename }); + expect(result).toEqual('red'); }); test('emits false for out-of-range package', () => { From 3fa43ed20699870bc8bffbcc6dfef011b93870d0 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Wed, 29 Nov 2023 23:16:33 +0100 Subject: [PATCH 3/6] fix: handle specific sub-expression cases --- packages/macros/src/glimmer/ast-transform.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/macros/src/glimmer/ast-transform.ts b/packages/macros/src/glimmer/ast-transform.ts index c0a29cea5..b206b617a 100644 --- a/packages/macros/src/glimmer/ast-transform.ts +++ b/packages/macros/src/glimmer/ast-transform.ts @@ -77,7 +77,7 @@ export function makeFirstTransform(opts: FirstTransformParams) { } }, }, - SubExpression(node: any) { + SubExpression(node: any, walker: { parent: { node: any } }) { if (node.path.type !== 'PathExpression') { return; } @@ -97,9 +97,18 @@ export function makeFirstTransform(opts: FirstTransformParams) { ); } if (node.path.original === 'macroDependencySatisfies') { - return env.syntax.builders.sexpr('macroCondition', [ - literal(dependencySatisfies(node, opts.packageRoot, moduleName, packageCache), env.syntax.builders), - ]); + console.log('parent', JSON.stringify(walker.parent, null, 2)); + console.log('node', JSON.stringify(node, null, 2)); + const staticValue = literal( + dependencySatisfies(node, opts.packageRoot, moduleName, packageCache), + env.syntax.builders + ); + // If this is a macro expression by itself, then turn it into a macroCondition for the second pass to prune. + // Otherwise assume it's being composed with another macro and evaluate it as a literal + if (walker.parent.node.path.original === 'if') { + return env.syntax.builders.sexpr('macroCondition', [staticValue]); + } + return staticValue; } }, MustacheStatement(node: any) { From 746124bee32205f731274e01889330b789a755c7 Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Thu, 30 Nov 2023 09:56:04 +0100 Subject: [PATCH 4/6] fix: remove logs --- packages/macros/src/glimmer/ast-transform.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/macros/src/glimmer/ast-transform.ts b/packages/macros/src/glimmer/ast-transform.ts index b206b617a..8fb071e96 100644 --- a/packages/macros/src/glimmer/ast-transform.ts +++ b/packages/macros/src/glimmer/ast-transform.ts @@ -97,8 +97,6 @@ export function makeFirstTransform(opts: FirstTransformParams) { ); } if (node.path.original === 'macroDependencySatisfies') { - console.log('parent', JSON.stringify(walker.parent, null, 2)); - console.log('node', JSON.stringify(node, null, 2)); const staticValue = literal( dependencySatisfies(node, opts.packageRoot, moduleName, packageCache), env.syntax.builders From 75a5065cc22745ee44ecaa8362645283f21c726f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Dec 2023 16:14:13 +0000 Subject: [PATCH 5/6] Prepare Release using 'release-plan' --- .release-plan.json | 71 +++++++++++++++++++-------------- CHANGELOG.md | 30 ++++++++++++++ packages/addon-dev/package.json | 2 +- packages/compat/package.json | 2 +- packages/core/package.json | 2 +- packages/macros/package.json | 2 +- 6 files changed, 76 insertions(+), 33 deletions(-) diff --git a/.release-plan.json b/.release-plan.json index 4b17b0227..bdd67af6b 100644 --- a/.release-plan.json +++ b/.release-plan.json @@ -1,7 +1,16 @@ { "solution": { "@embroider/addon-dev": { - "oldVersion": "4.1.2" + "impact": "patch", + "oldVersion": "4.1.2", + "newVersion": "4.1.3", + "constraints": [ + { + "impact": "patch", + "reason": "Appears in changelog section :bug: Bug Fix" + } + ], + "pkgJSONPath": "./packages/addon-dev/package.json" }, "@embroider/addon-shim": { "oldVersion": "1.8.7" @@ -10,53 +19,57 @@ "oldVersion": "3.1.1" }, "@embroider/compat": { - "impact": "minor", - "oldVersion": "3.3.1", - "newVersion": "3.4.0", + "impact": "patch", + "oldVersion": "3.4.0", + "newVersion": "3.4.1", "constraints": [ { - "impact": "minor", - "reason": "Appears in changelog section :rocket: Enhancement" + "impact": "patch", + "reason": "Has dependency `workspace:*` on @embroider/macros" + }, + { + "impact": "patch", + "reason": "Appears in changelog section :bug: Bug Fix" } ], - "pkgJSONPath": "packages/compat/package.json" + "pkgJSONPath": "./packages/compat/package.json" }, "@embroider/core": { - "oldVersion": "3.4.2" + "impact": "patch", + "oldVersion": "3.4.2", + "newVersion": "3.4.3", + "constraints": [ + { + "impact": "patch", + "reason": "Has dependency `workspace:*` on @embroider/macros" + } + ], + "pkgJSONPath": "./packages/core/package.json" }, "@embroider/hbs-loader": { "oldVersion": "3.0.3" }, "@embroider/macros": { - "oldVersion": "1.13.3" - }, - "@embroider/reverse-exports": { - "impact": "minor", - "oldVersion": "0.0.0", - "newVersion": "0.1.0", + "impact": "patch", + "oldVersion": "1.13.3", + "newVersion": "1.13.4", "constraints": [ { - "impact": "minor", - "reason": "Appears in changelog section :rocket: Enhancement" + "impact": "patch", + "reason": "Appears in changelog section :bug: Bug Fix" }, { "impact": "patch", - "reason": "Appears in changelog section :bug: Bug Fix" + "reason": "Appears in changelog section :house: Internal" } ], - "pkgJSONPath": "packages/reverse-exports/package.json" + "pkgJSONPath": "./packages/macros/package.json" + }, + "@embroider/reverse-exports": { + "oldVersion": "0.1.0" }, "@embroider/router": { - "impact": "patch", - "oldVersion": "2.1.5", - "newVersion": "2.1.6", - "constraints": [ - { - "impact": "patch", - "reason": "Appears in changelog section :bug: Bug Fix" - } - ], - "pkgJSONPath": "packages/router/package.json" + "oldVersion": "2.1.6" }, "@embroider/shared-internals": { "oldVersion": "2.5.1" @@ -74,5 +87,5 @@ "oldVersion": "3.2.1" } }, - "description": "## Release (2023-11-28)\n\n@embroider/compat 3.4.0 (minor)\n@embroider/reverse-exports 0.1.0 (minor)\n@embroider/router 2.1.6 (patch)\n\n#### :rocket: Enhancement\n* `reverse-exports`\n * [#1652](https://github.com/embroider-build/embroider/pull/1652) create new @embroider/reverse-exports package ([@lolmaus](https://github.com/lolmaus))\n* `compat`\n * [#1673](https://github.com/embroider-build/embroider/pull/1673) allow apps to disable the decorator transforms ([@ef4](https://github.com/ef4))\n\n#### :bug: Bug Fix\n* `router`\n * [#1684](https://github.com/embroider-build/embroider/pull/1684) Workaround typescript regression in router package ([@ef4](https://github.com/ef4))\n* `reverse-exports`\n * [#1676](https://github.com/embroider-build/embroider/pull/1676) fix single asterisk replacement in reverse-exports ([@mansona](https://github.com/mansona))\n\n#### :house: Internal\n* [#1683](https://github.com/embroider-build/embroider/pull/1683) update the releasing CI job ([@mansona](https://github.com/mansona))\n* [#1681](https://github.com/embroider-build/embroider/pull/1681) skip watch-mode tests in windows ([@mansona](https://github.com/mansona))\n\n#### Committers: 3\n- Andrey Mikhaylov (lolmaus) ([@lolmaus](https://github.com/lolmaus))\n- Chris Manson ([@mansona](https://github.com/mansona))\n- Edward Faulkner ([@ef4](https://github.com/ef4))\n" + "description": "## Release (2023-12-13)\n\n@embroider/addon-dev 4.1.3 (patch)\n@embroider/compat 3.4.1 (patch)\n@embroider/core 3.4.3 (patch)\n@embroider/macros 1.13.4 (patch)\n\n#### :bug: Bug Fix\n* `@embroider/macros`\n * [#1688](https://github.com/embroider-build/embroider/pull/1688) Fix branch elimination for `macroDependencySatisfies` ([@mike-engel](https://github.com/mike-engel))\n* `@embroider/compat`\n * [#1706](https://github.com/embroider-build/embroider/pull/1706) Support engine's lazyLoading boolean config ([@fengb](https://github.com/fengb))\n* `@embroider/addon-dev`\n * [#1696](https://github.com/embroider-build/embroider/pull/1696) Use rollup's `addWatchFile` API to mark dependencies ([@chancancode](https://github.com/chancancode))\n\n#### :house: Internal\n* Other\n * [#1716](https://github.com/embroider-build/embroider/pull/1716) update release-plan ([@mansona](https://github.com/mansona))\n * [#1698](https://github.com/embroider-build/embroider/pull/1698) Use release plan ([@mansona](https://github.com/mansona))\n* `@embroider/macros`\n * [#1709](https://github.com/embroider-build/embroider/pull/1709) Jest types broke our CI ([@ef4](https://github.com/ef4))\n* `@embroider/test-scenarios`\n * [#1705](https://github.com/embroider-build/embroider/pull/1705) Backport #1703 to stable ([@chancancode](https://github.com/chancancode))\n\n#### Committers: 5\n- Benjamin Feng ([@fengb](https://github.com/fengb))\n- Chris Manson ([@mansona](https://github.com/mansona))\n- Edward Faulkner ([@ef4](https://github.com/ef4))\n- Godfrey Chan ([@chancancode](https://github.com/chancancode))\n- Mike Engel ([@mike-engel](https://github.com/mike-engel))\n" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e591b5eb..cfe5bd66d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,34 @@ # Embroider Changelog +## Release (2023-12-13) + +@embroider/addon-dev 4.1.3 (patch) +@embroider/compat 3.4.1 (patch) +@embroider/core 3.4.3 (patch) +@embroider/macros 1.13.4 (patch) + +#### :bug: Bug Fix +* `@embroider/macros` + * [#1688](https://github.com/embroider-build/embroider/pull/1688) Fix branch elimination for `macroDependencySatisfies` ([@mike-engel](https://github.com/mike-engel)) +* `@embroider/compat` + * [#1706](https://github.com/embroider-build/embroider/pull/1706) Support engine's lazyLoading boolean config ([@fengb](https://github.com/fengb)) +* `@embroider/addon-dev` + * [#1696](https://github.com/embroider-build/embroider/pull/1696) Use rollup's `addWatchFile` API to mark dependencies ([@chancancode](https://github.com/chancancode)) + +#### :house: Internal +* Other + * [#1716](https://github.com/embroider-build/embroider/pull/1716) update release-plan ([@mansona](https://github.com/mansona)) + * [#1698](https://github.com/embroider-build/embroider/pull/1698) Use release plan ([@mansona](https://github.com/mansona)) +* `@embroider/macros` + * [#1709](https://github.com/embroider-build/embroider/pull/1709) Jest types broke our CI ([@ef4](https://github.com/ef4)) +* `@embroider/test-scenarios` + * [#1705](https://github.com/embroider-build/embroider/pull/1705) Backport #1703 to stable ([@chancancode](https://github.com/chancancode)) + +#### Committers: 5 +- Benjamin Feng ([@fengb](https://github.com/fengb)) +- Chris Manson ([@mansona](https://github.com/mansona)) +- Edward Faulkner ([@ef4](https://github.com/ef4)) +- Godfrey Chan ([@chancancode](https://github.com/chancancode)) +- Mike Engel ([@mike-engel](https://github.com/mike-engel)) ## Release (2023-11-28) diff --git a/packages/addon-dev/package.json b/packages/addon-dev/package.json index 9566186e2..add371a13 100644 --- a/packages/addon-dev/package.json +++ b/packages/addon-dev/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/addon-dev", - "version": "4.1.2", + "version": "4.1.3", "description": "Utilities for addon authors", "repository": { "type": "git", diff --git a/packages/compat/package.json b/packages/compat/package.json index 9ec3ac427..cbd6ac329 100644 --- a/packages/compat/package.json +++ b/packages/compat/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/compat", - "version": "3.4.0", + "version": "3.4.1", "private": false, "description": "Backward compatibility layer for the Embroider build system.", "repository": { diff --git a/packages/core/package.json b/packages/core/package.json index 4c0e43ad8..25416b38a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/core", - "version": "3.4.2", + "version": "3.4.3", "private": false, "description": "A build system for EmberJS applications.", "repository": { diff --git a/packages/macros/package.json b/packages/macros/package.json index e499353ed..5b438d9c7 100644 --- a/packages/macros/package.json +++ b/packages/macros/package.json @@ -1,6 +1,6 @@ { "name": "@embroider/macros", - "version": "1.13.3", + "version": "1.13.4", "private": false, "description": "Standardized build-time macros for ember apps.", "keywords": [ From e5cb780ace8659cdbf05518ac0ffb1e604de5360 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 12 Dec 2023 15:19:47 -0500 Subject: [PATCH 6/6] Always load ember-testing package eagerly In ember-source 5.6 (now in beta), we refactored the way Ember and its test-only pieces find each other to no longer be dependent on the AMD loader. But this mean it's no longer sufficient to `define()` *and not evaluate* the `ember-testing` package in order to install the test support. It must actually get evaluted first. Note that this bug does not manifest on embroider `main`, because there implicit-test-modules are eagerly evaluated. This is only a problem on stable, when using `staticEmberSource: true`. --- packages/compat/src/compat-adapters/ember-source.ts | 13 +++++++++---- packages/compat/src/compat-app-builder.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/compat/src/compat-adapters/ember-source.ts b/packages/compat/src/compat-adapters/ember-source.ts index 1bebb47c2..f2187269c 100644 --- a/packages/compat/src/compat-adapters/ember-source.ts +++ b/packages/compat/src/compat-adapters/ember-source.ts @@ -124,11 +124,16 @@ export default class extends V1Addon { meta['implicit-modules'] = []; } meta['implicit-modules'].push('./ember/index.js'); - - if (!meta['implicit-test-modules']) { - meta['implicit-test-modules'] = []; + // before 5.6, Ember uses the AMD loader to decide if it's test-only parts + // are present, so we must ensure they're registered. After that it's + // enough to evaluate ember-testing, which @embroider/core is hard-coded + // to do in the backward-compatible tests bundle. + if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) { + if (!meta['implicit-test-modules']) { + meta['implicit-test-modules'] = []; + } + meta['implicit-test-modules'].push('./ember-testing/index.js'); } - meta['implicit-test-modules'].push('./ember-testing/index.js'); } return meta; } diff --git a/packages/compat/src/compat-app-builder.ts b/packages/compat/src/compat-app-builder.ts index e2f0364b2..bafb3dbf6 100644 --- a/packages/compat/src/compat-app-builder.ts +++ b/packages/compat/src/compat-app-builder.ts @@ -1338,6 +1338,7 @@ export class CompatAppBuilder { // packagers to understand. It's better to express it here as a direct // module dependency. let eagerModules: string[] = [ + 'ember-testing', explicitRelative(dirname(myName), this.topAppJSAsset(appFiles, prepared).relativePath), ];