rtfeldman / seamless-immutable

Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.
BSD 3-Clause "New" or "Revised" License
5.37k stars 194 forks source link

Why package.json doesn't point to seamless-immutable.production.js? #164

Closed nazar-pc closed 7 years ago

nazar-pc commented 7 years ago

In my framework I have a convenient feature that allows to automatically call AMD modules with RequireJS by their name. For instance, after seamless-immutable installation I am able to do require(['seamless-immutable '], ...) anywhere in my app and it just works.

In order for above feature to work I'm using different keys from both bower.json and package.json in order to determine which file should be used by RequireJS to map package name alias there.

However, currently package.json for whatever reason points to source instead of production version. Moreover, it causes an error ReferenceError: process is not defined at makeImmutable on this line.

What is the idea behind this decision and could it be changed to production file in next releases?

nazar-pc commented 7 years ago

Also depends on #117

rtfeldman commented 7 years ago

It's done this way for people using seamless-immutable on Node: it respects Node's production flag automatically, whereas in the browser you can load whichever is appropriate.

nazar-pc commented 7 years ago

What about to add another key browser to package.json with seamless-immutable.production.min.js in it so that it would be possible to find deterministically which file browser should use?

I've added similar key to Redux already (https://github.com/reactjs/redux/pull/2047), quote from there:

There was a key browser in jQuery's package.json in past, so I decided that this is a good candidate to use.

I'm currently checking following keys (based on package.json files of other popular projects) with priority from higher to lower:

  • browser
  • jspm.main
  • main

As a side note, would be nice to have some more common structure for production builds, like dist/seamless-immutable.js (production version) and dist/seamless-immutable.min.js (production minified version).

rtfeldman commented 7 years ago

As a side note, would be nice to have some more common structure for production builds, like dist/seamless-immutable.js (production version) and dist/seamless-immutable.min.js (production minified version).

We already have that, except it's at the project root rather than in a dist/ folder. 🙂

Arguably a dist folder would be a slightly better place to put them, but I don't think that slight improvement is worth breaking everyone's builds the next time they upgrade.

nazar-pc commented 7 years ago

Arguably a dist folder would be a slightly better place to put them, but I don't think that slight improvement is worth breaking everyone's builds the next time they upgrade.

There are 2 ways here, neither of which is perfect:

rtfeldman commented 7 years ago

The third option is sticking with the status quo, which seems to have the fewest downsides.

nazar-pc commented 7 years ago

Closing this as #177 was merged, which solves issue for me.

Do you have plans to release a new version anytime soon?

nazar-pc commented 7 years ago

Nice, I see new release already:)