Skip to content

Commit

Permalink
fix(nextjs-mf): enable async function support (#2642)
Browse files Browse the repository at this point in the history
Co-authored-by: ScriptedAlchemy <[email protected]>
  • Loading branch information
ScriptedAlchemy and ScriptedAlchemy authored Jun 25, 2024
1 parent 88445e7 commit a047837
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/old-teachers-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/nextjs-mf': patch
---

async function enable to stop warnings
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions webpack/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down Expand Up @@ -3720,6 +3725,7 @@ declare interface Environment {
*/
templateLiteral?: boolean;
}

declare class EnvironmentPlugin {
constructor(...keys: any[]);
keys: any[];
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -9400,6 +9411,7 @@ declare interface Output {
*/
workerWasmLoading?: string | false;
}

declare interface OutputFileSystem {
writeFile: (
arg0: string,
Expand Down

0 comments on commit a047837

Please sign in to comment.