SalesforceCommerceCloud / pwa-kit

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.
https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-kit-overview.html
BSD 3-Clause "New" or "Revised" License
283 stars 131 forks source link

[FEATURE] Make nodejs inspect configurable #761

Open nx-renezwinge opened 1 year ago

nx-renezwinge commented 1 year ago

Is your feature request related to a problem? Please describe. Currently nodejs inspect can not be configured. It starts default with 127.0.0.1:9229. But if you run the frontend in a docker container, you can not reach it. The IP must be changed into 0.0.0.0 to make it works. This is currently not possible. Or if you have a second app already running which is using 9229, then we have no possibility to change the port for inspect.

Describe the solution you'd like Please add to pwa-kit-dev start command two new parameters like inspectIP and inspectPort

Describe alternatives you've considered Found no alternatives.

Sample

program
        .command('start')
        .description(`develop your app locally`)
        .addOption(
            new program.Option('--inspect', 'enable debugging with --inspect on the node process')
        )
        .addOption(new program.Option('--noHMR', 'disable the client-side hot module replacement'))
        .action(({inspect, noHMR}) => {
            execSync(
                `node${inspect ? ' --inspect=0.0.0.0:9229' : ''} ${p.join(process.cwd(), 'app', 'ssr.js')}`,
                {
                    env: {
                        ...process.env,
                        ...(noHMR ? {HMR: 'false'} : {})
                    }
                }
            )
        })
git2gus[bot] commented 1 year ago

This issue has been linked to a new work item: W-11911359

alexvuong commented 1 year ago

Thank you for raising this issue! This is a reasonable ask. We will take this up with the team and add it to our capacity when it is available.

nx-renezwinge commented 1 year ago

@alexvuong Thx, I'm happy to hear, it will be investigated.

muenzpraeger commented 1 year ago

Did you consider to just change the start:inspect script in your local project?

"start:inspect": "NODE_OPTIONS='--inspect=<yourIP>:<yourPort>' npm run start"

nx-renezwinge commented 1 year ago

Did you consider to just change the start:inspect script in your local project?

"start:inspect": "NODE_OPTIONS='--inspect=<yourIP>:<yourPort>' npm run start"

Hi @muenzpraeger, i copied the command out of the script

cross-env NODE_ICU_DATA=node_modules/full-icu node --inspect=0.0.0.0:9229 app/ssr.js

But your hint with the node options env var is much cleaner, i will try it out. Thx.