'process is not defined' in 1.39.0

I encounter a strange problem, my code work in 1.32.0, but when in 1.39.0, I get an error about process . I use process.cwd to get the current application base dir in my widget dialog. but it says process is not defined

@wss Why are you using process (a node.js global variable) in browser code? I’m not sure that bundlers correctly replace the process.cwd() function for browser code.

As for why it changed at all. It might be that we updated webpack in the meantime or removed a polyfill on our side that was able to simulate the process object. Note that I would not recommend you to rely on it. What did process.cwd() yield you in version 1.32.0?

my application is based theia-blueprint , it is a electron-application. in 1.32.0 process.cwd() yield ‘\applications\electron’ dir in debug mode, yield ‘\applications\electron\dist\win-unpacked’ in package mode.
in fact, I am not want to use process.cwd, because I also want to use it in browser version. how could I get the application’s base dir?

The best option would be to define a backend service that returns the backend path and call that from the frontend. Note that I would recommend to use the injected ApplicationPackage.projectPath instead, as cwd is very unreliable, in case the application hasn’t been started by clicking on the .exe file.

ApplicationPackage is what I want, thanks great.
ApplicationPackage can only be injected in backend? when I inject it in front widget, I debug my application always stays in the loading splash screen, debug console does not display any error message. I inject it in the backend everything works ok.

I don’t think the ApplicationPackage is bound on the frontend, since the projectPath cannot be calculated on the frontend. That’s why I mentioned you should define a backend service that uses that.