From 8f6257d109ad3c7f325dfef0cc1eabb546b7d893 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Fri, 1 Nov 2024 16:15:09 +0000 Subject: [PATCH] fix(react): ensure module federation template files are indented correctly --- .../common-ts/src/app/__fileName__.tsx__tmpl__ | 4 ++-- .../host/files/common-ts/src/main.ts__tmpl__ | 18 +++++++++--------- .../common/src/app/__fileName__.js__tmpl__ | 4 ++-- .../host/files/common/src/main.js__tmpl__ | 18 +++++++++--------- .../src/app/__fileName__.jsx__tmpl__ | 4 ++-- .../files/rspack-common/src/main.jsx__tmpl__ | 18 +++++++++--------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/packages/react/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ b/packages/react/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ index f4789e0395ff6..857d5e16213ff 100644 --- a/packages/react/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ +++ b/packages/react/src/generators/host/files/common-ts/src/app/__fileName__.tsx__tmpl__ @@ -10,9 +10,9 @@ import { loadRemote } from '@module-federation/enhanced/runtime'; <%_ if (remotes.length > 0) { remotes.forEach(function(r) { _%> <%_ if (dynamic) { _%> - const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) +const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) <%_ } else { _%> - const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); +const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); <%_ } _%> <%_ }); _%> <%_ } _%> diff --git a/packages/react/src/generators/host/files/common-ts/src/main.ts__tmpl__ b/packages/react/src/generators/host/files/common-ts/src/main.ts__tmpl__ index 52c51d1e1dfd4..b1ad55fdb0a2e 100644 --- a/packages/react/src/generators/host/files/common-ts/src/main.ts__tmpl__ +++ b/packages/react/src/generators/host/files/common-ts/src/main.ts__tmpl__ @@ -1,13 +1,13 @@ <%_ if (dynamic) { _%> - import { init } from '@module-federation/enhanced/runtime'; +import { init } from '@module-federation/enhanced/runtime'; - fetch('/assets/module-federation.manifest.json') - .then((res) => res.json()) - .then((remotes: Record) => - Object.entries(remotes).map(([name, entry]) => ({ name, entry })) - ) - .then((remotes) => init({ name: '<%= projectName %>', remotes })) - .then(() => import('./bootstrap').catch(err => console.error(err))); +fetch('/assets/module-federation.manifest.json') +.then((res) => res.json()) +.then((remotes: Record) => + Object.entries(remotes).map(([name, entry]) => ({ name, entry })) +) +.then((remotes) => init({ name: '<%= projectName %>', remotes })) +.then(() => import('./bootstrap').catch(err => console.error(err))); <%_ } else { _%> - import('./bootstrap').catch(err => console.error(err)); +import('./bootstrap').catch(err => console.error(err)); <%_ } _%> diff --git a/packages/react/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ b/packages/react/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ index ab542c9315a48..5320f427bc4d8 100644 --- a/packages/react/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ +++ b/packages/react/src/generators/host/files/common/src/app/__fileName__.js__tmpl__ @@ -10,9 +10,9 @@ import { loadRemote } from '@module-federation/enhanced/runtime'; <%_ if (remotes.length > 0) { remotes.forEach(function(r) { _%> <%_ if (dynamic) { _%> - const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) +const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) <%_ } else { _%> - const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); +const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); <%_ } _%> <%_ }); _%> <%_ } _%> diff --git a/packages/react/src/generators/host/files/common/src/main.js__tmpl__ b/packages/react/src/generators/host/files/common/src/main.js__tmpl__ index 52c51d1e1dfd4..b1ad55fdb0a2e 100644 --- a/packages/react/src/generators/host/files/common/src/main.js__tmpl__ +++ b/packages/react/src/generators/host/files/common/src/main.js__tmpl__ @@ -1,13 +1,13 @@ <%_ if (dynamic) { _%> - import { init } from '@module-federation/enhanced/runtime'; +import { init } from '@module-federation/enhanced/runtime'; - fetch('/assets/module-federation.manifest.json') - .then((res) => res.json()) - .then((remotes: Record) => - Object.entries(remotes).map(([name, entry]) => ({ name, entry })) - ) - .then((remotes) => init({ name: '<%= projectName %>', remotes })) - .then(() => import('./bootstrap').catch(err => console.error(err))); +fetch('/assets/module-federation.manifest.json') +.then((res) => res.json()) +.then((remotes: Record) => + Object.entries(remotes).map(([name, entry]) => ({ name, entry })) +) +.then((remotes) => init({ name: '<%= projectName %>', remotes })) +.then(() => import('./bootstrap').catch(err => console.error(err))); <%_ } else { _%> - import('./bootstrap').catch(err => console.error(err)); +import('./bootstrap').catch(err => console.error(err)); <%_ } _%> diff --git a/packages/react/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ b/packages/react/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ index 6d2c466714635..d0184bedb37fb 100644 --- a/packages/react/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ +++ b/packages/react/src/generators/host/files/rspack-common/src/app/__fileName__.jsx__tmpl__ @@ -11,9 +11,9 @@ import { loadRemote } from '@module-federation/enhanced/runtime'; <%_ if (remotes.length > 0) { remotes.forEach(function(r) { _%> <%_ if (dynamic) { _%> - const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) +const <%= r.className %> = React.lazy(() => loadRemote('<%= r.fileName %>/Module') as any) <%_ } else { _%> - const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); +const <%= r.className %> = React.lazy(() => import('<%= r.fileName %>/Module')); <%_ } _%> <%_ }); _%> <%_ } _%> diff --git a/packages/react/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ b/packages/react/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ index 52c51d1e1dfd4..b1ad55fdb0a2e 100644 --- a/packages/react/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ +++ b/packages/react/src/generators/host/files/rspack-common/src/main.jsx__tmpl__ @@ -1,13 +1,13 @@ <%_ if (dynamic) { _%> - import { init } from '@module-federation/enhanced/runtime'; +import { init } from '@module-federation/enhanced/runtime'; - fetch('/assets/module-federation.manifest.json') - .then((res) => res.json()) - .then((remotes: Record) => - Object.entries(remotes).map(([name, entry]) => ({ name, entry })) - ) - .then((remotes) => init({ name: '<%= projectName %>', remotes })) - .then(() => import('./bootstrap').catch(err => console.error(err))); +fetch('/assets/module-federation.manifest.json') +.then((res) => res.json()) +.then((remotes: Record) => + Object.entries(remotes).map(([name, entry]) => ({ name, entry })) +) +.then((remotes) => init({ name: '<%= projectName %>', remotes })) +.then(() => import('./bootstrap').catch(err => console.error(err))); <%_ } else { _%> - import('./bootstrap').catch(err => console.error(err)); +import('./bootstrap').catch(err => console.error(err)); <%_ } _%>