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

Add deno support to findConfigurationFlag #73

Merged
merged 1 commit into from
Oct 29, 2020

Conversation

bdchauvette
Copy link
Contributor

Hi @lorenzofox3!

Thanks for such a great project. I've been using zora with ESBuild and it's such a breath of fresh air using tools that are so clean and so fast!

What this PR does

Adds support for loading configuration flags from environment variables when running zora in Deno.

Why

I've been using zora on a few projects and I really love it as a way to run tests that work in any JS environment.

For one of my projects (still private, unfortunately), I'm supporting Deno. zora itself has been working great with Deno -- at least when using a bundler; I haven't tried running it from e.g. unpkg -- but I'd like to be able to set configuration flags using environment variables.

Note that the change in this PR is just a minor DX improvement for packages that only target Node and Deno. It's not strictly necessary because Deno's supports using window as a global object, so doing something like this does work:

if (typeof window !== "undefined") {
  // @ts-expect-error
  window.INDENT = true;
}

It's relatively minor bit of boilerplate, and it's required when targeting browsers anyway, but I still wish I didn't need it for packages that don't intend to be run in browsers.

AFAIK, outside findConfigurationFlags, the rest of zora is Just JavaScript (:sparkles:), so I don't think Deno requires any additional changes to work with zora. However, I totally understand that you might not want to add the burden of having to support an additional runtime. Maybe this this could be a first step towards something like "experimental support for Deno"? 🤷

Anyway, thanks again for such a great project! Let me know if you have any questions.

Related

@bdchauvette
Copy link
Contributor Author

In lieu of publishing my branch on npm so it can be consumed by Deno, here's a demo on repl.it with the bundle pasted in:

https://repl.it/@bdchauvette/zora-deno-config

@lorenzofox3 lorenzofox3 merged commit 8e2fae8 into lorenzofox3:master Oct 29, 2020
@lorenzofox3
Copy link
Owner

Thanks a lot !

I thought Deno came with its own testing utilities. Why don't you use it

@bdchauvette
Copy link
Contributor Author

Thanks!

Deno does come with a test runner, but I'm trying to make sure my tests can run in all of the targeted environments (node, deno, sometimes browser). If I used deno's built-ins, I wouldn't be able to run the suite in the other environments -- at least not very easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants