ritchieanesco/json-schema-yup-transform

Error on import of json-schema-yup-transform

Closed this issue · 3 comments

When importing json-schema-yup-transformer as of version 1.6.8:

import convertToYup from 'json-schema-yup-transformer';
// or with CJS: const convertToYup = require('json-schema-yup-transformer');

the following error happens:

/tmp/test/node_modules/json-schema-yup-transformer/dist/schema/utils.js:29
    [_1.DataTypes.STRING]: isString_1.default,
                  ^

TypeError: Cannot read properties of undefined (reading 'STRING')
    at Object.<anonymous> (/tmp/test/node_modules/json-schema-yup-transformer/dist/schema/utils.js:29:19)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/tmp/test/node_modules/json-schema-yup-transformer/dist/schema/index.js:14:14)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)

Additional info:

  • I am experiencing this both in Node.js (v16.14.2) and in Chrome with webpack 5;
  • version 1.6.4 works correctly;
  • quick investigation reveals that cyclic dependencies may be the reason for the bug, see #59.

Same error here with 1.6.8, using vite 2.9.14 and node 16

TypeError: Cannot read properties of undefined (reading 'STRING')
    at node_modules/json-schema-yup-transformer/dist/schema/utils.js (utils.ts:28:14)
    at __require2 (chunk-IJ7IQSKN.js?v=131fbf65:19:50)
    at node_modules/json-schema-yup-transformer/dist/schema/index.js (index.ts:2:1)
    at __require2 (chunk-IJ7IQSKN.js?v=131fbf65:19:50)
    at node_modules/json-schema-yup-transformer/dist/yup/addMethods/array.js (array.ts:9:1)
    at __require2 (chunk-IJ7IQSKN.js?v=131fbf65:19:50)
    at node_modules/json-schema-yup-transformer/dist/yup/addMethods/index.js (index.ts:2:1)
    at __require2 (chunk-IJ7IQSKN.js?v=131fbf65:19:50)
    at node_modules/json-schema-yup-transformer/dist/yup/builder/index.js (index.ts:6:1)
    at __require2 (chunk-IJ7IQSKN.js?v=131fbf65:19:50)

Works ok with 1.6.7

@leonbloy just published a new version (1.6.10) addressing the cyclical dependencies. Please let me know if there are still issues.

Just tested this on 1.6.10 and it works in my setup! Thanks for fixing!