jherr / create-mf-app

CLI app to create Module Federation applications
MIT License
730 stars 84 forks source link

[BUG] 'NODE_ENV' is not recognized (RSPACK) #70

Closed CosmeValera closed 1 month ago

CosmeValera commented 4 months ago

🐛 Problem

While using the Rspack version with any of the languages, when I try to execute npm start the following problem arises:

'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.

🧠 Thought process

This is a real life example of the error showed above: image

package.json:

{
  ...
  "scripts": {
    "build": "NODE_ENV=production rspack build",
    "build:dev": "NODE_ENV=development rspack build",
    "build:start": "cd dist && rspack serve",
    "start": "NODE_ENV=development rspack serve"
  },
  ...
}

However if I remove the NODE_ENV part in the start script this error does not appear anymore:

{
  ...
  "scripts": {
    "build": "NODE_ENV=production rspack build",
    "build:dev": "NODE_ENV=development rspack build",
    "build:start": "cd dist && rspack serve",
    "start": "rspack serve"
  },
  ...
}

image There is a configuration error, but the project is correctly displayed in the browser: image

🤠 Solution

I don't know much about Rspack, however my instant suggestion would be to simply remove the NODE_ENV=development and NODE_ENV=production from the scripts, so it at least works out of the box. However, it would be very helpful if someone that knew a bit about rspack could guide a little in this topic about what the correct approach for this would be. 💓💓

CosmeValera commented 4 months ago

@ScriptedAlchemy

zmzlois commented 2 months ago

It does shows as if this is a bug but I believe it is not.

Not sure about other frameworks but React conduct additional checks when NODE_ENV=development and setting it to NODE_ENV=production will improve performance.