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

build: drop SWC; use TS for cjs/esm bundles #8

Merged
merged 2 commits into from
Dec 14, 2022
Merged

build: drop SWC; use TS for cjs/esm bundles #8

merged 2 commits into from
Dec 14, 2022

Conversation

dimitrisnl
Copy link
Contributor

@dimitrisnl dimitrisnl commented Dec 12, 2022

What changed

  • Drop SWC in favour of using just TypeScript
  • Introduce 3 different tsconfigs. 1) ESM, 2) CJS, 3) Types
  • Completely drop exports key

Other References

Beta link

https://www.npmjs.com/package/zod-validation-error/v/0.2.2-beta.1

@changeset-bot
Copy link

changeset-bot bot commented Dec 12, 2022

🦋 Changeset detected

Latest commit: d24f4bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
zod-validation-error Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dimitrisnl dimitrisnl marked this pull request as ready for review December 12, 2022 12:26
@dimitrisnl
Copy link
Contributor Author

dimitrisnl commented Dec 12, 2022

ESM seems to be working

import zod from "zod";
import { fromZodError } from "zod-validation-error";

const userSchema = zod.object({
  name: zod.string(),
  age: zod.number(),
  email: zod.string().email(),
});

export function parseUser(value) {
  try {
    userSchema.parse(value);
  } catch (err) {
    const validationError = fromZodError(err);

    console.log(validationError);
  }
}


parseUser({age: 4, email: "test@test.com"})
dnl::src ⌁ node main.mjs                             
ValidationError: Validation error: Required at "name"
    at fromZodError (<project-path>/node_modules/zod-validation-error/dist/cjs/ValidationError.js:27:12)
    at parseUser (file://<project-path>/src/main.mjs:14:29)
    at file://<project-path>/src/main.mjs:21:1
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  details: [
    {
      code: 'invalid_type',
      expected: 'string',
      received: 'undefined',
      path: [Array],
      message: 'Required'
    }
  ]
}

Copy link
Contributor

@jmike jmike left a comment

Choose a reason for hiding this comment

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

Greatness.

jest.config.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@jmike
Copy link
Contributor

jmike commented Dec 13, 2022

@nikoskalogridis can you also afford some time to review this please?

@dimitrisnl dimitrisnl merged commit fa81c9b into main Dec 14, 2022
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.

3 participants