Add support for "browser" field for jspm itself #1675

Closed
letmaik opened this Issue Apr 3, 2016 · 5 comments

Projects

None yet

2 participants

@letmaik
letmaik commented Apr 3, 2016

As written in another issue jspm currently supports the "browser" field only for npm installs. I think it would be really useful to support this in jspm itself, especially when trying to make npm source repositories compatible to jspm.

In my case, I develop an npm package which uses transpilation and "browser". For development purposes it would be nice to be able to depend on that package as a normal github dependency from jspm. And the browser field support is the last missing piece for that: https://github.com/Reading-eScience-Centre/covjson-reader/blob/d21eaf68517881f7bcc17cf5c36388d089c08a56/package.json#L44 An alternative main entry point for jspm is really not a convenient solution here.

Is there any chance for adding such a feature? Or a good reason not to have it?

@guybedford
Member

In jspm we encourage conditional package configuration over this existing browser convention. This can currently be done in jspm 0.17 with a package.json containing:

{
  "main": "index.js",
  "map": {
    "./index.js": {
      "browser": "./index-browser.js"
    }
  }
}
@guybedford guybedford closed this Apr 29, 2016
@letmaik
letmaik commented Apr 29, 2016

What are the conditions exactly in general?

@guybedford
Member

Documentation is lacking but currently the core system conditions are browser, production and node. Custom conditions can be configured as well, although this is currently still an undocumented workflow for packages.

@letmaik
letmaik commented May 1, 2016

Seems like production is a thing that could be combined with browser or node. How would that look like then? And what is it anyway? Is the "default" mode something like development?

@guybedford
Member

jspm bundle and bulid will by default bundle for the browser in production. This can be altered by providing the --node or --dev flags to the build commands. SystemJS builder allows fine-grained setting of conditions though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment