Allow to disable Webpack bundling for NestJS apps #8482
Replies: 18 comments 4 replies
-
This is a very good question, also I wanted to use nx for my project but I would like to avoid compiling through webpack. |
Beta Was this translation helpful? Give feedback.
-
Just started looking at using nx for a nestjs project, but without separate entity files produced in the dist I don't see how this helps when trying to run migrations for deploying to productions. Seems like a non-starter for my case. |
Beta Was this translation helpful? Give feedback.
-
Nx has such a strong Angular focus, and I think the core developers are mostly Angular developers. Considering that Next is quickly becoming (if not has become) the mainly used framework for web development, I'd love to see better overall support and work with Next. |
Beta Was this translation helpful? Give feedback.
-
Any update here? |
Beta Was this translation helpful? Give feedback.
-
Is there any update? |
Beta Was this translation helpful? Give feedback.
-
I would also like to see this implemented |
Beta Was this translation helpful? Give feedback.
-
Any update guys? |
Beta Was this translation helpful? Give feedback.
-
Is there any update ? |
Beta Was this translation helpful? Give feedback.
-
Is there any update? |
Beta Was this translation helpful? Give feedback.
-
+1 bump for this, lets keep webpack out of the backend side, please |
Beta Was this translation helpful? Give feedback.
-
+1 really need this feature! |
Beta Was this translation helpful? Give feedback.
-
+1 really need it |
Beta Was this translation helpful? Give feedback.
-
I did build a wicked (feels brittle but I am still kinda proud) solution. I explicitly added "pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
} to "executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"generatePackageJson": true,
"generateLockfile": true,
"updateBuildableProjectDepsInPackageJson": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
...
} which produces How did I solve the struggle with the internal libs? I am using pnpm as a package manager and was able to use its linking. You could either set the link in the version of your libs cat package.json | jq '.dependencies = ( .dependencies | to_entries | map(if .key | startswith("@YOURSCOPE/") then .value = "link:./libnx/\(.key|sub("^@YOURSCOPE/"; ""))" else . end) | from_entries )' | tee package.json Important... make sure to copy the libs from dist to your docker image as well. Happy to receive some feedback! :) |
Beta Was this translation helpful? Give feedback.
-
Any official support to eject webpack from nestjs? Webpack has been causing havoc on our apps |
Beta Was this translation helpful? Give feedback.
-
Regarding referencing migration files, there is an rather straightforward workaround. // ... Imports
@Injectable()
export class TypeOrmProvider implements TypeOrmOptionsFactory {
createTypeOrmOptions(): TypeOrmModuleOptions | Promise<TypeOrmModuleOptions> {
return {
type: "postgres",
host: "foo",
port: 5432,
username: "foo",
password: "foo",
migrations: [
InitialChangelog1706807759398,
RefactorChangelog1707389887104,
AddColumn1707410043409,
// Reference all migrations that should run here
],
};
}
} It's a bit tedious to do that with every migration, but meh. Better than anything else, I've come around so far. |
Beta Was this translation helpful? Give feedback.
-
I think the best idea (for now) is to update documentation to showcase how to chain the @nx/js:tsc executor to compile specific folders like "migrations", and place them in the final output. |
Beta Was this translation helpful? Give feedback.
-
Webpack bundles the whole NestJS app into a single file. But the output misses dynamically discovered, imported, and executed files, like database migrations.
Please add an option to disable Webpack and output just compiled .ts files.
More about the
webpack: boolean
in NestJS CLI config - https://docs.nestjs.com/cli/monorepo#global-compiler-optionsAs I understand, it does a "compiler" switching based on this flag between
webpack
andtsc
.Beta Was this translation helpful? Give feedback.
All reactions