Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build the library bundle from a src folder using rollup and other refactorings #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

elchininet
Copy link
Contributor

@elchininet elchininet commented Nov 25, 2021

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 lib folder (CHANGELOG, README, LICENSE, and package.json are included by default)
  • A lint:fix script 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.values polyfill)

@AoDev
Copy link
Owner

AoDev commented Apr 29, 2022

@elchininet Wow it's a big change, complete rewrite. I'll need some time to look at it.

@elchininet
Copy link
Contributor Author

elchininet commented Apr 29, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants