Skip to content

Commit

Permalink
fix(ember): Fix backwards compatibility with Embroider changes (#3230)
Browse files Browse the repository at this point in the history
* fix(ember): Fix backwards compatibility with Embroider changes

Switching from ember-get-config to macros introduced a regression for the classic build system, since Embroider injects runtime config differently depending on whether the app is using embroider for it's build system or not. This will grab the config and add it in the included hook when building the addon and including it in an app if embroider is not detected.
  • Loading branch information
k-fish authored Feb 4, 2021
1 parent 02d0ded commit bb83006
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,26 @@ module.exports = {
},
},

getAddonConfig(app) {
let config = {};
try {
config = require(app.options.configPath)(app.env);
} catch(_) {
// Config not found
}
return config['@sentry/ember'] || {};
},

included() {
this._super.included.apply(this, arguments);
const app = this._findHost(this);
if (!('@embroider/core' in app.dependencies())) {
const addonConfig = this.getAddonConfig(app);
const options = Object.assign({}, addonConfig);
this.options['@embroider/macros'].setOwnConfig.sentryConfig = options;
}
},

contentFor(type, config) {
const addonConfig = config['@sentry/ember'] || {};
const app = this._findHost(this);
Expand Down
2 changes: 0 additions & 2 deletions packages/ember/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
"devDependencies": {
"@ember/optional-features": "^1.3.0",
"@embroider/compat": "^0.35.1",
"@embroider/core": "^0.35.1",
"@embroider/webpack": "^0.35.1",
"@glimmer/component": "^1.0.0",
"@glimmer/tracking": "^1.0.0",
"@sentry-internal/eslint-config-sdk": "6.0.4",
Expand Down

0 comments on commit bb83006

Please sign in to comment.