Forge Deploy is Uploading Everything Under /static folder for my Custom UI app

I have a forge UI Kit app with a custom ui dashboard panel.

resources:
  - key: dashboard-app
    path: static/dashboard/dist

The folder structure under /static is

 static/
  ├── img/
  │   ├── ...
  └── dashboard/
      ├── node_modules/          ← Problem: Being deployed
      │   └── (327 packages)
      ├── dist/
      │   ├── index.html
      │   ├── stats.html
      │   └── assets/
      │       └── (built JS/CSS)
      ├── src/
      │   ├── ,,,
      ├── package.json
      ├── package-lock.json
      ├── tsconfig.json
      ├── vite.config.ts
      ├── eslint.config.js
      ├── index.html
      └── README.md

I’m getting an error during forge deploy:

Error: Failed to deploy hosted resources. Each resource can only have up to 5000 files

When I run forge deploy –verbose I can see that all of the files under node_modules are being included (abbreviated):

 Packaging app files
  Packaging bundled files
  , from __forge__.cjs
  , from __forge_wrapper__.cjs
  ...
  Archive created: /var/folders/1r/yrgnww510pbdn5c53hgbxh2r0000gn/T/tmp-81847-WJshFWMEHdLa-.zip
  NativeUI bundle created: /var/folders/1r/yrgnww510pbdn5c53hgbxh2r0000gn/T/forge-native-ui-81847-tj2lOHvrG3iW
  NativeUI bundle created: /var/folders/1r/yrgnww510pbdn5c53hgbxh2r0000gn/T/forge-native-ui-81847-cgRtCdAaHRo0
  NativeUI bundle created: /var/folders/1r/yrgnww510pbdn5c53hgbxh2r0000gn/T/forge-native-ui-81847-Lj7ARgsoTRlK
  , from index.html
  , from assets/...
  , from img/...
  , from dashboard/...
  , from dashboard/dist/...
  , from dashboard/package.
  ...
  , from dashboard/node_modules/ansi-regex/index.js
  , from dashboard/node_modules/acorn-jsx/xhtml.js
  , from dashboard/node_modules/ansi-regex/index.d.ts
  , from dashboard/node_modules/ansi-regex/license
  , from dashboard/node_modules/ansi-regex/readme.md
  , from dashboard/node_modules/acorn-jsx/index.js
  ... .etc. ...

I have found similar questions about this posted but none has a satisfactory answer.

1 Like

Have reached out to the owning team, they should respond within a day.

Thanks

Hi @KeithHamburg as of today, Forge CLI does not support excluding any folders for uploading.

Would it be possible for you to re-structure your app a bit so that only content of your dist folder gets placed in /static/dashboard?

Yes, that’s what I’ve done as a work-around. It would be helpful if you guys could update the docs. The demos, example apps, and online docs I could find all talk about putting the custom UI project under static including package.json and then doing an npm install from there, which created a node_modules folder. This results in everything being uploaded, and often goes over the 5000 file limit.

This guide is an example of what I’m talking about: https://developer.atlassian.com/platform/forge/build-a-custom-ui-app-in-jira/

There are other unanswered posts in dev community about this problem. One even has someone suggesting to use ‘.forgeignore’ which I believe is from another forge platform. I had an AI assistant suggest creating this file while I was debugging this problem. Also, running forge create and selecting ‘Custom UI’ does the same thing (creates the custom ui app under /static).

You’re correct, our examples and templates use this setup and the don’t have this issue.

Could you check if there are any references from /static/dashboard/dist into a “sibling folder” like /static/img?

  • grep -R "../" static/dashboard/dist

  • grep -R "/static/" static/dashboard/dist

Other than references, source maps or symlink could also cause Forge CLI to “pull in” the parent folder.

.forgeignore doesn’t exist any more.

@jweiss is there a ticket to fix this? Pretty sloppy for the CLI to be uploading everything when the manifest explicitly lists the static build path.

I had to change the first grep to escape the . characters

grep -R "\.\./" static/dashboard/dist

but neither grep command returned any matches.

Right, yeah that was my thought as well.

@KeithHamburg just to verify: there aren’t 5000+ files sitting in your dist folder after running npm run build?

No but I think I found self-referential imports in two of the assets produced by the build, so maybe that’s the issue. Will try to figure out why.

Oh boy, I figured out what is going on. I had an older static resource for my images, and when I moved the dashboard under static, I just added another one:

resources:
  - key: dashboard-app
    path: static/dashboard/dist
  - key: static-assets
    path: static

So I guess the static-assets resource was picking up everything underneath it which included the static/dashboard/node_modules folder. :person_facepalming:

Thanks for helping me figure this out.

3 Likes