Skip to content

Support custom export conditions for import map generation #1613

@thescientist13

Description

@thescientist13

Motivation

Greenwood by default only supports three of the standard export conditions as defined in the NodeJS docs; import, module-sync, and default

For example, worker or browser - https://app.unpkg.com/[email protected]/files/package.json#L129

"./web": {
  "worker": {
    "types": "./web/types/index.d.ts",
    "import": "./web/dist/server.js",
    "require": "./web/dist/server.cjs"
  },
  "browser": {
    "development": {
      "types": "./web/types/index.d.ts",
      "import": "./web/dist/dev.js",
      "require": "./web/dist/dev.cjs"
    },
  }
 // ...
},

Technical Design

This is probably something Greenwood could handle through configuration most likely, since custom user conditions are valid through the exports map spec.

export default {
  importMap: {
    conditions: ['worker', 'browser']
  }
}

Basically we just want to add them the existing list
https://github.com/ProjectEvergreen/greenwood/blob/v0.34.0-alpha.0/packages/cli/src/lib/walker-package-ranger.js#L5

Would want to add a test case for this.

Additional Context

#1436 (can close this one out after we release this)

Metadata

Metadata

Labels

Projects

Status

🔖 Ready

Relationships

None yet

Development

No branches or pull requests

Issue actions