Skip to content

Commit

Permalink
Run the old preprocessor hack for older versions of embroider
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed May 14, 2023
1 parent 5443885 commit 1353a55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
27 changes: 21 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const Funnel = require('broccoli-funnel');
const chalk = require('chalk');
const BroccoliDebug = require('broccoli-debug');
const VersionChecker = require('ember-cli-version-checker');
const camelCase = require('camelcase');
const { createHash } = require('crypto');
const _ = require('lodash');
Expand Down Expand Up @@ -208,14 +209,28 @@ module.exports = {
},

setupPreprocessorRegistry(type, registry) {
// The canvas plugin should run on `self` and `parent`.
this._setupCanvasPlugin(registry);
let checker = new VersionChecker(this.project);
let embroider = checker.for('@embroider/core');

if (embroider.lt('2.0.0') && this.checkIfWillProbablyUseEmbroider()) {
// `type === 'self'` is broken in older Embroider versions. It doesn’t seem
// to correctly pass the plugins to `broccoli-babel-transpiler`. This works
// for some reason.
if (type === 'parent') {
this._setupCanvasPlugin(registry);
this._setupAddonPlugin(registry);
this._setupTreeshakerPlugin(registry);
}
} else {
// The canvas plugin should run on `self` and `parent`.
this._setupCanvasPlugin(registry);

if (type === 'self') {
// The addon plugin should run on `self`.
this._setupAddonPlugin(registry);
if (type === 'self') {
// The addon plugin should run on `self`.
this._setupAddonPlugin(registry);

this._setupTreeshakerPlugin(registry);
this._setupTreeshakerPlugin(registry);
}
}
},

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ember-auto-import": "^2.6.3",
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.2.0",
"ember-cli-version-checker": "^5.1.2",
"ember-concurrency": "^3.0.0",
"ember-modifier": "^3.2.7",
"lodash": "^4.17.21",
Expand Down

0 comments on commit 1353a55

Please sign in to comment.