-
Notifications
You must be signed in to change notification settings - Fork 126
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
feat: remove dev node_modules deps #242
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,6 +489,25 @@ async function createServerBundle(monorepoRoot: string) { | |
injectMiddlewareGeolocation(outputPath, packagePath); | ||
removeCachedPages(outputPath, packagePath); | ||
addCacheHandler(outputPath); | ||
|
||
if (options.minify) { | ||
removeNodeModule(path.join(outputPath, "node_modules"), [ | ||
"@esbuild", | ||
"prisma/libquery_engine-darwin-arm64.dylib.node", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we include all prisma engines? meaning all other OS packages not compatible with Lambda There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know where I can get a list of all non-lambda engines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have some generic prisma node_modules cleanup code https://github.com/jetbridge/sst-prisma/blob/master/stacks/resources/prismaLayer.ts#L90 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, what the hell is wrong with prisma? |
||
"@swc/core-darwin-arm64", | ||
"@swc/core", | ||
"better-sqlite3", | ||
"esbuild", | ||
"webpack", | ||
"uglify-js", | ||
// "react", // TODO: remove react/react-dom when nextjs updates its precompile versions | ||
// "react-dom", | ||
"@webassemblyjs", | ||
"uglify-js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate here, it's also listed above! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thx, I'll have to retest this w/ Next 14, which seems to have fixed the dev deps getting traced to the standalone output. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Been busy last week and caught a cold this week... I'll eventually test this to confirm... @mathisobadia was still seeing these dev modules but I didn't... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @revmischa This is inside your server-function lambda ? There is a lot of things that you should be able to remove, you can use |
||
"sass", | ||
"caniuse-lite", | ||
]); | ||
} | ||
} | ||
|
||
function addMonorepoEntrypoint(outputPath: string, packagePath: string) { | ||
|
@@ -743,3 +762,13 @@ function compareSemver(v1: string, v2: string): number { | |
if (minor1 !== minor2) return minor1 - minor2; | ||
return patch1 - patch2; | ||
} | ||
|
||
function removeNodeModule(nodeModulesPath: string, modules: string[]) { | ||
console.log("removing: ", modules); | ||
for (const module of modules) { | ||
fs.rmSync(path.join(nodeModulesPath, module), { | ||
force: true, | ||
recursive: true, | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my logs:
can we remove some of them also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very likely yes, but you'll need to test for yourself. You can probably remove :
swc core
sharp
esbuild
caniuse lite
uglify-js
terser