Skip to content

Commit

Permalink
MWPW-153629: Removal of merch-card-all dep (#2698)
Browse files Browse the repository at this point in the history
* Removal of merch-card-all dep

* improved dep imports

* Update mas.js

* Update mas.js

* removed sequential imports

* pr feedback

* fixes
  • Loading branch information
Axelcureno authored Aug 20, 2024
1 parent dad8c45 commit f7608be
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1,706 deletions.
1,688 changes: 0 additions & 1,688 deletions libs/deps/mas/merch-card-all.js

This file was deleted.

7 changes: 5 additions & 2 deletions libs/features/mas/mas/src/mas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { init } from '@adobe/mas-commerce';

const { origin, searchParams } = new URL(import.meta.url);

const locale = searchParams.get('locale') ?? 'US_en';
Expand All @@ -19,5 +18,9 @@ const config = () => ({
init(config);

if (features.includes('merch-card')) {
import(`${origin}/libs/deps/merch-card-all.js`);
await Promise.allSettled([
import('../../web-components/src/merch-card.js'),
import('../../web-components/src/merch-icon.js'),
import('../../web-components/src/merch-datasource.js'),
]);
}
4 changes: 3 additions & 1 deletion libs/features/mas/mocks/mas.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { init } from '@adobe/mas-commerce';
import '@adobe/mas-web-components/src/merch-card-all.js';
import '../../../web-components/src/merch-card.js';
import '../../../web-components/src/merch-icon.js';
import '../../../web-components/src/merch-datasource.js';

const locale =
document
Expand Down
8 changes: 0 additions & 8 deletions libs/features/mas/web-components/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ async function buildLitComponent(name) {
}

Promise.all([
build({
bundle: true,
format: 'esm',
entryPoints: ['./src/merch-card-all.js'],
minify: true,
outfile: `${outfolder}/merch-card-all.js`,
sourcemap: true,
}),
build({
bundle: true,
stdin: { contents: '' },
Expand Down
3 changes: 0 additions & 3 deletions libs/features/mas/web-components/src/merch-card-all.js

This file was deleted.

8 changes: 4 additions & 4 deletions libs/features/mas/web-components/src/merch-datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ const cardContent = {
};

async function parseMerchCard(item, merchCard) {
const cardJson = item.fields.reduce((acc, { name, multiple, values }) => {
acc[name] = multiple ? values : values[0];
return acc;
}, {});
const cardJson = Array.isArray(item.fields) ? item.fields.reduce((acc, { name, multiple, values }) => {
acc[name] = multiple ? values : values[0];
return acc;
}, {}) : {};
const { type = 'catalog' } = cardJson;
const cardType = cardContent[type] || cardContent.catalog;

Expand Down

0 comments on commit f7608be

Please sign in to comment.