Skip to content

Commit e3eb39c

Browse files
dcyrillerrunspired
authored andcommitted
Throw an error in case of dependency mismatch (#2)
* Throw an error in case of dependency mismatch An app (or addon) that consumes ember-data should have: - either jquery - or ember-fetch version 6.0.0 or above Throw a build error if it's not the case. * Remove ember-fetch as a peerDependency
1 parent d6d92fc commit e3eb39c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

index.js

+14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const version = require('./lib/version');
88
const { isInstrumentedBuild } = require('./lib/cli-flags');
99
const BroccoliDebug = require('broccoli-debug');
1010
const calculateCacheKeyForTree = require('calculate-cache-key-for-tree');
11+
const VersionChecker = require('ember-cli-version-checker');
1112

1213
function isProductionEnv() {
1314
let isProd = /production/.test(process.env.EMBER_ENV);
@@ -60,6 +61,19 @@ module.exports = {
6061

6162
init() {
6263
this._super.init && this._super.init.apply(this, arguments);
64+
65+
let checker = new VersionChecker(this.parent);
66+
let hasJQuery = checker.for('@ember/jquery').exists();
67+
let hasEmberFetch = checker.for('ember-fetch').isAbove('6.0.0');
68+
if (!hasJQuery && !hasEmberFetch) {
69+
throw new Error(
70+
'To use ember-data, you need either @ember/jquery or ember-fetch@>=6 ' +
71+
'package. You may already have jquery in your app. In that case, ' +
72+
'you will have to explicitely opt into it. More info here: ' +
73+
'https://guides.emberjs.com/release/configuring-ember/optional-features/#toc_jquery-integration'
74+
);
75+
}
76+
6377
this._prodLikeWarning();
6478
this.debugTree = BroccoliDebug.buildDebugCallback('ember-data');
6579
this.options = this.options || {};

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262
"semver": "^5.6.0",
6363
"silent-error": "^1.1.1"
6464
},
65-
"peerDependencies": {
66-
"ember-fetch": "^6.2.2"
67-
},
6865
"devDependencies": {
6966
"@babel/plugin-transform-typescript": "^7.2.0",
7067
"@ember-decorators/babel-transforms": "^5.1.4",

0 commit comments

Comments
 (0)