Giter Site home page Giter Site logo

Comments (5)

ashalfarhan avatar ashalfarhan commented on June 15, 2024 3

I'm facing the same issue, aliasing the module to point to the dist directory works fine for me:

import { defineConfig } from 'vite';

export default defineConfig({
  resolve: {
    alias: {
      validatorjs: 'validatorjs/dist/validator.js',
    },
  },
});

from validatorjs.

derekcannon avatar derekcannon commented on June 15, 2024 1

I'm having similar issues when switching over to Vite from Webpack, while using MobX React Form and ValidatorJS as the validator. Setting a field to "required", and attempting to validate it returns the following:

image

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'def')
at Messages._getTemplate (messages.js:103:29)
at Messages.render (messages.js:82:25)
at Validator._addFailure (validator.js:151:29)
at Validator.check (validator.js:73:16)
at Validator.passes (validator.js:494:17)
at DVR2.validateFieldSync (DVR.js:126:22)
at DVR2.validateField (DVR.js:88:12)
at Validator.js:160:33
at _createBaseFor.js:17:11
at baseForOwn (_baseForOwn.js:13:20)

from validatorjs.

foxhound87 avatar foxhound87 commented on June 15, 2024 1

I'm facing the same issue, aliasing the module to point to the dist directory works fine for me:

import { defineConfig } from 'vite';

export default defineConfig({
  resolve: {
    alias: {
      validatorjs: 'validatorjs/dist/validator.js',
    },
  },
});

This solution worked until I called useLang method.
Needs a fix to handle language.

from validatorjs.

gregfenton avatar gregfenton commented on June 15, 2024

My suspicion, though I don't know much about "bundling", is that, I believe, the library attempts to load "language files" via require_method('./lang/' + lang) and that require_method = require;

I suspect the issue is that the language files are not being bundled by Vite?

I'm not sure how/if I can:

  • tell Vite to bundle the resource files of a named NPM ??
  • fork the NPM and add some vite-specific configuration ??
  • fork the NPM and add some additional NPM or JS configuration such that its files bundle correctly (with Vite or with all bundlers??)

Pointers to docs or concepts or appropriate terminology for what I'm looking at here would be GREATLY appreciated!!

from validatorjs.

stellarhoof avatar stellarhoof commented on June 15, 2024

Not the best, but with yarn, package.json can be patched to change https://github.com/mikeerickson/validatorjs/blob/master/package.json#L21 from "main": "./src/validator.js", to "main": "./dist/validator.js",

from validatorjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.