Skip to content

Commit

Permalink
lots of cleanup on peer-deps etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Mar 18, 2023
1 parent 9650d19 commit deec267
Show file tree
Hide file tree
Showing 41 changed files with 700 additions and 1,516 deletions.
4 changes: 2 additions & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# package-import-method=hardlink
# module-exists will report false answers for the test apps
# unless we avoid hoisting
hoist=true
hoist=false
# Fastboot Doesnt respect node_modules resolution for whitelisted deps
# https://github.com/ember-fastboot/ember-cli-fastboot/issues/901
hoist-pattern[]=*abortcontroller-polyfill*
hoist-pattern[]=*node-fetch*

# we want true but cannot use true until the below issue is fixed
# https://github.com/pnpm/pnpm/issues/5340
strict-peer-dependencies=false
dedupe-peer-dependents=true
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@
"node": "^14.8.0 || 16.* || >= 18.*",
"yarn": "use pnpm",
"npm": "use pnpm",
"pnpm": "7.29.1"
"pnpm": "7.30.0"
},
"volta": {
"node": "18.15.0",
"pnpm": "7.29.1"
"pnpm": "7.30.0"
},
"packageManager": "pnpm@7.29.1",
"packageManager": "pnpm@7.30.0",
"changelog": {
"labels": {
"changelog:breaking": ":boom: Breaking Change",
Expand Down
2 changes: 1 addition & 1 deletion packages/-ember-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
57 changes: 42 additions & 15 deletions packages/adapter/addon-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');

const pkg = require('./package.json');

// do our best to detect being present
// Note: when this is not enough, consuming apps may need
// to "hoist" peer-deps or specify us as a direct dependency
// in order to deal with peer-dep bugs in package managers
function detectModule(moduleName) {
try {
// package managers have peer-deps bugs where another library
// bringing a peer-dependency doesn't necessarily result in all
// versions of the dependent getting the peer-dependency
//
// so we resolve from project as well as from our own location
//
// eslint-disable-next-line node/no-missing-require
require.resolve(moduleName, { paths: [process.cwd(), __dirname] });
return true;
} catch {
try {
// ember-data brings all packages so if present we are present
//
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
return true;
} catch {
return false;
}
}
}

module.exports = {
name: pkg.name,

Expand Down Expand Up @@ -30,22 +60,10 @@ module.exports = {
},
hostOptions.debug || {}
);
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE;

try {
// eslint-disable-next-line node/no-missing-require
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] });
HAS_DEBUG_PACKAGE = true;
} catch {
HAS_DEBUG_PACKAGE = false;
}
try {
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
HAS_META_PACKAGE = true;
} catch {
HAS_META_PACKAGE = false;
}
const HAS_DEBUG_PACKAGE = detectModule('@ember-data/debug');
const HAS_META_PACKAGE = detectModule('ember-data');

const includeDataAdapterInProduction =
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
? hostOptions.includeDataAdapterInProduction
Expand All @@ -55,13 +73,22 @@ module.exports = {
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);

const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/addon/available-packages.ts');
const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];

Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
MACRO_PACKAGE_FLAGS[key] = detectModule(MACRO_PACKAGE_FLAGS[key]);
});

// copy configs forward
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
ownConfig.compatWith = hostOptions.compatWith || null;
ownConfig.debug = debugOptions;
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
ownConfig.features = Object.assign({}, FEATURES);
ownConfig.includeDataAdapter = includeDataAdapter;
ownConfig.packages = MACRO_PACKAGE_FLAGS;

this._emberDataConfig = ownConfig;
return ownConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
2 changes: 1 addition & 1 deletion packages/canary-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
2 changes: 1 addition & 1 deletion packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
57 changes: 42 additions & 15 deletions packages/graph/addon-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');

const pkg = require('./package.json');

// do our best to detect being present
// Note: when this is not enough, consuming apps may need
// to "hoist" peer-deps or specify us as a direct dependency
// in order to deal with peer-dep bugs in package managers
function detectModule(moduleName) {
try {
// package managers have peer-deps bugs where another library
// bringing a peer-dependency doesn't necessarily result in all
// versions of the dependent getting the peer-dependency
//
// so we resolve from project as well as from our own location
//
// eslint-disable-next-line node/no-missing-require
require.resolve(moduleName, { paths: [process.cwd(), __dirname] });
return true;
} catch {
try {
// ember-data brings all packages so if present we are present
//
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
return true;
} catch {
return false;
}
}
}

module.exports = {
name: pkg.name,

Expand Down Expand Up @@ -30,22 +60,10 @@ module.exports = {
},
hostOptions.debug || {}
);
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE;

try {
// eslint-disable-next-line node/no-missing-require
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] });
HAS_DEBUG_PACKAGE = true;
} catch {
HAS_DEBUG_PACKAGE = false;
}
try {
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
HAS_META_PACKAGE = true;
} catch {
HAS_META_PACKAGE = false;
}
const HAS_DEBUG_PACKAGE = detectModule('@ember-data/debug');
const HAS_META_PACKAGE = detectModule('ember-data');

const includeDataAdapterInProduction =
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
? hostOptions.includeDataAdapterInProduction
Expand All @@ -55,13 +73,22 @@ module.exports = {
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);

const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/addon/available-packages.ts');
const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];

Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
MACRO_PACKAGE_FLAGS[key] = detectModule(MACRO_PACKAGE_FLAGS[key]);
});

// copy configs forward
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
ownConfig.compatWith = hostOptions.compatWith || null;
ownConfig.debug = debugOptions;
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
ownConfig.features = Object.assign({}, FEATURES);
ownConfig.includeDataAdapter = includeDataAdapter;
ownConfig.packages = MACRO_PACKAGE_FLAGS;

this._emberDataConfig = ownConfig;
return ownConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
57 changes: 42 additions & 15 deletions packages/json-api/addon-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
const requireModule = require('@ember-data/private-build-infra/src/utilities/require-module');

const pkg = require('./package.json');

// do our best to detect being present
// Note: when this is not enough, consuming apps may need
// to "hoist" peer-deps or specify us as a direct dependency
// in order to deal with peer-dep bugs in package managers
function detectModule(moduleName) {
try {
// package managers have peer-deps bugs where another library
// bringing a peer-dependency doesn't necessarily result in all
// versions of the dependent getting the peer-dependency
//
// so we resolve from project as well as from our own location
//
// eslint-disable-next-line node/no-missing-require
require.resolve(moduleName, { paths: [process.cwd(), __dirname] });
return true;
} catch {
try {
// ember-data brings all packages so if present we are present
//
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
return true;
} catch {
return false;
}
}
}

module.exports = {
name: pkg.name,

Expand Down Expand Up @@ -30,22 +60,10 @@ module.exports = {
},
hostOptions.debug || {}
);
let HAS_DEBUG_PACKAGE, HAS_META_PACKAGE;

try {
// eslint-disable-next-line node/no-missing-require
require.resolve('@ember-data/debug', { paths: [process.cwd(), __dirname] });
HAS_DEBUG_PACKAGE = true;
} catch {
HAS_DEBUG_PACKAGE = false;
}
try {
// eslint-disable-next-line node/no-missing-require
require.resolve('ember-data', { paths: [process.cwd(), __dirname] });
HAS_META_PACKAGE = true;
} catch {
HAS_META_PACKAGE = false;
}
const HAS_DEBUG_PACKAGE = detectModule('@ember-data/debug');
const HAS_META_PACKAGE = detectModule('ember-data');

const includeDataAdapterInProduction =
typeof hostOptions.includeDataAdapterInProduction === 'boolean'
? hostOptions.includeDataAdapterInProduction
Expand All @@ -55,13 +73,22 @@ module.exports = {
const DEPRECATIONS = require('@ember-data/private-build-infra/src/deprecations')(hostOptions.compatWith || null);
const FEATURES = require('@ember-data/private-build-infra/src/features')(isProd);

const ALL_PACKAGES = requireModule('@ember-data/private-build-infra/addon/available-packages.ts');
const MACRO_PACKAGE_FLAGS = Object.assign({}, ALL_PACKAGES.default);
delete MACRO_PACKAGE_FLAGS['HAS_DEBUG_PACKAGE'];

Object.keys(MACRO_PACKAGE_FLAGS).forEach((key) => {
MACRO_PACKAGE_FLAGS[key] = detectModule(MACRO_PACKAGE_FLAGS[key]);
});

// copy configs forward
const ownConfig = this.options['@embroider/macros'].setOwnConfig;
ownConfig.compatWith = hostOptions.compatWith || null;
ownConfig.debug = debugOptions;
ownConfig.deprecations = Object.assign(DEPRECATIONS, ownConfig.deprecations || {});
ownConfig.features = Object.assign({}, FEATURES);
ownConfig.includeDataAdapter = includeDataAdapter;
ownConfig.packages = MACRO_PACKAGE_FLAGS;

this._emberDataConfig = ownConfig;
return ownConfig;
Expand Down
2 changes: 1 addition & 1 deletion packages/json-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@7.29.1"
"packageManager": "pnpm@7.30.0"
}
Loading

0 comments on commit deec267

Please sign in to comment.