Update forge web build to current node / express?

Is there any way to update the web build to use updated components? I noticed its using express 3 still.

Additonally, it would be great to add in files upload size code too as I’m running into an issue where uploads are capped at 1 meg and I had to add

var app = express();
app.use(express.json({limit: ‘5mb’}));
app.use(express.urlencoded({limit: ‘5mb’}));

To the web.js file after build to get it to work.

Also, I understand that the web is probably not used as much but with the way things are right now its becoming more of a used thing for us anyhow so it would be great to have that in-line (side note but when building web it would also be good to have fallbacks for things that are not supported in web so it does not error out )

Thanks!

Great to have someone using the web target, thank you for the feedback!

I’m planning to drop express entirely in the next release or two given as it’s pulling in something like 95 (!) dependencies these days.

re: Web erroring out

Just to confirm, is this when using forge.* API’s that aren’t supported under web?

Ideally unsupported API’s should either fire an error callback or, when appropriate, silently perform no action.

Can you please give me a bit more info on:

  1. The kind of errors you’re seeing.
  2. At least one or two examples of API’s that aren’t behaving?

Thank you!

I’ve created an issue for the app size limit:

And API coverage for the web target:

Hi Antoine,

I should have been more detailed on the size limit. Basically with express / node there is a default post limit of 1 meg. We have the ability to upload files via the app. Normally, on device we grab and ‘stream’ the photo to the server but this does not work on web so we base64 the image and post that to our backend.

The issue comes in with the default post size of express, its set to like 1 meg. Adding the lines

app.use(express.json({limit: ‘5mb’}));
app.use(express.urlencoded({limit: ‘5mb’}));

Allow us to upload larger files, however we have to manually add those to the web.js after build.

As for the forge* the one I have noticed the most is the forge.notifications, granted we are slowly moving those out just because we have an HTML alert system now but I have noticed it will throw an error message in the console.

I guess what would be nice is if it maybe just did an alert or confirm instead because we at times there are callback events when selecting yes or no. I hope that makes sense?

1 Like

Ah, my bad - I’ve updated the issue to reflect that it’s the POST request which is failing.

A follow-up question:

How will it affect you when we stop using using Express to power forge run web ?

It used to be a really light-weight framework but it’s ballooned somewhat over the last few years. This is partly why the web target startup’s become so slow!

Currently the plan is to rewrite our code using just the built-in Node.js HTTP modules so it would be a good to get a clearer idea of how you’re using the target. Can you perhaps share some of your code?

Hi Antonie,

I don’t think it would cause any issues really, normally I don’t touch the code produced by forge, I just had to dig into it to fix the image upload size this last time but otherwise I just leave it alone.

As far as package size with express, it was my understanding that they tried to combat that with v4 by removing most of the middleware and making it a bit more moduler, right now all packages come in around 2 megs from what I can tell.

I think an approach that could be taken for the build process is why copy everything over to the dev folder each time if nothing has really changed? I think what could make it way faster would be, when saying running

forge run web

is to just copy over the src files to the development directory and start the app. From what I can tell right now is it builds the whole project out again, checking forge modules, deleting the development folder then moving it all over to that folder again. On windows anyhow this is a bit problematic because node at times will hold on to that folder, locking it and the build fails. I have to use a tool called

EMCO UnLock IT

To unlock the development folder so builds will work again, so it would be great to have it simply copy over the src files because 99% of the time I’m not updating the modules in force just my src code. Really it could be extended even further for more granularity to have flags like

forge run web --folder --js

So it would only copy the js folder in src,that would make it way faster than a full rebuild and I would imagine cut back on the API calls each time too.

Sorry for the long response :smiley:

1 Like