felixmosh / bull-board

🎯 Queue background jobs inspector
MIT License
2.31k stars 363 forks source link

Next.js standalone mode excludes @bull-board/ui package from final build #802

Open j4tmr opened 2 months ago

j4tmr commented 2 months ago

Describe the Bug

When using Next.js in standalone mode, the @bull-board/ui package is not included in the final build, even though it is listed as a dependency in the package.json. The package itself contains important static files required for the UI, but these files are missing from the final standalone output.

Root Cause

The reason for this issue is that the @bull-board/ui package does not get directly imported into the application code. Next.js's standalone mode uses a file-tracing mechanism that relies on analyzing direct imports and references in the code to determine which files and packages should be included in the final build output. Since @bull-board/ui is not directly imported but rather contains static assets that are necessary for the UI, the file-tracing mechanism does not detect it as needed for inclusion in the build. Consequently, the package's contents are omitted from the final standalone output, leading to missing assets and broken functionality.

Expected Behavior

The @bull-board/ui package, along with all its static files, should be included in the standalone output when it's listed as a dependency.

Suggested Solution

It would be beneficial if Next.js's standalone build process could more effectively handle such packages that contain essential static files but are not directly imported. One approach could be to enhance the file-tracing mechanism to consider these types of dependencies or provide a configuration option to manually include them.

felixmosh commented 2 months ago

Do you have any insights of how to solve it? AS far as I know, next.js standalone mode has the ability to copy static files, do that, and provide your own options.uiBasePath.

j4tmr commented 2 months ago

@felixmosh I tried several ways, including nextjs's webpack configuration, but none of them worked. Your solution should be the same as me copying node_modules/@bull-board/ui directly to standalone in ci/cd. It needs to be copied dynamically.

felixmosh commented 2 months ago

What is the problem of this solution? it works.