From d38bb7eaec81edc1274474a24259d6c3224b3c9c Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 2 Feb 2022 16:33:28 +0100 Subject: [PATCH] Properly use @embroider/test-setup --- .github/workflows/ci.yml | 1 + config/ember-try.js | 48 +++------------------------------------- ember-cli-build.js | 32 +++++++++++++++++---------- package.json | 1 + yarn.lock | 8 +++++++ 5 files changed, 33 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6466467a..f6ca07d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,7 @@ jobs: - ember-classic - ember-default-with-jquery - embroider-safe + - embroider-optimized steps: - uses: actions/checkout@v2 diff --git a/config/ember-try.js b/config/ember-try.js index f3ff9e0b..d1e0a263 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,36 +1,7 @@ 'use strict'; const getChannelURL = require('ember-source-channel-url'); -const EMBROIDER_VERSION = '^0.43.4'; -const embroider = { - safe: { - name: 'embroider-safe', - npm: { - devDependencies: { - '@embroider/core': EMBROIDER_VERSION, - '@embroider/webpack': EMBROIDER_VERSION, - '@embroider/compat': EMBROIDER_VERSION, - }, - }, - env: { - EMBROIDER_TEST_SETUP_OPTIONS: 'safe', - }, - }, - - optimized: { - name: 'embroider-optimized', - npm: { - devDependencies: { - '@embroider/core': EMBROIDER_VERSION, - '@embroider/webpack': EMBROIDER_VERSION, - '@embroider/compat': EMBROIDER_VERSION, - }, - }, - env: { - EMBROIDER_TEST_SETUP_OPTIONS: 'optimized', - }, - }, -}; +const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup'); module.exports = async function () { return { @@ -145,21 +116,8 @@ module.exports = async function () { devDependencies: {}, }, }, - embroider.safe, - // disable embroider optimized test scenarios, as the dynamism these - // tests use is not compatible with embroider we are still exploring - // appropriate paths forward. - // - // Steps to re-enable: - // - // 1. have a strategy to make this work - // 2. uncomment the next line - // embroider.optimized, - // - // 3. add "embroider-optimized" to .github/workflows/ci-build.yml's - // ember-try-scenario list. - // - // embroiderOptimized(), disabled because of: https://github.com/embroider-build/embroider/issues/522 + embroiderSafe(), + embroiderOptimized(), ], }; }; diff --git a/ember-cli-build.js b/ember-cli-build.js index b7bca889..3801532d 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -10,16 +10,24 @@ module.exports = function (defaults) { }, }); - try { - const { maybeEmbroider } = require('@embroider/test-setup'); // eslint-disable-line node/no-missing-require - return maybeEmbroider(app); - } catch (e) { - // This exists, so that we can continue to support node 10 for some of our - // test scenarios. Specifically those not scenario testing embroider. As - // @embroider/test-setup and @embroider in no longer supports node 10 - if (e !== null && typeof e === 'object' && e.code === 'MODULE_NOT_FOUND') { - return app.toTree(); - } - throw e; - } + const { maybeEmbroider } = require('@embroider/test-setup'); + return maybeEmbroider(app, { + packageRules: [ + { + // See: https://github.com/embroider-build/embroider/issues/522 + package: 'dummy', + components: { + '{{template-only}}': { + safeToIgnore: true, + }, + '{{js-only}}': { + safeToIgnore: true, + }, + '{{jax}}': { + safeToIgnore: true, + }, + }, + }, + ], + }); }; diff --git a/package.json b/package.json index 064fd9dc..317c139f 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "devDependencies": { "@ember/optional-features": "^2.0.0", "@ember/test-helpers": "^2.4.2", + "@embroider/test-setup": "^1.0.0", "babel-eslint": "^10.1.0", "ember-angle-bracket-invocation-polyfill": "^3.0.1", "ember-cli": "~3.27.0", diff --git a/yarn.lock b/yarn.lock index 14de3229..7f3b35b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1048,6 +1048,14 @@ semver "^7.3.5" typescript-memoize "^1.0.1" +"@embroider/test-setup@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@embroider/test-setup/-/test-setup-1.0.0.tgz#f0841345326bcb55eee8437be37f3a8207146b37" + integrity sha512-jnrzNyL0mUZ+DTY59s4Yr/V+NgECpwKxuxdKJOr0hNCxC6Kpo5Dagjz22tEyiMOkZhuDdZ4qAqmTUpeu8taLnQ== + dependencies: + lodash "^4.17.21" + resolve "^1.20.0" + "@eslint/eslintrc@^0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c"