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

WIP: Runtime APIs - modules section #13344

Closed
wants to merge 1 commit into from
Closed

Conversation

irvinebroque
Copy link
Contributor

Scaffolds out a new /runtime-apis/modules section to explain our ESM support and CommonJS support.

refs cloudflare/workerd#854 (comment)

  • Needs to cross-link
  • Needs to explain other module types
  • Needs some code examples to be clear about what will/won't work
  • Would benefit from clearer way to visualize role of Wrangler in process for those not thinking directly about what bundler is doing vs. what runtime is providing.
  • Should probably discourage CommonJS more strongly.

Scaffolds out a new /runtime-apis/modules section to explain our ESM support and CommonJS support.

By default, [Wrangler](/workers/wrangler/) bundles and uploads your code using the ES Modules format. When Wrangler bundles code, it transforms `require()` calls from [CommonJS](https://nodejs.org/api/modules.html) into code that can run on Workers in the ESM format. This allows you to use `require()` in your own code, or use libraries that are published as CommonJS — even though at runtime, `require()` and CommonJS are not supported from within an ES Module.

If you need to deploy code directly to Workers that directly uses the [CommonJS](https://nodejs.org/api/modules.html) format, and `require()` — it is possible to do so by [setting the module type in Wrangler to `CommonJS`](https://developers.cloudflare.com/workers/wrangler/configuration/#bundling).

Choose a reason for hiding this comment

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

🚫 [vale] reported by reviewdog 🐶
[cloudflare.RelativeLinks] Error: When referring to another page in our docs, use the full relative link (/1.1.1.1/check/) instead of the full URL (https://developers.cloudflare.com/1.1.1.1/check/).

Copy link

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8d91918
Status: ✅  Deploy successful!
Preview URL: https://03640559.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://bib-modules.cloudflare-docs-7ou.pages.dev

View logs

Copy link

@KimJ15
Copy link
Collaborator

KimJ15 commented Sep 27, 2024

👋Hi there, we’re going to close this PR due to inactivity and web framework migration

@KimJ15 KimJ15 closed this Sep 27, 2024
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.

4 participants