Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-157555: Remove useless logic and putting import commerce.js top. #2906

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createTag, getConfig, loadArea, loadScript, loadStyle, localizeLink,
} from '../../utils/utils.js';
import { replaceKey } from '../../features/placeholders.js';
import '../../deps/mas/commerce.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? This is also being imported in L427

Copy link
Contributor Author

@seanchoi-dev seanchoi-dev Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we want to start to load this ASAP when merch.js get loaded.
This is what task's description says:
"Remove the related logic and move import of commerce.js to the top."


export const CHECKOUT_LINK_CONFIG_PATH = '/commerce/checkout-link.json'; // relative to libs.

Expand Down Expand Up @@ -422,14 +423,7 @@ export async function initService(force = false) {
}
const { env, commerce = {}, locale } = getConfig();
initService.promise = initService.promise ?? polyfills().then(async () => {
const { hostname, searchParams } = new URL(window.location.href);
let commerceLibPath = '../../deps/mas/commerce.js';
if (/hlx\.(page|live)$|localhost$|www\.stage\.adobe\.com$/.test(hostname)) {
const maslibs = searchParams.get('maslibs');
if (maslibs) {
commerceLibPath = `${getMasBase(hostname, maslibs)}/libs/commerce.js`;
}
}
const commerceLibPath = '../../deps/mas/commerce.js';
seanchoi-dev marked this conversation as resolved.
Show resolved Hide resolved
const commerceLib = await import(commerceLibPath);
const service = await commerceLib.init(() => ({
env,
Expand Down
Loading