diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ca90a481..0c594dae3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,37 @@
# Embroider Changelog
+## Release (2024-06-12)
+
+@embroider/webpack 4.0.3 (patch)
+
+#### :bug: Bug Fix
+* `@embroider/webpack`
+ * [#1981](https://github.com/embroider-build/embroider/pull/1981) Revert "Webpack: close the compiler" ([@krasnoukhov](https://github.com/krasnoukhov))
+
+#### Committers: 1
+- Dmitry Krasnoukhov ([@krasnoukhov](https://github.com/krasnoukhov))
+
+## Release (2024-06-11)
+
+@embroider/compat 3.5.2 (patch)
+@embroider/core 3.4.11 (patch)
+@embroider/macros 1.16.3 (patch)
+@embroider/webpack 4.0.2 (patch)
+
+#### :bug: Bug Fix
+* `@embroider/macros`
+ * [#1967](https://github.com/embroider-build/embroider/pull/1967) Address these issues in new apps (5.9): ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
+* `@embroider/webpack`
+ * [#1978](https://github.com/embroider-build/embroider/pull/1978) Webpack: close the compiler ([@ef4](https://github.com/ef4))
+* `@embroider/macros`, `@embroider/test-fixtures`
+ * [#1977](https://github.com/embroider-build/embroider/pull/1977) Fix modifier removal for "unless (macroCondition ...)" ([@ef4](https://github.com/ef4))
+* `@embroider/macros`, `@embroider/test-fixtures`, `@embroider/test-scenarios`
+ * [#1975](https://github.com/embroider-build/embroider/pull/1975) Stop using "#with" in macro tests ([@ef4](https://github.com/ef4))
+
+#### Committers: 2
+- Edward Faulkner ([@ef4](https://github.com/ef4))
+- [@NullVoxPopuli](https://github.com/NullVoxPopuli)
+
## Release (2024-05-29)
@embroider/router 2.1.8 (patch)
diff --git a/packages/compat/package.json b/packages/compat/package.json
index 8f4d6ca2d..32b75bde0 100644
--- a/packages/compat/package.json
+++ b/packages/compat/package.json
@@ -1,6 +1,6 @@
{
"name": "@embroider/compat",
- "version": "3.5.1",
+ "version": "3.5.2",
"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 caf750b61..9ea6d5dfc 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@embroider/core",
- "version": "3.4.10",
+ "version": "3.4.11",
"private": false,
"description": "A build system for EmberJS applications.",
"repository": {
diff --git a/packages/macros/package.json b/packages/macros/package.json
index 924966187..ed984b0b2 100644
--- a/packages/macros/package.json
+++ b/packages/macros/package.json
@@ -1,6 +1,6 @@
{
"name": "@embroider/macros",
- "version": "1.16.2",
+ "version": "1.16.3",
"private": false,
"description": "Standardized build-time macros for ember apps.",
"keywords": [
diff --git a/packages/macros/src/glimmer/ast-transform.ts b/packages/macros/src/glimmer/ast-transform.ts
index b1e8832a0..c13341834 100644
--- a/packages/macros/src/glimmer/ast-transform.ts
+++ b/packages/macros/src/glimmer/ast-transform.ts
@@ -72,25 +72,16 @@ export function makeFirstTransform(opts: FirstTransformParams) {
name: '@embroider/macros/first',
visitor: {
- Program: {
- enter(node: any) {
- if (node.blockParams.length > 0) {
- scopeStack.push(node.blockParams);
- }
- },
- exit(node: any) {
- if (node.blockParams.length > 0) {
- scopeStack.pop();
- }
- },
- },
+ ...scopeVisitors(env, scopeStack),
SubExpression(node: any, walker: { parent: { node: any } }) {
if (node.path.type !== 'PathExpression') {
return;
}
- if (inScope(scopeStack, node.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return;
}
+
if (node.path.original === 'macroGetOwnConfig') {
return literal(
getConfig(node, opts.configs, opts.packageRoot, moduleName, true, packageCache),
@@ -120,7 +111,8 @@ export function makeFirstTransform(opts: FirstTransformParams) {
if (node.path.type !== 'PathExpression') {
return;
}
- if (inScope(scopeStack, node.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return;
}
if (node.path.original === 'macroGetOwnConfig') {
@@ -166,23 +158,13 @@ export function makeSecondTransform() {
name: '@embroider/macros/second',
visitor: {
- Program: {
- enter(node: any) {
- if (node.blockParams.length > 0) {
- scopeStack.push(node.blockParams);
- }
- },
- exit(node: any) {
- if (node.blockParams.length > 0) {
- scopeStack.pop();
- }
- },
- },
+ ...scopeVisitors(env, scopeStack),
BlockStatement(node: any) {
if (node.path.type !== 'PathExpression') {
return;
}
- if (inScope(scopeStack, node.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return;
}
if (node.path.original === 'if') {
@@ -196,7 +178,8 @@ export function makeSecondTransform() {
if (node.path.type !== 'PathExpression') {
return;
}
- if (inScope(scopeStack, node.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return;
}
if (node.path.original === 'if') {
@@ -228,13 +211,14 @@ export function makeSecondTransform() {
) {
modifier.path = macroUnlessExpression(modifier.path, env.syntax.builders);
if (modifier.path.type === 'UndefinedLiteral') {
- return true;
+ return false;
}
}
if (modifier.path.type !== 'PathExpression') {
return true;
}
- if (inScope(scopeStack, modifier.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return true;
}
if (modifier.path.original === 'macroMaybeAttrs') {
@@ -248,7 +232,8 @@ export function makeSecondTransform() {
if (node.path.type !== 'PathExpression') {
return;
}
- if (inScope(scopeStack, node.path.parts[0])) {
+
+ if (inScope(scopeStack, headOf(node.path))) {
return;
}
if (node.path.original === 'if') {
@@ -281,3 +266,34 @@ function inScope(scopeStack: string[][], name: string) {
}
return false;
}
+
+function headOf(path: any) {
+ if (!path) return;
+
+ return 'head' in path ? path.head.name : path.parts[0];
+}
+
+function scopeVisitors(env: any, scopeStack: string[][]) {
+ function enter(node: any) {
+ if (node.blockParams.length > 0) {
+ scopeStack.push(node.blockParams);
+ }
+ }
+ function exit(node: any) {
+ if (node.blockParams.length > 0) {
+ scopeStack.pop();
+ }
+ }
+
+ let hasTemplate = 'template' in env.syntax.builders;
+ if (hasTemplate) {
+ return {
+ Template: { enter, exit },
+ Block: { enter, exit },
+ };
+ } else {
+ return {
+ Program: { enter, exit },
+ };
+ }
+}
diff --git a/packages/macros/tests/glimmer/get-config.test.ts b/packages/macros/tests/glimmer/get-config.test.ts
index fbd0cccf8..19606b813 100644
--- a/packages/macros/tests/glimmer/get-config.test.ts
+++ b/packages/macros/tests/glimmer/get-config.test.ts
@@ -29,12 +29,12 @@ describe(`macroGetConfig`, function () {
});
test('macroGetOwnConfig in subexpression position', function () {
- let code = transform(`{{#with (macroGetOwnConfig "mode") as |m|}}{{m}}{{/with}}`);
+ let code = transform(`{{#let (macroGetOwnConfig "mode") as |m|}}{{m}}{{/let}}`);
expect(code).toMatch(/\{\{#with ["']amazing["'] as |m|\}\}/);
});
test('macroGetConfig in subexpression position', function () {
- let code = transform(`{{#with (macroGetConfig "scenario-tester" "color") as |m|}}{{m}}{{/with}}`);
+ let code = transform(`{{#let (macroGetConfig "scenario-tester" "color") as |m|}}{{m}}{{/let}}`);
expect(code).toMatch(/\{\{#with ["']orange["'] as |m|\}\}/);
});
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index d3faa5f84..f5dd375af 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -1,6 +1,6 @@
{
"name": "@embroider/webpack",
- "version": "4.0.1",
+ "version": "4.0.3",
"private": false,
"description": "Builds EmberJS apps with Webpack",
"repository": {
diff --git a/tests/fixtures/macro-test/tests/integration/components/common-test.js b/tests/fixtures/macro-test/tests/integration/components/common-test.js
index 7987bee5a..646b67f72 100644
--- a/tests/fixtures/macro-test/tests/integration/components/common-test.js
+++ b/tests/fixtures/macro-test/tests/integration/components/common-test.js
@@ -7,7 +7,7 @@ module('Integration | Macro | common', function(hooks) {
setupRenderingTest(hooks);
test('our macros do not shadow local variables', async function(assert) {
- await render(hbs`{{#with "hello" as |macroDependencySatisfies|}} {{macroDependencySatisfies}} {{/with}}`);
+ await render(hbs`{{#let "hello" as |macroDependencySatisfies|}} {{macroDependencySatisfies}} {{/let}}`);
assert.equal(this.element.textContent.trim(), 'hello');
});
diff --git a/tests/fixtures/macro-test/tests/integration/components/get-config-test.js b/tests/fixtures/macro-test/tests/integration/components/get-config-test.js
index 127d47d42..68f382e60 100644
--- a/tests/fixtures/macro-test/tests/integration/components/get-config-test.js
+++ b/tests/fixtures/macro-test/tests/integration/components/get-config-test.js
@@ -18,12 +18,12 @@ module('Integration | Macro | getConfig', function(hooks) {
});
test('macroGetOwnConfig in subexpression position', async function(assert) {
- await render(hbs`{{#with (macroGetOwnConfig "mode") as |m|}}{{m}}{{/with}}`);
+ await render(hbs`{{#let (macroGetOwnConfig "mode") as |m|}}{{m}}{{/let}}`);
assert.equal(this.element.textContent.trim(), 'amazing');
});
test('macroGetConfig in subexpression position', async function(assert) {
- await render(hbs`{{#with (macroGetConfig "ember-source" "color") as |m|}}{{m}}{{/with}}`);
+ await render(hbs`{{#let (macroGetConfig "ember-source" "color") as |m|}}{{m}}{{/let}}`);
assert.equal(this.element.textContent.trim(), 'orange');
});
diff --git a/tests/fixtures/macro-test/tests/integration/components/macro-unless-test.js b/tests/fixtures/macro-test/tests/integration/components/macro-unless-test.js
index 5cb6afc65..12db5cf75 100644
--- a/tests/fixtures/macro-test/tests/integration/components/macro-unless-test.js
+++ b/tests/fixtures/macro-test/tests/integration/components/macro-unless-test.js
@@ -114,7 +114,7 @@ module('Integration | Macro | macroCondition + {{unless}}', function (hooks) {
await click('button');
});
- test('macroCondition in modifier position when true with no alternate', async function (assert) {
+ test('macroCondition in modifier position when true with no alternate should do nothing', async function (assert) {
assert.expect(0);
this.doThing = function () {
assert.ok(true, 'it ran');
diff --git a/tests/scenarios/compat-resolver-test.ts b/tests/scenarios/compat-resolver-test.ts
index bd646a50f..b6afaea91 100644
--- a/tests/scenarios/compat-resolver-test.ts
+++ b/tests/scenarios/compat-resolver-test.ts
@@ -1160,8 +1160,8 @@ Scenarios.fromProject(() => new Project())
'templates/application.hbs': `
{{outlet}}
{{yield bar}}
- {{#with (hash submit=(action doit)) as |thing| }}
- {{/with}}
+ {{#let (hash submit=(action doit)) as |thing| }}
+ {{/let}}