Force include dependencies for 'standalone' output #66327
Unanswered
ondreej
asked this question in
App Router
Replies: 2 comments
-
I encountered the same problem when trying to use In next.config.js: const { nodeFileTrace } = require('@vercel/nft');
const nextConfig = async () => {
// resolve files that are needed for additional packages to work
const { fileList: additionalTracedFiles } = await nodeFileTrace(
// add entry points for the missing packages or any additional scripts you need here
[require.resolve('@dotenvx/dotenvx/src/cli/dotenvx')],
{
// ignore unnecesary files if nft includes too many (in my case: it included absolutely everything in node_modules/.bin)
ignore: (file) => {
return file.replace(/\\/g, '/').startsWith('node_modules/.bin/');
},
}
);
/** @type {import('next').NextConfig} */
return {
/*...*/
experimental: {
outputFileTracingIncludes: {
'**': [
// everything that additional packages depends on
...additionalTracedFiles,
// add only binaries for additional packages if ignored earlier
'./node_modules/.bin/dotenvx*',
],
},
},
};
};
module.exports = nextConfig; This config was created to work with nextjs v14. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Used the solution by @aczekajski to do the same but for Drizzle ORM, here is the needed changes: import path from 'path';
import { nodeFileTrace } from "@vercel/nft";
const drizzle = nodeFileTrace([
require.resolve("drizzle-kit"),
require.resolve("drizzle-orm"),
path.resolve(path.dirname(require.resolve("drizzle-kit")), "bin.cjs")
]).then((drizzle) => [
...drizzle.fileList,
"./node_modules/.bin/drizzle-kit",
"./node_modules/drizzle-orm/**",
"./node_modules/drizzle-kit/**",
]);
const config = Promise.resolve(drizzle).then(drizzle => ({
// Other next config configuration options
...
// Add drizzle dependencies
outputFileTracingIncludes: {
"**": [...drizzle],
},
}));
export default config; Unfortunately need to force include drizzle-kit and drizzle-orm because bin scripts not handled by |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am working with Next 15 RC and have configured my next.config.js for a standalone output.
But after building the website, I need to run certain commands that require packages not included by default in the standalone build, such as
cross-env
. (for example, I need to run Payload v3 migrations inside a docker container)Is there a way to explicitly include specific dependencies in the standalone build output?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions