From af72058381912c5e5d10d338c72802e32a15ec6f Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Thu, 24 Oct 2024 10:44:58 +0300 Subject: [PATCH] fix(framework): Experiement with importing json-schema-faker (#6762) --- packages/framework/src/client.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/framework/src/client.ts b/packages/framework/src/client.ts index 05dd8313f36..b01af80bb63 100644 --- a/packages/framework/src/client.ts +++ b/packages/framework/src/client.ts @@ -1,4 +1,3 @@ -import JSONSchemaFaker from 'json-schema-faker'; import { Liquid } from 'liquidjs'; import ora from 'ora'; @@ -40,6 +39,12 @@ import { WithPassthrough } from './types/provider.types'; import { EMOJI, log, sanitizeHtmlInObject, stringifyDataStructureWithSingleQuotes } from './utils'; import { transformSchema, validateData } from './validators'; +/* + * JSONSchemaFaker needs to be imported as CJS to avoid HMR and Webpack issues when importing @novu/framework + * in Next.js. See https://github.com/json-schema-faker/json-schema-faker/issues/796#issuecomment-2433335751 + */ +const { JSONSchemaFaker } = require('json-schema-faker'); + /** * We want to respond with a consistent string value for preview */