question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🚀 Feature Request: Load values from wrangler.toml

See original GitHub issue

Describe the solution

A lot of times, I’d like my worker code to depend on some values I have in my wrangler.toml (e.g. getting the worker name, getting the routes it can be deployed to, etc.)

While I can duplicate this information in JS, it’d be easier if I could just import my wrangler.toml the same way I can import my package.json.

We should include a plugin to parse .toml files with esbuild (such as esbuild-plugin-toml so that wrangler publish can include imports from toml files.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
petebacondarwincommented, Jun 6, 2022

We can currently achieve this via a custom build step, so I’m going to close this as not something we should implement in core Wrangler.

0reactions
petebacondarwincommented, May 30, 2022

We should also be aware that the structure of a wrangler.toml is quite complex with all the inheritance options. So even if you imported this file directly, you might not be reading the correct values depending upon the current environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration · Cloudflare Workers docs
Wrangler optionally uses a wrangler.toml configuration file to customize the development and publishing setup for a Worker.
Read more >
🚀 Feature Request: improve the wrangler.toml config ... - GitHub
Describe the solution A feedback that often comes up in various discussions is that the toml config file is not ergonomic, error-prone, ...
Read more >
Using the CLI - Miniflare
Fun, full-featured, fully-local simulator for Cloudflare Workers.
Read more >
Ditch the Wrangler CLI for Miniflare - LogRocket Blog
To get started with Miniflare, all you need is Node.js and npm: mkdir worker cd worker npm init -y ... Next, move over...
Read more >
Troy Hunt on Twitter: "@lxalln Are you sure? Docs say either ...
Worker environment variable I declare in wrangler.toml overwrite the ... Today we're releasing one of the most requested Workers features: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found