-
Notifications
You must be signed in to change notification settings - Fork 533
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-pages, cloudflare-module): enable code splitting by default #1905
Conversation
remove the NITRO_EXP_CLOUDFLARE_DYNAMIC_IMPORTS flag used to enable code splitting with lazy loading for the cloudflare-pages and cloudflare_module presets and enable such behavior by default since that is not stable and working with up-to-date versions of wrangler
β Live Preview ready!
|
rules = [ | ||
{ type = "ESModule", globs = ["**/*.js", "**/*.mjs"]}, | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added those here to simplify the documentation and not requiring people to set them only when using the cloudflare_module preset.
The the service worker output these are not going to do anything but they are not breaking anything either (as you can see from this example), that's why I think it's simpler to just include them here, but let me know what you think, I don't mind moving it into the cloudflare_module preset section.
@@ -12,7 +12,7 @@ describe("nitro:preset:cloudflare-pages", async () => { | |||
testNitro(ctx, () => { | |||
const mf = new Miniflare({ | |||
modules: true, | |||
scriptPath: resolve(ctx.outDir, "_worker.js"), | |||
scriptPath: resolve(ctx.outDir, "_worker.js", "index.js"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we always need a path like this as .../_worker.js/index.js
? (double extension seems strange but fine if it is only allowed convention)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's the only allowed convention unfortunately π
later this might be configurable but for now it has to be like this π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try on nightly channel!
This is huge π₯ |
β Type of change
π Description
remove the NITRO_EXP_CLOUDFLARE_DYNAMIC_IMPORTS flag (added in #1172) used to enable code splitting with lazy loading for the cloudflare-pages and cloudflare_module presets and enable such behavior by default since that is not stable and working with up-to-date versions of wrangler
For the stability of this feature please have a look at these reproductions: https://github.com/dario-piotrowicz/nitro-nuxt-lazy-loading-test/tree/main
They show that things do work fine (both locally and in production) when using lazy loading πͺ
π Checklist