parcel-bundler / website

🌎 Parcel website
https://parceljs.org
MIT License
350 stars 466 forks source link

A shared node/webapp in a single package #1008

Open mischnic opened 2 years ago

mischnic commented 2 years ago

Adding engines.node causes "External modules are not supported when building for browser".

So you need to do

  "engines": {
    "node": ">=14.0"
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": ">= 50%"
      }
    }
  }
eddiemonge commented 2 years ago
  "engines": {
    "node": ">=16",
  },
  "targets": {
    "default": {
      "engines": {
        "browsers": "> 0.5%, last 2 versions, not dead"
      }
    }
  },
  "browserslist": "> 0.5%, last 2 versions, not dead",

It should be reading off of browsersList but if a top level engines is defined, then a targets.defaults needs an engines as well, which is a possible duplicate of browsersList.

mischnic commented 2 years ago

The "problem" in that case is that either "engines.node" or "browserslist" needs to have a higher precedence to make the default target a node or browser target. I'm actually not sure if browserslist or engines.node wins at the moment

gcp commented 2 years ago

As explained in the linked ticket, you can hit this case even for things that aren't node apps at all, because some environments use the package.json engines section to figure out what node version to use for the project (even if only to run Parcel itself!).