From c2b4f4f29cc7f2ac04e36e57b48a9c009680368e Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Wed, 23 Jun 2021 18:57:09 +0300 Subject: [PATCH 1/3] Use .dynamic extension instead of .module --- samples/nextjs/scripts/templates/component-factory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/nextjs/scripts/templates/component-factory.ts b/samples/nextjs/scripts/templates/component-factory.ts index d802c503c2..06c93bcd2d 100644 --- a/samples/nextjs/scripts/templates/component-factory.ts +++ b/samples/nextjs/scripts/templates/component-factory.ts @@ -7,9 +7,9 @@ export interface ComponentFile { componentName: string; } -const isLazyLoadingModule = (componentPath: string) => componentPath.includes('.module'); +const isLazyLoadingModule = (componentPath: string) => componentPath.includes('.dynamic'); -const removeModuleNameEnding = (moduleName: string) => moduleName.replace(/\.?module$/i, ''); +const removeModuleNameEnding = (moduleName: string) => moduleName.replace(/\.?dynamic$/i, ''); /** * Generates the contents of the component factory file using a predefined string template. From 3986b6107c2e0294d0cee68413e1905f291e3600 Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Wed, 23 Jun 2021 18:57:16 +0300 Subject: [PATCH 2/3] add files --- ...emo.module.graphql => GraphQL-ConnectedDemo.dynamic.graphql} | 0 ...nnectedDemo.module.tsx => GraphQL-ConnectedDemo.dynamic.tsx} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename samples/nextjs/src/components/graphql/{GraphQL-ConnectedDemo.module.graphql => GraphQL-ConnectedDemo.dynamic.graphql} (100%) rename samples/nextjs/src/components/graphql/{GraphQL-ConnectedDemo.module.tsx => GraphQL-ConnectedDemo.dynamic.tsx} (98%) diff --git a/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.module.graphql b/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.dynamic.graphql similarity index 100% rename from samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.module.graphql rename to samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.dynamic.graphql diff --git a/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.module.tsx b/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.dynamic.tsx similarity index 98% rename from samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.module.tsx rename to samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.dynamic.tsx index 5d8382f01b..d33a926205 100644 --- a/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.module.tsx +++ b/samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.dynamic.tsx @@ -15,7 +15,7 @@ import { AppRoute, Item, GraphQlConnectedDemo as GrapQLConnectedDemoDatasource, -} from './GraphQL-ConnectedDemo.module.graphql'; +} from './GraphQL-ConnectedDemo.dynamic.graphql'; import { StyleguideComponentProps } from 'lib/component-props'; import config from 'temp/config'; From c2b1aa4e417e5f3ec9cfd11bd5e6b9dd98620035 Mon Sep 17 00:00:00 2001 From: illiakovalenko Date: Wed, 23 Jun 2021 19:03:27 +0300 Subject: [PATCH 3/3] Change function --- samples/nextjs/scripts/templates/component-factory.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/samples/nextjs/scripts/templates/component-factory.ts b/samples/nextjs/scripts/templates/component-factory.ts index 06c93bcd2d..242a451a0f 100644 --- a/samples/nextjs/scripts/templates/component-factory.ts +++ b/samples/nextjs/scripts/templates/component-factory.ts @@ -9,7 +9,8 @@ export interface ComponentFile { const isLazyLoadingModule = (componentPath: string) => componentPath.includes('.dynamic'); -const removeModuleNameEnding = (moduleName: string) => moduleName.replace(/\.?dynamic$/i, ''); +const removeDynamicModuleNameEnding = (moduleName: string) => + moduleName.replace(/\.?dynamic$/i, ''); /** * Generates the contents of the component factory file using a predefined string template. @@ -26,7 +27,7 @@ import dynamic from 'next/dynamic' ${components .map((component) => { if (isLazyLoadingModule(component.path)) { - const moduleName = removeModuleNameEnding(component.moduleName); + const moduleName = removeDynamicModuleNameEnding(component.moduleName); return `const ${moduleName} = { module: () => import('${component.path}'), element: () => dynamic(${moduleName}.module) @@ -43,11 +44,11 @@ ${components (component) => `components.set('${ isLazyLoadingModule(component.path) - ? removeModuleNameEnding(component.componentName) + ? removeDynamicModuleNameEnding(component.componentName) : component.componentName }', ${ isLazyLoadingModule(component.path) - ? removeModuleNameEnding(component.moduleName) + ? removeDynamicModuleNameEnding(component.moduleName) : component.moduleName });` )