Skip to content

Commit

Permalink
refactor(enhanced): update shareKey handling to include layer context
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Dec 31, 2024
1 parent c44c96b commit 1376c4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 3 additions & 1 deletion packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ class ConsumeSharedPlugin {
return {
import: item.import === false ? undefined : item.import || request,
shareScope: item.shareScope || options.shareScope || 'default',
shareKey: item.shareKey || request,
shareKey: item.layer
? `(${item.layer})${item.shareKey || request}`
: item.shareKey || request,
requiredVersion:
item.requiredVersion === false
? false
Expand Down
27 changes: 16 additions & 11 deletions packages/enhanced/src/lib/sharing/ProvideSharedPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,22 @@ class ProvideSharedPlugin {
};
return result;
},
(item, key) => ({
shareKey: item.shareKey || key,
version: item.version,
shareScope: item.shareScope || options.shareScope || 'default',
eager: !!item.eager,
requiredVersion: item.requiredVersion || false,
strictVersion: item.strictVersion || false,
singleton: item.singleton || false,
layer: item.layer,
request: item.request || key,
}),
(item, key) => {
const request = item.request || key;
return {
shareScope: item.shareScope || options.shareScope || 'default',
shareKey: item.layer
? `(${item.layer})${item.shareKey || request}`
: item.shareKey || request,
version: item.version,
eager: !!item.eager,
requiredVersion: item.requiredVersion,
strictVersion: item.strictVersion,
singleton: !!item.singleton,
layer: item.layer,
request,
};
},
);
this._provides.sort(([a], [b]) => {
if (a < b) return -1;
Expand Down
8 changes: 2 additions & 6 deletions packages/enhanced/src/lib/sharing/SharePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class SharePlugin {
([key, options]) => ({
[key]: {
import: options.import,
shareKey: options.layer
? `(${options.layer})${options.shareKey || key}`
: options.shareKey || key,
shareKey: options.shareKey || key,
shareScope: options.shareScope,
requiredVersion: options.requiredVersion,
strictVersion: options.strictVersion,
Expand All @@ -64,9 +62,7 @@ class SharePlugin {
.filter(([, options]) => options.import !== false)
.map(([key, options]) => ({
[options.import || key]: {
shareKey: options.layer
? `(${options.layer})${options.shareKey || key}`
: options.shareKey || key,
shareKey: options.shareKey || key,
shareScope: options.shareScope,
version: options.version,
eager: options.eager,
Expand Down

0 comments on commit 1376c4a

Please sign in to comment.