-
-
Notifications
You must be signed in to change notification settings - Fork 58
SharepointPlus v6.0 Announcement
It was already possible to use sharepointplus
as a Node module, however it was just an adaptation of the browser's version.
I'm now doing 100% of my development in a Node environment, using Webpack and other tools, and it was about time to update sharepointplus
code to a more modern JavaScript!
The code of sharepointplus
has been split to now have one function per file. I also leverage the ES6 features like await
and arrow functions
to come up with a more readable code.
I created a new test suite, adding more tests to the existing functions, and expanding it to Sharepoint Online. sharepointplus
is officially fully compatible with Sharepoint Online.
One great thing with Webpack is the ability to do tree-shaking: _"Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module syntax."
By splitting my code to small files, we're now able to only import the code that is really needed, cutting down the dead-code. This allows you to have smaller bundles.
To use this new feature, you could manually import all the modules/files, but it doesn't look simple enough for me, so I created a Webpack plugin loader called sharepointplus-loader
that will do all the hard work for you.
You have 3 different options to import sharepointplus
in your project:
You can import all modules, however the final bundle will be quite big:
import $SP from 'sharepointplus'
Another solution is to manually select the files you'll use. In that case, your bundle will only contain the necessary code.
Let's suppose you only need these functions in your web project: $SP().list().get()
, $SP().list().remove()
and $SP().toSPDate()
.
import spInit from 'sharepointplus/es5/init.js'
import list from 'sharepointplus/es5/lists/list.js'
import get from 'sharepointplus/es5/lists/get.js'
import remove from 'sharepointplus/es5/lists/remove.js'
import toSPDate from 'sharepointplus/es5/utils/toSPDate.js'
const $SP = spInit({'list':list, 'get':get, 'remove':remove, 'toSPDate':toSPDate});
The best option is to use the Webpack plugin loader called sharepointplus-loader
that will do the best of the two previous options.
In your code, you'll only call sharepointplus
:
import $SP from 'sharepointplus'
Then sharepointplus-loader
will automatically convert that line to call the necessary code. Using the same example from option 2, your code will be transformed to:
// #### The below code is automatically generated by the plugin
```javascript
import spInit from 'sharepointplus/es5/init.js'
import list from 'sharepointplus/es5/lists/list.js'
import get from 'sharepointplus/es5/lists/get.js'
import remove from 'sharepointplus/es5/lists/remove.js'
import toSPDate from 'sharepointplus/es5/utils/toSPDate.js'
const $SP = spInit({'list':list, 'get':get, 'remove':remove, 'toSPDate':toSPDate});
Today I'm announcing SharepointPlus v5.0 that is a major break for the users:
- No more Callbacks : all functions return a Promise, and the Callbacks are not supported anymore (see the documentation of each function);
- Support from IE11 : bye bye IE8 ! The tests will run under IE11 and modern browsers (but the technology I'm using should be OK for IE9+). The developers will be responsible to verify it works for older browsers;
- Nanoajax has been integrated, so jQuery.ajax is not used anymore, even if you have jQuery in the page;
- All functions related to form fields are moved into a dedicated plugin: it means you'll have to call the plugin file if you want to use
$SP().formfields()
.
By rewriting all the functions I've also reviewed some parameters and some data returned by them. It will be detailed into the changelog.
The file's size is 20% lighter than v4.0, and it makes it easier to maintain. In parallel I've added more than 30 new Unit tests (~191 tests are done) to make sure everything is still working as expected.
I won't release this new version right away. Actually I'm starting a big project in Sharepoint 2013 in which I'll have the opportunity to test this v5.0 and add more stuff. At the end of this project (end of October) I'll publish the library in the main channel.
SharepointPlus v5.0 won't be safe to use in existing projects (it might be safe if you take the time to modify your code), so I'd only recommend it for new projects.
//Polyfill included