Skip to content

Commit 5f7b084

Browse files
fix(nextjs-mf): throw compile error if AppDir is used (#2227)
Co-authored-by: ScriptedAlchemy <[email protected]>
1 parent d942a1c commit 5f7b084

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.changeset/metal-kangaroos-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/nextjs-mf': patch
3+
---
4+
5+
Prevent application from compiling if AppDir is used at all

packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ export class NextFederationPlugin {
8080
}
8181

8282
private validateOptions(compiler: Compiler): boolean {
83+
const manifestPlugin = compiler.options.plugins.find(
84+
(p) => p?.constructor.name === 'BuildManifestPlugin',
85+
);
86+
87+
if (manifestPlugin) {
88+
//@ts-ignore
89+
if (manifestPlugin?.appDirEnabled) {
90+
throw new Error(
91+
'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',
92+
);
93+
}
94+
}
95+
8396
const compilerValid = validateCompilerOptions(compiler);
8497
const pluginValid = validatePluginOptions(this._options);
8598
const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];
@@ -109,6 +122,7 @@ export class NextFederationPlugin {
109122
if (this._extraOptions.debug) {
110123
compiler.options.devtool = false;
111124
}
125+
112126
if (isServer) {
113127
configureServerCompilerOptions(compiler);
114128
configureServerLibraryAndFilename(this._options);

0 commit comments

Comments
 (0)