Skip to content

Commit

Permalink
Fix an issue with Ember Data v4.12
Browse files Browse the repository at this point in the history
Adding the compatAdapters is a temporary workaround until the issue is resolved upstream somehow.

More information: embroider-build/embroider#1506
  • Loading branch information
Windvis committed Jul 12, 2023
1 parent c2d63d3 commit 8fb4947
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');
const { V1Addon } = require('@embroider/compat');

module.exports = function (defaults) {
let app = new EmberApp(defaults, {
Expand All @@ -18,5 +19,47 @@ module.exports = function (defaults) {
staticModifiers: true,
staticComponents: true,
splitAtRoutes: ['map'],

// These compatAdapters are needed to work around an Ember Data v4.12 + Embroider issue
// We can remove them once the issue is fixed or when we update to v5.4 since supposedly it's not an issue there
// https://github.com/embroider-build/embroider/issues/1506
compatAdapters: new Map([
[
// Copy of the Embroider version without the version check: https://github.com/embroider-build/embroider/blob/main/packages/compat/src/compat-adapters/%40ember-data/debug.ts
'@ember-data/debug',
class EmberDataDebugCompatAdapter extends V1Addon {
get packageMeta() {
let meta = super.packageMeta;

// See also the compat-adapter for @ember-data/store where we make this an
// implicit-module.
meta.externals = [...(meta.externals ?? []), '@ember-data/store'];

return meta;
}
},
],
[
// Copy of the Embroider version without the version check: https://github.com/embroider-build/embroider/blob/main/packages/compat/src/compat-adapters/%40ember-data/store.ts
'@ember-data/store',
class EmberDataStoreCompatAdapter extends V1Addon {
get packageMeta() {
let meta = super.packageMeta;

// this is here because the compat-adapter for @ember-data/debug adds this
// to externals because it has an undeclared peerDep on us, and thus might
// resolve totally incorrect copies. By making it external we leave it up to
// runtime, where we will find this implicit-module for the actual copy of
// @ember-data/store that is active in app.
meta['implicit-modules'] = [
...(meta['implicit-modules'] ?? []),
'./index.js',
];

return meta;
}
},
],
]),
});
};

0 comments on commit 8fb4947

Please sign in to comment.