opensourceBIM / BIMserver-JavaScript-API

BIMserver JavaScript API
GNU Lesser General Public License v3.0
55 stars 35 forks source link

Convert to ES2015 #10

Closed bastienmenis closed 6 years ago

bastienmenis commented 6 years ago

I have forked the code and converted it to and ES2015 module. In addition to modernising the code, it should help with compatibility with NodeJS (see #7)

https://github.com/bastienmenis/BIMserver-JavaScript-API

@rubendel I am happy to create a pull request but can you review this first? I did not understand how you manage the version numbers, I had to replace '%VERSION%' with a number so that the package.json could be parsed.

I used rollup/babel for bundling as an UMD module. The UMD module has been tested with bimSurfer. The ES2015 module has been tested in an Angular app with Rollup as bundler (it should also work with Webpack)

rubendel commented 6 years ago

That's really cool! I'll have a look at it tomorrow and let you know. The %VERSION% is replaced by a bash script before running the build script. If this could be integrated in the Grunt script that'd be better but not sure if that's possible. The version number itself is managed by the build server atm. Same bash script pushes it to npmjs.org, would be great to get that up and running as well.

bastienmenis commented 6 years ago

Ok, thanks. I have also switched from grunt to npm as the script runner. ("npm run build")

To manage the version numbers, another option is to use "npm version" before doing "npm publish".

Note that to use the library I had to change "new BimServerClient(...)" to "new bimserverapi.BimServerClient(...)" due to the way the module is bundled.

bastienmenis commented 6 years ago

@rubendel I have a few more suggestions:

  1. Rename the transpiled file to "bimserverapi.umd.js" to follow common module naming convention
  2. Include the transpiled file in releases, so that applications can load the library in a single file to improve performance (and add compatibility with older browsers)
  3. Put a version number in the package.json file. Because npm considers that the current file has an invalid version number, it is not possible to install the module as a dependency using:
    "dependencies": {
    "bimserverapi": "git+https://github.com/opensourceBIM/BIMserver-JavaScript-API.git",
    }
  4. Publish the new releases to npm. Just for convenience :)

I am happy to looks into 2, 3 and 4 if you can share your publish script

rubendel commented 6 years ago

Took a while, but had another look at this.

  1. Done
  2. Done
  3. Done during build phase, it's replaced by the version used in maven
  4. Done, need to have a look at the documentation

Have not tested in NodeJS yet...