From 3c8d50229a467b6fb42f9e28d9d32d13a1c94498 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Fri, 2 Jul 2021 10:42:18 -0700 Subject: [PATCH 1/2] Undefined does not serialize under broccoli-babel-transpiler When broccoli-babel-transpiler tries to determine in a plugin is serializable it checks for certain types: https://github.com/babel/broccoli-babel-transpiler/blob/416732dd5d57b9f29dad7afd7f7cae76f0ac1606/lib/parallel-api.js#L45-L61. If the value is undefined it is not serializable and thus not parallelizable. Since we are just checking for truthyness of the appPackageRoot value we can instead use an empty string. This also satisfies the babel type which is string | undefined. --- packages/macros/src/babel/state.ts | 2 +- packages/macros/src/macros-config.ts | 2 +- tests/scenarios/macro-test.ts | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/macros/src/babel/state.ts b/packages/macros/src/babel/state.ts index 2e91d50ec..a036a4c09 100644 --- a/packages/macros/src/babel/state.ts +++ b/packages/macros/src/babel/state.ts @@ -40,7 +40,7 @@ export default interface State { // the package root directory of the app, if the app is under active // development. Needed so that we can get consistent answers to // `isDevelopingApp` and `isDeveopingThisPackage` - appPackageRoot: string | undefined; + appPackageRoot: string; embroiderMacrosConfigMarker: true; diff --git a/packages/macros/src/macros-config.ts b/packages/macros/src/macros-config.ts index 3d46a2436..275ead917 100644 --- a/packages/macros/src/macros-config.ts +++ b/packages/macros/src/macros-config.ts @@ -245,7 +245,7 @@ export default class MacrosConfig { owningPackageRoot, isDevelopingPackageRoots: [...this.isDevelopingPackageRoots].map(root => this.moves.get(root) || root), - appPackageRoot: this.appPackageRoot ? this.moves.get(this.appPackageRoot) || this.appPackageRoot : undefined, + appPackageRoot: this.appPackageRoot ? this.moves.get(this.appPackageRoot) || this.appPackageRoot : '', // This is used as a signature so we can detect ourself among the plugins // emitted from v1 addons. diff --git a/tests/scenarios/macro-test.ts b/tests/scenarios/macro-test.ts index 126dff9f1..787a61ec6 100644 --- a/tests/scenarios/macro-test.ts +++ b/tests/scenarios/macro-test.ts @@ -43,6 +43,11 @@ appScenarios assert.equal(result.exitCode, 0, result.output); }); + test(`yarn test production`, async function (assert) { + let result = await app.execute(`cross-env THROW_UNLESS_PARALLELIZABLE=1 EMBER_ENV='production' yarn test`); + assert.equal(result.exitCode, 0, result.output); + }); + test(`CLASSIC=true yarn test`, async function (assert) { // throw_unless_parallelizable is enabled to ensure that @embroider/macros is parallelizable let result = await app.execute(`cross-env THROW_UNLESS_PARALLELIZABLE=1 CLASSIC=true yarn test`); From 2c0af5d0036177d896afead40b16f475aa67fbf7 Mon Sep 17 00:00:00 2001 From: Travis Hoover Date: Fri, 2 Jul 2021 11:37:14 -0700 Subject: [PATCH 2/2] adding production check in tests --- tests/app-template/package.json | 1 + tests/scenarios/macro-test.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/app-template/package.json b/tests/app-template/package.json index 1cb273c20..c8e365066 100644 --- a/tests/app-template/package.json +++ b/tests/app-template/package.json @@ -12,6 +12,7 @@ }, "scripts": { "build": "ember build", + "build:production": "ember build -prod", "lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"", "lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix", "lint:hbs": "ember-template-lint .", diff --git a/tests/scenarios/macro-test.ts b/tests/scenarios/macro-test.ts index 787a61ec6..7ddcfe3c4 100644 --- a/tests/scenarios/macro-test.ts +++ b/tests/scenarios/macro-test.ts @@ -43,8 +43,8 @@ appScenarios assert.equal(result.exitCode, 0, result.output); }); - test(`yarn test production`, async function (assert) { - let result = await app.execute(`cross-env THROW_UNLESS_PARALLELIZABLE=1 EMBER_ENV='production' yarn test`); + test(`yarn build production`, async function (assert) { + let result = await app.execute(`cross-env THROW_UNLESS_PARALLELIZABLE=1 yarn build:production`); assert.equal(result.exitCode, 0, result.output); });