Skip to content

Commit

Permalink
Merge pull request #2248 from graphcommerce-org/hotfix/dependency-exp…
Browse files Browse the repository at this point in the history
…ression

Hotfix 8.0.x: Dependency is an expression and bundlesize of @apollo/client
  • Loading branch information
paales authored May 16, 2024
2 parents b92b3b4 + e262419 commit 4a8611e
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-boats-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphcommerce/magento-cart-payment-method": patch
---

Compatibility with Magento 2.4.7
5 changes: 5 additions & 0 deletions .changeset/large-coins-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphcommerce/next-config": patch
---

reduce bundlesize of @apollo/client
6 changes: 6 additions & 0 deletions .changeset/spotty-ads-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphcommerce/next-config": patch
"@graphcommerce/graphql-mesh": patch
---

Suppress warning where a dependency is an expression, Added uglify-es and long as the dependencies couldn’t be found
5 changes: 4 additions & 1 deletion packages/graphql-mesh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"@graphql-tools/utils": "^10.0.12",
"@whatwg-node/fetch": "^0.9.15",
"fetch-retry": "^5.0.6",
"tslib": "^2.6.2"
"long": "^5.2.3",
"tslib": "^2.6.2",
"uglify-es": "3.3.9"
},
"peerDependencies": {
"@apollo/client": "^3",
Expand All @@ -30,6 +32,7 @@
"graphql": "^16.7.1"
},
"devDependencies": {
"@types/uglify-es": "^3",
"typescript": "5.3.3"
},
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function PaymentMethodPlaceOrderNoop(props: PaymentPlaceOrderProps) {

const form = useFormGqlMutationCart(PaymentMethodPlaceOrderNoopDocument, {
onComplete: async (result) => {
if (!result.data?.placeOrder) return
if (!result.data?.placeOrder?.order) return
await onSuccess(result.data.placeOrder.order.order_number)
},
})
Expand Down
195 changes: 120 additions & 75 deletions packagesDev/next-config/dist/generated/config.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,146 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SidebarGalleryConfigSchema = exports.RecentlyViewedProductsConfigSchema = exports.MagentoConfigurableVariantValuesSchema = exports.GraphCommerceStorefrontConfigSchema = exports.GraphCommerceDebugConfigSchema = exports.GraphCommerceConfigSchema = exports.DatalayerConfigSchema = exports.SidebarGalleryPaginationVariantSchema = exports.ProductFiltersLayoutSchema = exports.CompareVariantSchema = exports.definedNonNullAnySchema = exports.isDefinedNonNullAny = void 0;
/* eslint-disable */
const zod_1 = require("zod");
const isDefinedNonNullAny = (v) => v !== undefined && v !== null;
exports.isDefinedNonNullAny = isDefinedNonNullAny;
exports.definedNonNullAnySchema = zod_1.z.any().refine((v) => (0, exports.isDefinedNonNullAny)(v));
exports.CompareVariantSchema = zod_1.z.enum(['CHECKBOX', 'ICON']);
exports.ProductFiltersLayoutSchema = zod_1.z.enum(['DEFAULT', 'SIDEBAR']);
exports.SidebarGalleryPaginationVariantSchema = zod_1.z.enum(['DOTS', 'THUMBNAILS_BOTTOM']);
/* eslint-disable */ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
CompareVariantSchema: function() {
return CompareVariantSchema;
},
DatalayerConfigSchema: function() {
return DatalayerConfigSchema;
},
GraphCommerceConfigSchema: function() {
return GraphCommerceConfigSchema;
},
GraphCommerceDebugConfigSchema: function() {
return GraphCommerceDebugConfigSchema;
},
GraphCommerceStorefrontConfigSchema: function() {
return GraphCommerceStorefrontConfigSchema;
},
MagentoConfigurableVariantValuesSchema: function() {
return MagentoConfigurableVariantValuesSchema;
},
ProductFiltersLayoutSchema: function() {
return ProductFiltersLayoutSchema;
},
RecentlyViewedProductsConfigSchema: function() {
return RecentlyViewedProductsConfigSchema;
},
SidebarGalleryConfigSchema: function() {
return SidebarGalleryConfigSchema;
},
SidebarGalleryPaginationVariantSchema: function() {
return SidebarGalleryPaginationVariantSchema;
},
definedNonNullAnySchema: function() {
return definedNonNullAnySchema;
},
isDefinedNonNullAny: function() {
return isDefinedNonNullAny;
}
});
const _zod = require("zod");
const isDefinedNonNullAny = (v)=>v !== undefined && v !== null;
const definedNonNullAnySchema = _zod.z.any().refine((v)=>isDefinedNonNullAny(v));
const CompareVariantSchema = _zod.z.enum([
"CHECKBOX",
"ICON"
]);
const ProductFiltersLayoutSchema = _zod.z.enum([
"DEFAULT",
"SIDEBAR"
]);
const SidebarGalleryPaginationVariantSchema = _zod.z.enum([
"DOTS",
"THUMBNAILS_BOTTOM"
]);
function DatalayerConfigSchema() {
return zod_1.z.object({
coreWebVitals: zod_1.z.boolean().nullish()
return _zod.z.object({
coreWebVitals: _zod.z.boolean().nullish()
});
}
exports.DatalayerConfigSchema = DatalayerConfigSchema;
function GraphCommerceConfigSchema() {
return zod_1.z.object({
canonicalBaseUrl: zod_1.z.string().min(1),
cartDisplayPricesInclTax: zod_1.z.boolean().nullish(),
compare: zod_1.z.boolean().nullish(),
compareVariant: exports.CompareVariantSchema.nullish(),
configurableVariantForSimple: zod_1.z.boolean().nullish(),
return _zod.z.object({
canonicalBaseUrl: _zod.z.string().min(1),
cartDisplayPricesInclTax: _zod.z.boolean().nullish(),
compare: _zod.z.boolean().nullish(),
compareVariant: CompareVariantSchema.nullish(),
configurableVariantForSimple: _zod.z.boolean().nullish(),
configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(),
crossSellsHideCartItems: zod_1.z.boolean().nullish(),
crossSellsRedirectItems: zod_1.z.boolean().nullish(),
customerRequireEmailConfirmation: zod_1.z.boolean().nullish(),
crossSellsHideCartItems: _zod.z.boolean().nullish(),
crossSellsRedirectItems: _zod.z.boolean().nullish(),
customerRequireEmailConfirmation: _zod.z.boolean().nullish(),
dataLayer: DatalayerConfigSchema().nullish(),
debug: GraphCommerceDebugConfigSchema().nullish(),
demoMode: zod_1.z.boolean().nullish(),
enableGuestCheckoutLogin: zod_1.z.boolean().nullish(),
googleAnalyticsId: zod_1.z.string().nullish(),
googleRecaptchaKey: zod_1.z.string().nullish(),
googleTagmanagerId: zod_1.z.string().nullish(),
hygraphEndpoint: zod_1.z.string().min(1),
hygraphManagementApi: zod_1.z.string().nullish(),
hygraphProjectId: zod_1.z.string().nullish(),
hygraphWriteAccessEndpoint: zod_1.z.string().nullish(),
hygraphWriteAccessToken: zod_1.z.string().nullish(),
limitSsg: zod_1.z.boolean().nullish(),
magentoEndpoint: zod_1.z.string().min(1),
previewSecret: zod_1.z.string().nullish(),
productFiltersLayout: exports.ProductFiltersLayoutSchema.nullish(),
productFiltersPro: zod_1.z.boolean().nullish(),
productRoute: zod_1.z.string().nullish(),
demoMode: _zod.z.boolean().nullish(),
enableGuestCheckoutLogin: _zod.z.boolean().nullish(),
googleAnalyticsId: _zod.z.string().nullish(),
googleRecaptchaKey: _zod.z.string().nullish(),
googleTagmanagerId: _zod.z.string().nullish(),
hygraphEndpoint: _zod.z.string().min(1),
hygraphManagementApi: _zod.z.string().nullish(),
hygraphProjectId: _zod.z.string().nullish(),
hygraphWriteAccessEndpoint: _zod.z.string().nullish(),
hygraphWriteAccessToken: _zod.z.string().nullish(),
limitSsg: _zod.z.boolean().nullish(),
magentoEndpoint: _zod.z.string().min(1),
previewSecret: _zod.z.string().nullish(),
productFiltersLayout: ProductFiltersLayoutSchema.nullish(),
productFiltersPro: _zod.z.boolean().nullish(),
productRoute: _zod.z.string().nullish(),
recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(),
robotsAllow: zod_1.z.boolean().nullish(),
robotsAllow: _zod.z.boolean().nullish(),
sidebarGallery: SidebarGalleryConfigSchema().nullish(),
storefront: zod_1.z.array(GraphCommerceStorefrontConfigSchema()),
wishlistHideForGuests: zod_1.z.boolean().nullish(),
wishlistShowFeedbackMessage: zod_1.z.boolean().nullish()
storefront: _zod.z.array(GraphCommerceStorefrontConfigSchema()),
wishlistHideForGuests: _zod.z.boolean().nullish(),
wishlistShowFeedbackMessage: _zod.z.boolean().nullish()
});
}
exports.GraphCommerceConfigSchema = GraphCommerceConfigSchema;
function GraphCommerceDebugConfigSchema() {
return zod_1.z.object({
pluginStatus: zod_1.z.boolean().nullish(),
sessions: zod_1.z.boolean().nullish(),
webpackCircularDependencyPlugin: zod_1.z.boolean().nullish(),
webpackDuplicatesPlugin: zod_1.z.boolean().nullish()
return _zod.z.object({
pluginStatus: _zod.z.boolean().nullish(),
sessions: _zod.z.boolean().nullish(),
webpackCircularDependencyPlugin: _zod.z.boolean().nullish(),
webpackDuplicatesPlugin: _zod.z.boolean().nullish()
});
}
exports.GraphCommerceDebugConfigSchema = GraphCommerceDebugConfigSchema;
function GraphCommerceStorefrontConfigSchema() {
return zod_1.z.object({
canonicalBaseUrl: zod_1.z.string().nullish(),
cartDisplayPricesInclTax: zod_1.z.boolean().nullish(),
defaultLocale: zod_1.z.boolean().nullish(),
domain: zod_1.z.string().nullish(),
googleAnalyticsId: zod_1.z.string().nullish(),
googleRecaptchaKey: zod_1.z.string().nullish(),
googleTagmanagerId: zod_1.z.string().nullish(),
hygraphLocales: zod_1.z.array(zod_1.z.string().min(1)).nullish(),
linguiLocale: zod_1.z.string().nullish(),
locale: zod_1.z.string().min(1),
magentoStoreCode: zod_1.z.string().min(1)
return _zod.z.object({
canonicalBaseUrl: _zod.z.string().nullish(),
cartDisplayPricesInclTax: _zod.z.boolean().nullish(),
defaultLocale: _zod.z.boolean().nullish(),
domain: _zod.z.string().nullish(),
googleAnalyticsId: _zod.z.string().nullish(),
googleRecaptchaKey: _zod.z.string().nullish(),
googleTagmanagerId: _zod.z.string().nullish(),
hygraphLocales: _zod.z.array(_zod.z.string().min(1)).nullish(),
linguiLocale: _zod.z.string().nullish(),
locale: _zod.z.string().min(1),
magentoStoreCode: _zod.z.string().min(1)
});
}
exports.GraphCommerceStorefrontConfigSchema = GraphCommerceStorefrontConfigSchema;
function MagentoConfigurableVariantValuesSchema() {
return zod_1.z.object({
content: zod_1.z.boolean().nullish(),
gallery: zod_1.z.boolean().nullish(),
url: zod_1.z.boolean().nullish()
return _zod.z.object({
content: _zod.z.boolean().nullish(),
gallery: _zod.z.boolean().nullish(),
url: _zod.z.boolean().nullish()
});
}
exports.MagentoConfigurableVariantValuesSchema = MagentoConfigurableVariantValuesSchema;
function RecentlyViewedProductsConfigSchema() {
return zod_1.z.object({
enabled: zod_1.z.boolean().nullish(),
maxCount: zod_1.z.number().nullish()
return _zod.z.object({
enabled: _zod.z.boolean().nullish(),
maxCount: _zod.z.number().nullish()
});
}
exports.RecentlyViewedProductsConfigSchema = RecentlyViewedProductsConfigSchema;
function SidebarGalleryConfigSchema() {
return zod_1.z.object({
paginationVariant: exports.SidebarGalleryPaginationVariantSchema.nullish()
return _zod.z.object({
paginationVariant: SidebarGalleryPaginationVariantSchema.nullish()
});
}
exports.SidebarGalleryConfigSchema = SidebarGalleryConfigSchema;
19 changes: 14 additions & 5 deletions packagesDev/next-config/dist/withGraphCommerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,26 @@ function withGraphCommerce(nextConfig, cwd) {
},
transpilePackages,
webpack: (config, options) => {
// Allow importing yml/yaml files for graphql-mesh
config.module?.rules?.push({ test: /\.ya?ml$/, use: 'js-yaml-loader' });
if (!config.module)
config.module = { rules: [] };
config.module = {
...config.module,
rules: [
...(config.module.rules ?? []),
// Allow importing yml/yaml files for graphql-mesh
{ test: /\.ya?ml$/, use: 'js-yaml-loader' },
// @lingui .po file support
{ test: /\.po/, use: '@lingui/loader' },
],
exprContextCritical: false,
};
if (!config.plugins)
config.plugins = [];
// Make import.meta.graphCommerce available for usage.
config.plugins.push(new webpack_1.DefinePlugin(importMetaPaths));
// To properly properly treeshake @apollo/client we need to define the __DEV__ property
config.plugins.push(new webpack_1.DefinePlugin({ 'globalThis.__DEV__': options.dev }));
if (!options.isServer) {
config.plugins.push(new webpack_1.DefinePlugin({ __DEV__: options.dev }));
if (graphcommerceConfig.debug?.webpackCircularDependencyPlugin) {
config.plugins.push(new circular_dependency_plugin_1.default({
exclude: /readable-stream|duplexer2|node_modules\/next/,
Expand All @@ -122,8 +133,6 @@ function withGraphCommerce(nextConfig, cwd) {
}));
}
}
// @lingui .po file support
config.module?.rules?.push({ test: /\.po/, use: '@lingui/loader' });
config.snapshot = {
...(config.snapshot ?? {}),
managedPaths: [
Expand Down
21 changes: 15 additions & 6 deletions packagesDev/next-config/src/withGraphCommerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,29 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
},
transpilePackages,
webpack: (config: Configuration, options) => {
// Allow importing yml/yaml files for graphql-mesh
config.module?.rules?.push({ test: /\.ya?ml$/, use: 'js-yaml-loader' })
if (!config.module) config.module = { rules: [] }

config.module = {
...config.module,
rules: [
...(config.module.rules ?? []),
// Allow importing yml/yaml files for graphql-mesh
{ test: /\.ya?ml$/, use: 'js-yaml-loader' },
// @lingui .po file support
{ test: /\.po/, use: '@lingui/loader' },
],
exprContextCritical: false,
}

if (!config.plugins) config.plugins = []

// Make import.meta.graphCommerce available for usage.
config.plugins.push(new DefinePlugin(importMetaPaths))

// To properly properly treeshake @apollo/client we need to define the __DEV__ property
config.plugins.push(new DefinePlugin({ 'globalThis.__DEV__': options.dev }))

if (!options.isServer) {
config.plugins.push(new DefinePlugin({ __DEV__: options.dev }))
if (graphcommerceConfig.debug?.webpackCircularDependencyPlugin) {
config.plugins.push(
new CircularDependencyPlugin({
Expand All @@ -147,9 +159,6 @@ export function withGraphCommerce(nextConfig: NextConfig, cwd: string): NextConf
}
}

// @lingui .po file support
config.module?.rules?.push({ test: /\.po/, use: '@lingui/loader' })

config.snapshot = {
...(config.snapshot ?? {}),
managedPaths: [
Expand Down
Loading

0 comments on commit 4a8611e

Please sign in to comment.