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

Deno/Isolated Modules support, and GitHub Actions to test and fix #269

Merged
merged 17 commits into from
Jan 3, 2021
Merged

Deno/Isolated Modules support, and GitHub Actions to test and fix #269

merged 17 commits into from
Jan 3, 2021

Conversation

jeremyBanks
Copy link
Contributor

@jeremyBanks jeremyBanks commented Dec 13, 2020

Adds support for TypeScript's "isolated modules" mode, at the expense of bumping the minimum version for Zod v3 from TypeScript 3.7 to TypeScript 3.8. This changes type-only exports to use the export type keyword, and imports Jest's test helpers explicitly, so the TypeScript files can be compiled in isolation, instead of requiring shared context.

Adds a GitHub Actions workflow to automatically regenerate deno/lib as well as run our other fixers (eslint and prettier) automatically if a commit is pushed without running them locally.

Adds a GitHub Actions workflow to build and test again our maximum and minimum supported versions of TypeScript on Node, and also test on Deno.

This is still not compatible with deno bundle due to the bug denoland/deno#8680 (previously discussed around #209 (comment)). I experimented with changing export names to work around it, but the number of names that needed to be changed was significant, and the bundle still seemed to be invalid due to other errors, so I reverted those changes. For now we're only testing for compatibility with the primary deno run/deno install workflow (only using tsc), not the less-stable deno bundle/deno compile workflow (which uses both tsc and swc).

@jeremyBanks jeremyBanks mentioned this pull request Dec 13, 2020
@jeremyBanks jeremyBanks changed the title Isolated Modules support Isolated Modules support and testing on GitHub Actions Dec 13, 2020
@jeremyBanks jeremyBanks mentioned this pull request Dec 13, 2020
@jeremyBanks jeremyBanks marked this pull request as draft December 14, 2020 04:27
@jeremyBanks jeremyBanks changed the title Isolated Modules support and testing on GitHub Actions Deno/Isolated Modules support, testing and fixing on GitHub Actions Dec 14, 2020
@jeremyBanks jeremyBanks marked this pull request as ready for review December 14, 2020 04:34
@jeremyBanks jeremyBanks changed the title Deno/Isolated Modules support, testing and fixing on GitHub Actions Deno/Isolated Modules support, and GitHub Actions to test and fix Dec 14, 2020
@jeremyBanks
Copy link
Contributor Author

I haven't tested it yet, but Deno appears to have merged a fix for the SWC bundler issue, so it should work in the next release.

@colinhacks colinhacks merged commit 95d61bb into colinhacks:v3 Jan 3, 2021
@colinhacks
Copy link
Owner

colinhacks commented Jan 3, 2021

I merged this PR with a bunch of major structural changes from #226. Everything is now merged back into the v3 branch.

I'm not sure how to verify that everything is still working as expected for Deno users. All the tests pass and everything compiles nicely with "isolatedModules: true" so I went ahead and pushed the updated version to zod@next`. @jeremyBanks can you give it a try and look through the auto-generated deno/lib to make sure things are working?

Testing the SWC bundler bug fix would also be great 👍

@jeremyBanks
Copy link
Contributor Author

jeremyBanks commented Jan 3, 2021

@colinhacks Great! I imported the v3 branch (https://raw.githubusercontent.com/colinhacks/zod/410dd7b479e6252656abc7c457585deac5b83ee4/deno/lib/mod.ts) into an existing project and was able to use it in a few places without encountering any errors; it looks good to me. 👍

Unfortunately, the Deno/SWC bundler is still broken. The previous error has been fixed, the output is now syntactically valid, but it's renaming exported types in an inconsistent way that creates reference errors. I'll file a new issue with Deno for the new error once I have a chance to reduce it. 🤞

@jeremyBanks jeremyBanks deleted the v3-isolated-modules branch January 3, 2021 23:29
@jeremyBanks
Copy link
Contributor Author

jeremyBanks commented Jan 4, 2021

Filed bundler bug at denoland/deno#8978. I'm not sure if my reduced case is the exact same root cause, but it's probably at least a nearby bug.

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.

4 participants