polyfill-library icon indicating copy to clipboard operation
polyfill-library copied to clipboard

FEATURE: Add a script to copy Polyfills to distribution folder

Open RodrigoTomeES opened this issue 1 year ago • 3 comments

Hello,

Recently, we attempted to implement an endpoint in NextJS to serve client-based polyfills. During local testing, it worked perfectly, even with the production build. However, upon deployment to the development environment, the API encountered an error indicating that it couldn't locate the polyfills.

As a result, we opened issue #1219 to address this problem. With the assistance of @JakeChampion, we were able to find a solution. To resolve the issue, we need to include the polyfills in our final bundle and modify the plugin's access path for reading the polyfills, thereby creating a package path. Consequently, I propose the following two changes:

  • ~~Store the distribution polyfills in a relative path instead of /var/... to avoid potential issues in environments where that path is inaccessible (e.g., in a lambda function).~~
  • Provide a script that copies the polyfills to the distribution build, similar to the functionality offered by partytown.

Implementing these changes will greatly simplify the process of using the library when generating a bundle.

Thank you and best regards!


The framework used is NextJS and it's deployed to AWS Lambda with Serverless NextJS.

RodrigoTomeES avatar May 17 '23 10:05 RodrigoTomeES