-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
@nrwl/node:build package.json not including all external dependencies. #6901
Comments
I have the same issue with a lot more packages like nestjs config, gcp storage, luxon |
I have the same problem. I use 11 dependencies but only 6 are listed in the package.json. I do not understand how it works but it seems only those directly imported in By transitive dependency I just mean another file in the same application. I'm using 13.2.1 which is the latest at the moment. |
In case it's helpful, we use a custom webpack config + the Our const path = require('path');
const GeneratePackageJsonPlugin = require('generate-package-json-webpack-plugin');
module.exports = config => {
/**
* The main entry for services will always look something like `{root}/services/{serviceName}/src/main.ts`
* We can take advantage of this convention to find the service package.json file
*/
const entry = config.entry.main[0];
const packageJSON = require(path.join(entry.split('/src/')[0], 'package.json'));
packageJSON.dependencies = {
...(packageJSON.dependencies || {}),
// common implicit deps across all packages. service specific implicit deps should go into their respective package.json file
graphql: '~15.5.0',
};
/**
* The first plugin is `ForkTsCheckerWebpackPlugin` - we do not need to do type checking as part of the dev server.
* We have other checks for this. Removing this plugin significantly reduces the resource consumption of services during development.
*/
config.plugins.shift();
return {
...config,
plugins: [...config.plugins, new GeneratePackageJsonPlugin(packageJSON)],
// skip minimizing but still tree shake
optimization: {
...config.optimization,
minimize: false,
// Non-prod uses webpack cacheUnaffected setting, which cannot be used with usedExports. So only set when building for prod
usedExports: process.env.NODE_ENV === 'production',
},
};
}; |
I am having the same issue - it seems like some dependencies, especially those from libs are not included in the generated package.json. This makes containerizing a single application really difficult. |
This also applies to |
@marbemac your solution is nice but it adds a lot of unnecessary packages to package.json and I find it difficult to keep only the used ones in an automated manner. My workaround is to add
|
@andreidragu hmm - it should only add the the packages that are used in your code 🤔 (it does so for us at least). |
I'm facing the same issue now that I have migrated the workspace to the latest version. None of my apps have generated dependencies in their respective
|
I am having the same issue with |
@Mellywins were you able to resolve this issue? i'm using 13.9.4 and i have the same issue. thanks! |
@ferliesypmh I had to use a workaround to solve this... |
Thanks @marbemac, that webpack plugin indeed does a much better job! I'm not sure why this plugin picks up dependencies that NX does not, but definitely seems like a bug. |
I was running into this but after deleting root node_modules and package-lock.json and reinstalling, all dependencies were included in the generated package.json as expected. |
I kept getting this issue as well, my work around was to create an import.ts file in the app src folder, then add this file as anadditionalEntryPoints in the project.json e.g. import.ts imports all required packages for nestjs, excluding angular related packages.
then add this file in the additional entry points in project.json
The package.json file gets generated with all the packages you want included with this app, might be improved but this worked for me You can discard the imports.js that nx generates after your build runs. 😁 |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
Up |
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
Still an issue |
Current Behavior
Code contains two dependencies
On serve or build. The generated package.json does not include morgan as a dependency, only express is included in package.json
project.targets.build.options.generatePackageJson = true
Expected Behavior
I expected the output of package.json to include morgan as a dependency.
Steps to Reproduce
project.targets.build.options.generatePackageJson = true
.Project entry in workspace.json
This issue may not be prioritized if details are not provided to help us reproduce the issue.
Failure Logs
N/A
Environment
node 14
ubuntu LTS 20
The text was updated successfully, but these errors were encountered: