Skip to content

Filter out node_modules without breaking nx monorepos #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/@apphosting/adapter-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apphosting/adapter-nextjs",
"version": "14.0.16",
"version": "14.0.17",
"main": "dist/index.js",
"description": "Experimental addon to the Firebase CLI to add web framework support",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions packages/@apphosting/adapter-nextjs/src/bin/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ metadata:
adapterVersion: ${adapterMetadata.adapterVersion}
framework: nextjs
frameworkVersion: ${defaultNextVersion}
outputFiles:
serverApp:
include:
- .next/standalone
`,
};
validateTestFiles(tmpDir, expectedFiles);
Expand Down
13 changes: 12 additions & 1 deletion packages/@apphosting/adapter-nextjs/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ async function moveResources(
for (const path of pathsToMove) {
const isbundleYamlDir = join(appDir, path) === dirname(bundleYamlPath);
const existsInOutputBundle = await exists(join(outputBundleAppDir, path));
if (!isbundleYamlDir && !existsInOutputBundle) {
// Keep apphosting.yaml files in the root directory still, as later steps expect them to be there
const isApphostingYaml = path === "apphosting_preprocessed" || path === "apphosting.yaml";
if (!isbundleYamlDir && !existsInOutputBundle && !isApphostingYaml) {
await move(join(appDir, path), join(outputBundleAppDir, path));
}
}
Expand Down Expand Up @@ -191,6 +193,15 @@ async function generateBundleYaml(
frameworkVersion: nextVersion,
},
};
// TODO (b/432285470) See if there is a way to also delete files for apps using Nx monorepos
if (!process.env.MONOREPO_COMMAND) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be the mechanism for handling output files when it is a monorepo then, does this mean we do not delete any files without serverApp being set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx monorepos at least will behave as they've always behaved in the past, nothing is deleted

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think proper behavior is that we support monorepo projects as well.
But I can see how that's a hassle now and requires some careful rethinking.
can we leave a TODO here linking to a bug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah can create a bug and link it here to support nx monorepos properly. I don't have much experience there right now so I don't know immediately how to solve this issues since the standalone build doesn't come with a node_modules for some reason but adding the todo will be a good reminder for later anyways

outputBundle.outputFiles = {
serverApp: {
include: [normalize(relative(cwd, opts.outputDirectoryAppPath))],
},
};
}

await writeFile(opts.bundleYamlPath, yamlStringify(outputBundle));
return;
}
Expand Down