Skip to content

chore: Exclude more packages #950

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 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions .changeset/beige-ways-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@opennextjs/aws": patch
---

chore: Exclude more packages

Added a debug to determine which packages that gets excluded from the final bundle's `node_modules`. Will skip these packages now aswell:

- "typescript"
- "next/dist/compiled/babel"
- "next/dist/compiled/babel-packages"
- "next/dist/compiled/amphtml-validator"
20 changes: 15 additions & 5 deletions packages/open-next/src/build/copyTracedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ const EXCLUDED_PACKAGES = [
// This seems to be only in Next 15
// Some of sharp deps are under the @img scope
"@img",
"typescript",
"next/dist/compiled/babel",
"next/dist/compiled/babel-packages",
"next/dist/compiled/amphtml-validator",
];

function isExcluded(srcPath: string) {
return EXCLUDED_PACKAGES.some((excluded) =>
function isExcluded(srcPath: string): string | undefined {
return EXCLUDED_PACKAGES.find((excluded) =>
srcPath.match(getCrossPlatformPathRegex(`/node_modules/${excluded}/`)),
);
}
Expand Down Expand Up @@ -250,11 +254,17 @@ File ${serverPath} does not exist

// Only files that are actually copied
const tracedFiles: string[] = [];

// Packages that are excluded and not copied
const excludedPackages = new Set<string>();
//Actually copy the files
filesToCopy.forEach((to, from) => {
// We don't want to copy excluded packages (i.e sharp)
if (isExcluded(from)) {
// We don't want to copy excluded packages (e.g. sharp)
const excluded = isExcluded(from);
if (excluded) {
if (excluded && !excludedPackages.has(excluded)) {
logger.debug("Skipping excluded package:", excluded);
excludedPackages.add(excluded);
}
return;
}
tracedFiles.push(to);
Expand Down
Loading