Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

Summary

Adds documentation for missing Wrangler configuration

Documentation checklist

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 3 total issue(s) found.

petebacondarwin and others added 2 commits October 14, 2024 20:48
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 total issue(s) found.

Copy link
Contributor

@GregBrimble GregBrimble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it's not strictly related to your change, but I wonder if it's worth just calling out somewhere on this page that automatic bundling is what makes TypeScript possible. It's not actually obvious when we say stuff like "TypeScript is a first-class language on Cloudflare Workers" elsewhere in the docs.

This is especially important if we're making module discovery more accessible. It should be really clear that these modules need to be given to us as ESM/CJS/Wasm/Text or Data.

Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty @petebacondarwin for docs, few notes re: dynamic imports behavior at runtime


This approach is useful for supporting lazy loading of large or dynamically imported JavaScript files:

- Normally, a large lazy-imported file (for example, `await import("./large-dep.mjs")`) would be bundled directly into your entrypoint, reducing the effectiveness of the lazy loading.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you upload these as separate modules, don't we still have an issue?

cloudflare/workerd#2372

Or am I misunderstanding the problem there?

cc @jasnell

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is definitely still a cost, since as I understand it, we do parse all modules at start up. The main difference, unless I am mistaken is that we don't execute the code in the lazy module until it is imported.
Despite this, we found that next-on-pages start up time was improved dramatically by splitting out chunks from the main entry-point, so there is some benefit.
Also, once we update the implementation in workerd this will become significantly improved, so things can only get better if you use this approach.

@petebacondarwin
Copy link
Contributor Author

I know it's not strictly related to your change, but I wonder if it's worth just calling out somewhere on this page that automatic bundling is what makes TypeScript possible. It's not actually obvious when we say stuff like "TypeScript is a first-class language on Cloudflare Workers" elsewhere in the docs.

This is especially important if we're making module discovery more accessible. It should be really clear that these modules need to be given to us as ESM/CJS/Wasm/Text or Data.

Actually, I think an even better solution would be for us to be able to run non-ESM JavaScript/TypeScript additional modules through esbuild to ensure they are also in the right state for consumption by workerd.

@GregBrimble
Copy link
Contributor

Actually, I think an even better solution would be for us to be able to run non-ESM JavaScript/TypeScript additional modules through esbuild to ensure they are also in the right state for consumption by workerd.

There's definitely some code lying around somewhere for a "process entrypoint"/"bundle no-bundle" sort of thing which could be used. Interesting idea. And I guess --no-bundle still works as the opt-out. Yeah, could be explored!

@petebacondarwin petebacondarwin force-pushed the pbd/add-find-additional-modules-docs branch from 47f4dd0 to c7a0e61 Compare October 16, 2024 13:13
@petebacondarwin petebacondarwin merged commit fcd5446 into cloudflare:production Oct 17, 2024
7 checks passed
@petebacondarwin petebacondarwin deleted the pbd/add-find-additional-modules-docs branch October 17, 2024 15:21
@irvinebroque
Copy link
Contributor

Thank you Pete!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants