standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.26k stars 146 forks source link

dependency suggestion for module authors #761

Closed dnalborczyk closed 5 years ago

dnalborczyk commented 5 years ago

I was thinking about the best approach on how to handle esm as 3rd party module dependency.

it probably depends on the particular use case of a particular module.

let's say we have a utility module, meant for being used in the browser as well as in node.js, e.g. like lodash, exposing "main" and "module" in package.json. main points to the bridge, module points to the real deal.

I'm leaning towards dev dependency as well as either peer dependency or optional dependency (although I must admit I'm not sure about the ins and outs of optional dependencies

{
  "devDependencies": {
    "esm": "^3.2.20"
  },
  "peerDependencies": {
    "esm": ">= 3.0.0 < 4.0.0"
  }
}

or:

{
  "devDependencies": {
    "esm": "^3.2.20"
  },
  "optionalDependencies": {
    "esm": ">= 3.0.0 < 4.0.0"
  }
}

@jdalton any thoughts or suggestions on this one?

jdalton commented 5 years ago

any thoughts or suggestions on this one?

Keeping it as a dependency is fine. Usually packages will specify a browser field or they can simply reference their entry ES module for browser use.