From a047837d0af841703c1b4f2023ced99bc3b92a32 Mon Sep 17 00:00:00 2001 From: Zack Jackson Date: Mon, 24 Jun 2024 17:30:15 -0700 Subject: [PATCH] fix(nextjs-mf): enable async function support (#2642) Co-authored-by: ScriptedAlchemy --- .changeset/old-teachers-eat.md | 5 +++++ .github/workflows/build-and-test.yml | 2 +- .../src/plugins/NextFederationPlugin/index.ts | 5 +++++ webpack/types.d.ts | 12 ++++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .changeset/old-teachers-eat.md diff --git a/.changeset/old-teachers-eat.md b/.changeset/old-teachers-eat.md new file mode 100644 index 00000000000..3a16bf2b43c --- /dev/null +++ b/.changeset/old-teachers-eat.md @@ -0,0 +1,5 @@ +--- +'@module-federation/nextjs-mf': patch +--- + +async function enable to stop warnings diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index e477ce8ab91..1ed243a00ce 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -74,7 +74,7 @@ jobs: run: npx nx run-many --target=test:e2e --projects=modernjs --parallel=1 && lsof -ti tcp:4001 | xargs kill - name: E2E Test for 3005-runtime-host - run: lsof -ti tcp:3005,3006,3007 | xargs kill & pnpm run app:runtime:dev & echo "done" && sleep 20 && npx nx run-many --target=test:e2e --projects=3005-runtime-host --parallel=1 && lsof -ti tcp:3005,3006,3007 | xargs kill + run: npx kill-port --port 3005,3006,3007 && pnpm run app:runtime:dev & echo "done" && sleep 20 && npx nx run-many --target=test:e2e --projects=3005-runtime-host --parallel=1 && lsof -ti tcp:3005,3006,3007 | xargs kill - name: E2E Test for 3008-webpack-host run: pnpm run app:manifest:dev & echo "done" && npx wait-on tcp:3009 && npx wait-on tcp:3012 && npx nx run-many --target=e2e --projects=3008-webpack-host --parallel=1 && lsof -ti tcp:3008,3009,3010,3011,3012 | xargs kill diff --git a/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts index 94af477ca66..3714db553b7 100644 --- a/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts +++ b/packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts @@ -119,6 +119,11 @@ export class NextFederationPlugin { private applyConditionalPlugins(compiler: Compiler, isServer: boolean) { compiler.options.output.uniqueName = this._options.name; + compiler.options.output.environment = { + ...compiler.options.output.environment, + asyncFunction: true, + }; + applyPathFixes(compiler, this._extraOptions); if (this._extraOptions.debug) { compiler.options.devtool = false; diff --git a/webpack/types.d.ts b/webpack/types.d.ts index fbebc5721d7..5179ca0208d 100644 --- a/webpack/types.d.ts +++ b/webpack/types.d.ts @@ -3670,6 +3670,11 @@ declare interface Environment { */ arrowFunction?: boolean; + /** + * The environment supports async function and await ('async function () { await ... }'). + */ + asyncFunction?: boolean; + /** * The environment supports BigInt as literal (123n). */ @@ -3720,6 +3725,7 @@ declare interface Environment { */ templateLiteral?: boolean; } + declare class EnvironmentPlugin { constructor(...keys: any[]); keys: any[]; @@ -9200,6 +9206,11 @@ declare interface Output { | string | ((pathData: PathData, assetInfo?: AssetInfo) => string); + /** + * Compress the data in the head tag of CSS files. + */ + cssHeadDataCompression?: boolean; + /** * Similar to `output.devtoolModuleFilenameTemplate`, but used in the case of duplicate module identifiers. */ @@ -9400,6 +9411,7 @@ declare interface Output { */ workerWasmLoading?: string | false; } + declare interface OutputFileSystem { writeFile: ( arg0: string,