googlearchive / vrview

Library for embedding immersive media into traditional websites.
http://developers.google.com/cardboard/vrview
Apache License 2.0
1.71k stars 1.09k forks source link

Make it easier to use the module as an npm dependency #276

Closed taye closed 5 years ago

taye commented 6 years ago

This PR

  1. moves packages which are needed by the npm build script from devDependencies to dependencies
  2. adds a postinstall script which runs npm build
  3. fixes a require call which incorrectly assumed the location of of the stats-js module (#159)

so that developers can

npm i github:google/vrview
const { Player } = require('vrview/build/api');
jsantell commented 6 years ago

What's the reasoning behind browserify and rollup being dependencies? They should not be in the final distributable build, but only used for the build process itself

taye commented 6 years ago

Having the build tools listed as dependencies ensures that npm makes them available for vrview's build process as it's installed as a dependency. Otherwise, a dependent package would need to list the same build tools as dependencies to install vrview and successfully run the postinstall script.

jsantell commented 6 years ago

If you're pulling down vrview as a dependency, it should not pull down browserify/rollup to be included in a consumer's bundle. The build process in this project needs some work to support npm importing, but requiring consumers to build the project isn't the way to do it, I think. Ideally it'd reference a prebuilt distributable. Are there other popular projects putting build dependencies in dependencies and requiring consumers to build a JS lib on npm? I know native modules perform something like this, but they don't have the dependency vs devDependency issue. Curious to learn more

taye commented 6 years ago

If you're pulling down vrview as a dependency, it should not pull down browserify/rollup to be included in a consumer's bundle. The build process in this project needs some work to support npm importing, but requiring consumers to build the project isn't the way to do it, I think.

From the info in the readme and the fact that the project doesn't seem to be published to npm, I got the impression that having prebuilt files in the package wasn't preferred.

Ideally it'd reference a prebuilt distributable.

I'd like this. I think that publishing the build artefacts to npm and/or committing them to a tagged release branch would be a nice way to do this.

Are there other popular projects putting build dependencies in dependencies and requiring consumers to build a JS lib on npm? I know native modules perform something like this, but they don't have the dependency vs devDependency issue. Curious to learn more

I don't remember coming across any non native packages that do this. Committing build output is quite common though.

jsantell commented 6 years ago

@taye we're having a chat on our end next week to see how we can make the build/setup/install experience nicer, with fully supporting npm usage, and bringing this up to speed. Will have more to update then; thanks!