[@xdn/starter] service-worker.js: "process" is not defined issue

If I create a new starter app via npm create xdn-app@latest and afterwards run it via xdn run --production I’m getting the following error in browser’s console:

Uncaught ReferenceError: process is not defined
    at Object.3044 (service-worker.js:2)
    at s (service-worker.js:2)
    at Object.2926 (service-worker.js:2)
    at s (service-worker.js:2)
    at Object.5361 (service-worker.js:2)
    at s (service-worker.js:2)
    at service-worker.js:2
    at service-worker.js:2

This one probably comes from webpack 5.
I could make some workaround for this in my starter project adding the following plugin to webpack config:

plugins: [
  new webpack.ProvidePlugin({
    process: 'process/browser',
  }),
]

as well as adding "process": "^0.11.10", dev dependency via npm i -D process.
In this case my generated service-worker.js file works fine.

Could the support fix be added to @xdn/starter package?
Thanks!

Thanks for the report. We have logged this internally as XDN-8956 for our team to review.

1 Like