Skip to content

Commit

Permalink
Merge pull request #1886 from embroider-build/merge-stable
Browse files Browse the repository at this point in the history
Merge stable into main
  • Loading branch information
mansona committed Apr 22, 2024
2 parents fad2387 + c4a8fc2 commit ea895c2
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 133 deletions.
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Embroider Changelog

## Release (2024-04-18)

@embroider/compat 3.4.8 (patch)
@embroider/core 3.4.8 (patch)
@embroider/macros 1.16.0 (minor)
@embroider/test-setup 4.0.0 (major)
@embroider/webpack 4.0.0 (major)

#### :boom: Breaking Change
* `@embroider/webpack`
* [#1868](https://github.com/embroider-build/embroider/pull/1868) Adjusting `@embroider/webpack` to use `@babel/preset-env` to avoid critical security audit ([@lupestro](https://github.com/lupestro))

#### :rocket: Enhancement
* `@embroider/macros`, `@embroider/test-fixtures`
* [#1858](https://github.com/embroider-build/embroider/pull/1858) Add support for `{{unless}}` to the `macroCondition` macro ([@Windvis](https://github.com/Windvis))

#### :bug: Bug Fix
* `@embroider/core`, `@embroider/test-scenarios`
* [#1885](https://github.com/embroider-build/embroider/pull/1885) Fix pre support in portable babel launcher ([@ef4](https://github.com/ef4))

#### Committers: 3
- Edward Faulkner ([@ef4](https://github.com/ef4))
- Ralph Mack ([@lupestro](https://github.com/lupestro))
- Sam Van Campenhout ([@Windvis](https://github.com/Windvis))

## Release (2024-04-10)

@embroider/addon-dev 4.3.1 (patch)

#### :bug: Bug Fix
* `@embroider/addon-dev`, `@embroider/test-scenarios`
* [#1874](https://github.com/embroider-build/embroider/pull/1874) with namespace in publicAssets don't include path ([@mansona](https://github.com/mansona))

#### Committers: 1
- Chris Manson ([@mansona](https://github.com/mansona))

## Release (2024-04-10)

@embroider/addon-dev 4.3.0 (minor)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"overrides": {
"browserslist": "^4.14.0",
"graceful-fs": "^4.0.0",
"@types/eslint": "^8.37.0"
"@types/eslint": "^8.37.0",
"babel-plugin-module-resolver@5.0.1": "5.0.0"
}
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/addon-dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/

### addon.publicAssets(path <required>, options)

A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name
A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.

## addon-dev command

Expand Down
2 changes: 1 addition & 1 deletion packages/addon-dev/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/addon-dev",
"version": "4.3.0",
"version": "4.3.1",
"description": "Utilities for addon authors",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/addon-dev/src/rollup-public-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export default function publicAssets(
});
const publicAssets: Record<string, string> = filenames.reduce(
(acc: Record<string, string>, v): Record<string, string> => {
acc[`./${path}/${v}`] = resolve(
'/' + join(opts?.namespace ?? pkg.name, path, v)
);
const namespace = opts?.namespace ?? join(pkg.name, path);

acc[`./${path}/${v}`] = resolve('/' + join(namespace, v));
return acc;
},
{}
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/compat",
"version": "3.4.7",
"version": "3.4.8",
"private": false,
"description": "Backward compatibility layer for the Embroider build system.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/core",
"version": "3.4.7",
"version": "3.4.8",
"private": false,
"description": "A build system for EmberJS applications.",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/portable-babel-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export default function babelLauncher(

function wrap1(original: any) {
if (typeof original === 'function') {
return function (this: any, state: any) {
return original.call(this, convertState(state));
return function (this: any, file: any) {
return original.call(convertState(this), file);
};
}
}

function wrap2(original: Function) {
return function (this: any, path: any, state: any) {
return original.call(this, path, convertState(state));
return original.call(convertState(this), path, convertState(state));
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/macros/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/macros",
"version": "1.15.1",
"version": "1.16.0",
"private": false,
"description": "Standardized build-time macros for ember apps.",
"keywords": [
Expand Down
28 changes: 27 additions & 1 deletion packages/macros/src/glimmer/ast-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import literal from './literal';
import getConfig from './get-config';
import dependencySatisfies from './dependency-satisfies';
import { maybeAttrs } from './macro-maybe-attrs';
import { macroIfBlock, macroIfExpression, macroIfMustache } from './macro-condition';
import {
macroIfBlock,
macroIfExpression,
macroIfMustache,
macroUnlessBlock,
macroUnlessExpression,
macroUnlessMustache,
} from './macro-condition';
import { failBuild } from './fail-build';
import { RewrittenPackageCache } from '@embroider/shared-internals';

Expand Down Expand Up @@ -181,6 +188,9 @@ export function makeSecondTransform() {
if (node.path.original === 'if') {
return macroIfBlock(node);
}
if (node.path.original === 'unless') {
return macroUnlessBlock(node);
}
},
SubExpression(node: any) {
if (node.path.type !== 'PathExpression') {
Expand All @@ -192,6 +202,9 @@ export function makeSecondTransform() {
if (node.path.original === 'if') {
return macroIfExpression(node, env.syntax.builders);
}
if (node.path.original === 'unless') {
return macroUnlessExpression(node, env.syntax.builders);
}
if (node.path.original === 'macroFailBuild') {
failBuild(node);
}
Expand All @@ -208,6 +221,16 @@ export function makeSecondTransform() {
return false;
}
}
if (
modifier.path.type === 'SubExpression' &&
modifier.path.path.type === 'PathExpression' &&
modifier.path.path.original === 'unless'
) {
modifier.path = macroUnlessExpression(modifier.path, env.syntax.builders);
if (modifier.path.type === 'UndefinedLiteral') {
return true;
}
}
if (modifier.path.type !== 'PathExpression') {
return true;
}
Expand All @@ -231,6 +254,9 @@ export function makeSecondTransform() {
if (node.path.original === 'if') {
return macroIfMustache(node, env.syntax.builders);
}
if (node.path.original === 'unless') {
return macroUnlessMustache(node, env.syntax.builders);
}
if (node.path.original === 'macroFailBuild') {
failBuild(node);
}
Expand Down
64 changes: 64 additions & 0 deletions packages/macros/src/glimmer/macro-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,67 @@ export function macroIfMustache(node: any, builders: any) {

return builders.mustache(result);
}

export function macroUnlessBlock(node: any) {
let condition = node.params[0];

if (!condition || condition.type !== 'SubExpression' || condition.path.original !== 'macroCondition') {
return node;
}

if (condition.params.length !== 1) {
throw new Error(`macroCondition requires one arguments, you passed ${node.params.length}`);
}

let result = evaluate(condition.params[0]);
if (!result.confident) {
throw new Error(`argument to macroCondition must be statically analyzable`);
}

if (result.value) {
if (node.inverse) {
return node.inverse.body;
} else {
return [];
}
} else {
return node.program.body;
}
}

export function macroUnlessExpression(node: any, builders: any) {
let condition = node.params[0];

if (!condition || condition.type !== 'SubExpression' || condition.path.original !== 'macroCondition') {
return node;
}

if (condition.params.length !== 1) {
throw new Error(`macroCondition requires one arguments, you passed ${node.params.length}`);
}

let result = evaluate(condition.params[0]);
if (!result.confident) {
throw new Error(`argument to macroCondition must be statically analyzable`);
}

if (result.value) {
return node.params[2] || builders.undefined();
} else {
return node.params[1];
}
}

export function macroUnlessMustache(node: any, builders: any) {
let result = macroUnlessExpression(node, builders);

if (result === node) {
return node;
}

if (result.type === 'SubExpression') {
return builders.mustache(result.path, result.params, result.hash);
}

return builders.mustache(result);
}
2 changes: 1 addition & 1 deletion packages/test-setup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/test-setup",
"version": "3.0.3",
"version": "4.0.0",
"repository": {
"type": "git",
"url": "https://github.com/embroider-build/embroider.git",
Expand Down
4 changes: 2 additions & 2 deletions packages/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@embroider/webpack",
"version": "3.2.3",
"version": "4.0.0",
"private": false,
"description": "Builds EmberJS apps with Webpack",
"repository": {
Expand All @@ -19,13 +19,13 @@
"scripts": {},
"dependencies": {
"@babel/core": "^7.14.5",
"@babel/preset-env": "^7.14.5",
"@embroider/babel-loader-9": "workspace:*",
"@embroider/hbs-loader": "workspace:*",
"@embroider/shared-internals": "workspace:*",
"@types/supports-color": "^8.1.0",
"assert-never": "^1.2.1",
"babel-loader": "^8.2.2",
"babel-preset-env": "^1.7.0",
"css-loader": "^5.2.6",
"csso": "^4.2.0",
"debug": "^4.3.2",
Expand Down
Loading

0 comments on commit ea895c2

Please sign in to comment.