Skip to content

Commit b61ecde

Browse files
authored
Merge pull request #1983 from embroider-build/merge-stable
Merge stable into Main
2 parents 0277294 + d2422d9 commit b61ecde

File tree

11 files changed

+92
-44
lines changed

11 files changed

+92
-44
lines changed

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Embroider Changelog
22

3+
## Release (2024-06-12)
4+
5+
@embroider/webpack 4.0.3 (patch)
6+
7+
#### :bug: Bug Fix
8+
* `@embroider/webpack`
9+
* [#1981](https://github.com/embroider-build/embroider/pull/1981) Revert "Webpack: close the compiler" ([@krasnoukhov](https://github.com/krasnoukhov))
10+
11+
#### Committers: 1
12+
- Dmitry Krasnoukhov ([@krasnoukhov](https://github.com/krasnoukhov))
13+
14+
## Release (2024-06-11)
15+
16+
@embroider/compat 3.5.2 (patch)
17+
@embroider/core 3.4.11 (patch)
18+
@embroider/macros 1.16.3 (patch)
19+
@embroider/webpack 4.0.2 (patch)
20+
21+
#### :bug: Bug Fix
22+
* `@embroider/macros`
23+
* [#1967](https://github.com/embroider-build/embroider/pull/1967) Address these issues in new apps (5.9): ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
24+
* `@embroider/webpack`
25+
* [#1978](https://github.com/embroider-build/embroider/pull/1978) Webpack: close the compiler ([@ef4](https://github.com/ef4))
26+
* `@embroider/macros`, `@embroider/test-fixtures`
27+
* [#1977](https://github.com/embroider-build/embroider/pull/1977) Fix modifier removal for "unless (macroCondition ...)" ([@ef4](https://github.com/ef4))
28+
* `@embroider/macros`, `@embroider/test-fixtures`, `@embroider/test-scenarios`
29+
* [#1975](https://github.com/embroider-build/embroider/pull/1975) Stop using "#with" in macro tests ([@ef4](https://github.com/ef4))
30+
31+
#### Committers: 2
32+
- Edward Faulkner ([@ef4](https://github.com/ef4))
33+
- [@NullVoxPopuli](https://github.com/NullVoxPopuli)
34+
335
## Release (2024-05-29)
436

537
@embroider/router 2.1.8 (patch)

packages/compat/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@embroider/compat",
3-
"version": "3.5.1",
3+
"version": "3.5.2",
44
"private": false,
55
"description": "Backward compatibility layer for the Embroider build system.",
66
"repository": {

packages/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@embroider/core",
3-
"version": "3.4.10",
3+
"version": "3.4.11",
44
"private": false,
55
"description": "A build system for EmberJS applications.",
66
"repository": {

packages/macros/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@embroider/macros",
3-
"version": "1.16.2",
3+
"version": "1.16.3",
44
"private": false,
55
"description": "Standardized build-time macros for ember apps.",
66
"keywords": [

packages/macros/src/glimmer/ast-transform.ts

+47-31
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,16 @@ export function makeFirstTransform(opts: FirstTransformParams) {
7272
name: '@embroider/macros/first',
7373

7474
visitor: {
75-
Program: {
76-
enter(node: any) {
77-
if (node.blockParams.length > 0) {
78-
scopeStack.push(node.blockParams);
79-
}
80-
},
81-
exit(node: any) {
82-
if (node.blockParams.length > 0) {
83-
scopeStack.pop();
84-
}
85-
},
86-
},
75+
...scopeVisitors(env, scopeStack),
8776
SubExpression(node: any, walker: { parent: { node: any } }) {
8877
if (node.path.type !== 'PathExpression') {
8978
return;
9079
}
91-
if (inScope(scopeStack, node.path.parts[0])) {
80+
81+
if (inScope(scopeStack, headOf(node.path))) {
9282
return;
9383
}
84+
9485
if (node.path.original === 'macroGetOwnConfig') {
9586
return literal(
9687
getConfig(node, opts.configs, opts.packageRoot, moduleName, true, packageCache),
@@ -120,7 +111,8 @@ export function makeFirstTransform(opts: FirstTransformParams) {
120111
if (node.path.type !== 'PathExpression') {
121112
return;
122113
}
123-
if (inScope(scopeStack, node.path.parts[0])) {
114+
115+
if (inScope(scopeStack, headOf(node.path))) {
124116
return;
125117
}
126118
if (node.path.original === 'macroGetOwnConfig') {
@@ -166,23 +158,13 @@ export function makeSecondTransform() {
166158
name: '@embroider/macros/second',
167159

168160
visitor: {
169-
Program: {
170-
enter(node: any) {
171-
if (node.blockParams.length > 0) {
172-
scopeStack.push(node.blockParams);
173-
}
174-
},
175-
exit(node: any) {
176-
if (node.blockParams.length > 0) {
177-
scopeStack.pop();
178-
}
179-
},
180-
},
161+
...scopeVisitors(env, scopeStack),
181162
BlockStatement(node: any) {
182163
if (node.path.type !== 'PathExpression') {
183164
return;
184165
}
185-
if (inScope(scopeStack, node.path.parts[0])) {
166+
167+
if (inScope(scopeStack, headOf(node.path))) {
186168
return;
187169
}
188170
if (node.path.original === 'if') {
@@ -196,7 +178,8 @@ export function makeSecondTransform() {
196178
if (node.path.type !== 'PathExpression') {
197179
return;
198180
}
199-
if (inScope(scopeStack, node.path.parts[0])) {
181+
182+
if (inScope(scopeStack, headOf(node.path))) {
200183
return;
201184
}
202185
if (node.path.original === 'if') {
@@ -228,13 +211,14 @@ export function makeSecondTransform() {
228211
) {
229212
modifier.path = macroUnlessExpression(modifier.path, env.syntax.builders);
230213
if (modifier.path.type === 'UndefinedLiteral') {
231-
return true;
214+
return false;
232215
}
233216
}
234217
if (modifier.path.type !== 'PathExpression') {
235218
return true;
236219
}
237-
if (inScope(scopeStack, modifier.path.parts[0])) {
220+
221+
if (inScope(scopeStack, headOf(node.path))) {
238222
return true;
239223
}
240224
if (modifier.path.original === 'macroMaybeAttrs') {
@@ -248,7 +232,8 @@ export function makeSecondTransform() {
248232
if (node.path.type !== 'PathExpression') {
249233
return;
250234
}
251-
if (inScope(scopeStack, node.path.parts[0])) {
235+
236+
if (inScope(scopeStack, headOf(node.path))) {
252237
return;
253238
}
254239
if (node.path.original === 'if') {
@@ -281,3 +266,34 @@ function inScope(scopeStack: string[][], name: string) {
281266
}
282267
return false;
283268
}
269+
270+
function headOf(path: any) {
271+
if (!path) return;
272+
273+
return 'head' in path ? path.head.name : path.parts[0];
274+
}
275+
276+
function scopeVisitors(env: any, scopeStack: string[][]) {
277+
function enter(node: any) {
278+
if (node.blockParams.length > 0) {
279+
scopeStack.push(node.blockParams);
280+
}
281+
}
282+
function exit(node: any) {
283+
if (node.blockParams.length > 0) {
284+
scopeStack.pop();
285+
}
286+
}
287+
288+
let hasTemplate = 'template' in env.syntax.builders;
289+
if (hasTemplate) {
290+
return {
291+
Template: { enter, exit },
292+
Block: { enter, exit },
293+
};
294+
} else {
295+
return {
296+
Program: { enter, exit },
297+
};
298+
}
299+
}

packages/macros/tests/glimmer/get-config.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ describe(`macroGetConfig`, function () {
2929
});
3030

3131
test('macroGetOwnConfig in subexpression position', function () {
32-
let code = transform(`{{#with (macroGetOwnConfig "mode") as |m|}}{{m}}{{/with}}`);
32+
let code = transform(`{{#let (macroGetOwnConfig "mode") as |m|}}{{m}}{{/let}}`);
3333
expect(code).toMatch(/\{\{#with ["']amazing["'] as |m|\}\}/);
3434
});
3535

3636
test('macroGetConfig in subexpression position', function () {
37-
let code = transform(`{{#with (macroGetConfig "scenario-tester" "color") as |m|}}{{m}}{{/with}}`);
37+
let code = transform(`{{#let (macroGetConfig "scenario-tester" "color") as |m|}}{{m}}{{/let}}`);
3838
expect(code).toMatch(/\{\{#with ["']orange["'] as |m|\}\}/);
3939
});
4040

packages/webpack/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@embroider/webpack",
3-
"version": "4.0.1",
3+
"version": "4.0.3",
44
"private": false,
55
"description": "Builds EmberJS apps with Webpack",
66
"repository": {

tests/fixtures/macro-test/tests/integration/components/common-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module('Integration | Macro | common', function(hooks) {
77
setupRenderingTest(hooks);
88

99
test('our macros do not shadow local variables', async function(assert) {
10-
await render(hbs`{{#with "hello" as |macroDependencySatisfies|}} {{macroDependencySatisfies}} {{/with}}`);
10+
await render(hbs`{{#let "hello" as |macroDependencySatisfies|}} {{macroDependencySatisfies}} {{/let}}`);
1111
assert.equal(this.element.textContent.trim(), 'hello');
1212
});
1313

tests/fixtures/macro-test/tests/integration/components/get-config-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ module('Integration | Macro | getConfig', function(hooks) {
1818
});
1919

2020
test('macroGetOwnConfig in subexpression position', async function(assert) {
21-
await render(hbs`{{#with (macroGetOwnConfig "mode") as |m|}}{{m}}{{/with}}`);
21+
await render(hbs`{{#let (macroGetOwnConfig "mode") as |m|}}{{m}}{{/let}}`);
2222
assert.equal(this.element.textContent.trim(), 'amazing');
2323
});
2424

2525
test('macroGetConfig in subexpression position', async function(assert) {
26-
await render(hbs`{{#with (macroGetConfig "ember-source" "color") as |m|}}{{m}}{{/with}}`);
26+
await render(hbs`{{#let (macroGetConfig "ember-source" "color") as |m|}}{{m}}{{/let}}`);
2727
assert.equal(this.element.textContent.trim(), 'orange');
2828
});
2929

tests/fixtures/macro-test/tests/integration/components/macro-unless-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ module('Integration | Macro | macroCondition + {{unless}}', function (hooks) {
114114
await click('button');
115115
});
116116

117-
test('macroCondition in modifier position when true with no alternate', async function (assert) {
117+
test('macroCondition in modifier position when true with no alternate should do nothing', async function (assert) {
118118
assert.expect(0);
119119
this.doThing = function () {
120120
assert.ok(true, 'it ran');

tests/scenarios/compat-resolver-test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,8 @@ Scenarios.fromProject(() => new Project())
11601160
'templates/application.hbs': `
11611161
{{outlet}}
11621162
{{yield bar}}
1163-
{{#with (hash submit=(action doit)) as |thing| }}
1164-
{{/with}}
1163+
{{#let (hash submit=(action doit)) as |thing| }}
1164+
{{/let}}
11651165
<LinkTo @route="index"/>
11661166
<form {{on "submit" doit}}></form>
11671167
`,
@@ -1170,7 +1170,7 @@ Scenarios.fromProject(() => new Project())
11701170
expectTranspiled('templates/application.hbs').equalsCode(`
11711171
import { precompileTemplate } from "@ember/template-compilation";
11721172
import { on } from "@ember/modifier";
1173-
export default precompileTemplate("\\n {{outlet}}\\n {{yield bar}}\\n {{#with (hash submit=(action doit)) as |thing|}}\\n {{/with}}\\n <LinkTo @route=\\"index\\" />\\n <form {{on \\"submit\\" doit}}></form>\\n ", {
1173+
export default precompileTemplate("\\n {{outlet}}\\n {{yield bar}}\\n {{#let (hash submit=(action doit)) as |thing|}}\\n {{/let}}\\n <LinkTo @route=\\"index\\" />\\n <form {{on \\"submit\\" doit}}></form>\\n ", {
11741174
moduleName: "my-app/templates/application.hbs",
11751175
scope: () => ({
11761176
on,

0 commit comments

Comments
 (0)