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

feat(cloudflare-module, cloudflare-pages): experimental dynamic imports #1172

Merged
merged 11 commits into from
Aug 21, 2023

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Apr 19, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This adds support for dynamic imports with CF modules following cloudflare/workers-sdk#2769. (Feature coming soon to CF Pages too: merged via #1531 by @dario-piotrowicz to this PR)

Experiment can be enabled by setting NITRO_EXP_CLOUDFLARE_DYNAMIC_IMPORTS environment variable.

Pending: cloudflare/workers-sdk#3707

TODO:

  • __STATIC_CONTENT_MANIFEST import support
  • update docs with rules info (and console warning)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added enhancement New feature or request preset:cloudflare labels Apr 19, 2023
@danielroe danielroe requested a review from pi0 April 19, 2023 10:35
@danielroe danielroe self-assigned this Apr 19, 2023
@pi0
Copy link
Member

pi0 commented Apr 19, 2023

Thanks for PR. I think previously there were issues with module format and dynamic chunks (globalThis injection).

I will double check this you can also try on a nuxt project :)

@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #1172 (d44436f) into main (6a1ea5c) will decrease coverage by 0.10%.
The diff coverage is 36.84%.

❗ Current head d44436f differs from pull request most recent head 0d98d24. Consider uploading reports for the commit 0d98d24 to get more accurate results

@@            Coverage Diff             @@
##             main    #1172      +/-   ##
==========================================
- Coverage   77.80%   77.70%   -0.10%     
==========================================
  Files          76       76              
  Lines        7816     7835      +19     
  Branches      797      801       +4     
==========================================
+ Hits         6081     6088       +7     
- Misses       1732     1744      +12     
  Partials        3        3              
Files Changed Coverage Ξ”
src/presets/cloudflare-pages.ts 58.87% <30.00%> (-1.42%) ⬇️
src/presets/cloudflare-module.ts 88.09% <44.44%> (-11.91%) ⬇️

@nuxt-studio
Copy link
Contributor

nuxt-studio bot commented Apr 19, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
nitro Edit on Studio β†—οΈŽ View Live Preview 0d98d24

@Rigo-m
Copy link
Contributor

Rigo-m commented Apr 19, 2023

Faster than light

@pi0 pi0 changed the title feat(cloudflare): enable dynamic imports for worker modules feat(cloudflare-module, cloudflare-pages): enable dynamic imports Aug 6, 2023
@pi0 pi0 changed the title feat(cloudflare-module, cloudflare-pages): enable dynamic imports feat(cloudflare-module, cloudflare-pages): experimental dynamic imports Aug 21, 2023
@pi0 pi0 marked this pull request as ready for review August 21, 2023 00:27
@pi0
Copy link
Member

pi0 commented Aug 21, 2023

Thanks for this initiative @danielroe, @dario-piotrowicz πŸ’š I have made some small refactors to allow enabling this experiment via NITRO_EXP_CLOUDFLARE_DYNAMIC_IMPORTS and make testing easier.

@pi0 pi0 merged commit 345d0cc into main Aug 21, 2023
6 checks passed
@pi0 pi0 deleted the feat/split-workers branch August 21, 2023 00:29
@pi0 pi0 mentioned this pull request Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request preset:cloudflare
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants