Build the library bundle from a src folder using rollup and other refactorings
The library works well in newer Node versions but we noticed that it was failing in a legacy project that is hard to upgrade with this message:
const {
^
SyntaxError: Unexpected token {
...
This is due to old Node versions don‘t support the destructuring assignments located in the main file.
Instead of trying to modify the code to support old Node versions, it is better to write modern JavaScript code in a source folder and compile it using ES5 to a distribution folder (which makes the library ready to work with Node 4). So, it is possible to use any ESNext code as:
Without any fear that the code could fail because of compatibility issues.
To make this possible a tandem of rollup and @rollup/plugin-typescript has been used. rollup opens the door for creating other distribution versions of the package if they are needed (like an ESM version) and @rollup/plugin-typescript allows writing the code in TypeScript if it is wanted in the future, its function, for now, is just to transpile any modern JavaScript code into ES5 standard code.
As part of this pull-request other changes have been made:
- The package distribution now includes only the files inside the
libfolder (CHANGELOG, README, LICENSE, and package.json are included by default) - A
lint:fixscript has been created to fix all the prettier issues - The filters have been extracted to separate modules
- The code has been refactored to use ES modules, ES2015 JavaScript features, and a more functional approach
- A polyfill module has been created to add polyfills (the only one right now is an
Object.valuespolyfill)
@elchininet Wow it's a big change, complete rewrite. I'll need some time to look at it.
Hi @AoDev, I can separate the changes in smaller pull requests to help you review them better. Let me know if that could help you. Regards!