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

FEATURE: Add a script to copy Polyfills to distribution folder #1292

Open
RodrigoTomeES opened this issue May 17, 2023 · 3 comments
Open

FEATURE: Add a script to copy Polyfills to distribution folder #1292

RodrigoTomeES opened this issue May 17, 2023 · 3 comments
Labels
library Relates to an Origami library

Comments

@RodrigoTomeES
Copy link
Contributor

RodrigoTomeES commented May 17, 2023

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.

@JakeChampion
Copy link
Owner

Thanks for the thorough issue, this is great! I think you may be the first using polyfill-library in aws lambda and also as a NextJS route

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).

I don't believe polyfill-library stores anything in /var/ - I'm not sure what is doing that, I presume it is the NextJS' bundling mechanism because all the distribution polyfills are in ./node_modules/polyfill-library/polyfills/__dist/, which you should hopefully see on this page https://unpkg.com/browse/polyfill-library@3.111.0/polyfills/__dist/

@RodrigoTomeES
Copy link
Contributor Author

@JakeChampion I don't think is a problem with NextJS bundling because if we build a production NextJS without Serverless it's works so maybe the problem is that but in the Serverless bundling.

@RodrigoTomeES
Copy link
Contributor Author

RodrigoTomeES commented May 18, 2023

I update the README to reflect the problem with routes in AWS Lambda because this is not a library issue but it's without documentation #1291

@RodrigoTomeES RodrigoTomeES changed the title FEATURE: Support relative path for to read dist polyfills and add script to copy it to distribution folder FEATURE: Add a script to copy Polyfills to distribution folder May 21, 2023
@robertboulton robertboulton removed this from Backlog in Origami ✨ Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library Relates to an Origami library
Projects
None yet
Development

No branches or pull requests

2 participants