JSPM Bundling Workflows

61 views
Skip to first unread message

CJ Koski

unread,
May 25, 2016, 3:07:41 PM5/25/16
to jspm
Hi,


Currently for software releases I go through the following process:

1.  jspm unbundle.

2.  Delete the old bundles from revision control.

3.  For each bundle type that was unbundled (one for each JS app type), run jspm bundle app/type app_type_release_version_x_bundle.js --inject 

4.  Commit all new bundles for deployment.


I would like to be able improve this process and automate it sometime in the future soon, which is fine, I can do so.

But would be nice so that I could only re-bundle the modules and their dependencies when they have changed since the last bundling.

IE jspm unbundle removes all bundles, so I have to recreate them all.  And now clients will have to download new app bundles on each release even though there was nothing that changed.


Maybe I should be approaching this in a different way?

Cheers and thanks any help :)

 

Guy Bedford

unread,
Jun 10, 2016, 8:07:00 AM6/10/16
to CJ Koski, jspm
If you have multiple packages, and are publishing bundles with each package, then that isn't not advisable yes - publishing bundles is generally not a good idea as small configuration differences will cause headaches.

Perhaps you can publish a static build rather with exclusions? Alternatively run bundling as the pre-production step rather than an intermediate publishing step.

--
You received this message because you are subscribed to the Google Groups "jspm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspm-io+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

CJ Koski

unread,
Aug 12, 2016, 3:39:07 PM8/12/16
to jspm, cjk...@gmail.com
Thanks Guy.

I can't do the bundling as a production step because I don't have the liberty to install node across our web servers.

So I ended up provisioning a server that is specifically for publishing and updated the tagging process to create bundles automatically.

I am using the JSPM node API to generate the bundles in memory first to get a hash and used this as the file name so that server and browser caches will work for as long as a bundle does not change.  

var builder = new jspm.Builder();
builder.bundle('app/' + bundleName, {}).then(function (output) {  //generate bundle output in memory for md5 hash
var hash = crypto.createHash('md5').update(output.source).digest('hex');
jspm.bundle('app/'+bundleName, 'bundles/'+bundleName.replace('.js', '')+"-"+hash+'.js', {injectConfig: true}).then(function() {
...

And when bundles do change the file name will change and invalidate any caching.
Reply all
Reply to author
Forward
0 new messages