streamich / json-joy

JSON CRDT, JSON CRDT Patch, JSON Patch+, JSON Predicate, JSON Pointer, JSON Expression, JSON Type
https://jsonjoy.com/libs/json-joy-js
Apache License 2.0
741 stars 14 forks source link

Could not resolve "@jsonjoy.com/util/lib/buffers/isUint8Array" #687

Open macmillen opened 1 month ago

macmillen commented 1 month ago

When I try to import json-joy like this:

  import { Model, s } from "json-joy/lib/json-crdt";

I get this error:

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/buffers/isUint8Array"

     node_modules/json-joy/lib/json-crdt-patch/PatchBuilder.js:6:31:
       6 │ const isUint8Array_1 = require("@jsonjoy.com/util/lib/buffers/isUint8Array");
         ╵                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/buffers/isUint8Array" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/buffers/isUint8Array"

     node_modules/json-joy/lib/json-crdt/nodes/rga/AbstractRga.js:5:31:
       5 │ const isUint8Array_1 = require("@jsonjoy.com/util/lib/buffers/isUint8Array");
         ╵                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/buffers/isUint8Array" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/json-pack/lib/cbor/CborDecoder"

     node_modules/json-joy/lib/json-crdt-patch/codec/binary/Decoder.js:7:30:
       7 │ const CborDecoder_1 = require("@jsonjoy.com/json-pack/lib/cbor/CborDecoder");
         ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/json-pack/lib/cbor/CborDecoder" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/buffers/Writer"

     node_modules/json-joy/lib/json-crdt-patch/util/binary/CrdtWriter.js:4:25:
       4 │ const Writer_1 = require("@jsonjoy.com/util/lib/buffers/Writer");
         ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/buffers/Writer" as external to exclude it from the
   bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/json-pack/lib/cbor/CborEncoder"

     node_modules/json-joy/lib/json-crdt/codec/structural/binary/Encoder.js:9:30:
       9 │ const CborEncoder_1 = require("@jsonjoy.com/json-pack/lib/cbor/CborEncoder");
         ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/json-pack/lib/cbor/CborEncoder" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase"

     node_modules/json-joy/lib/json-crdt/codec/structural/binary/Decoder.js:10:34:
       10 │ const CborDecoderBase_1 = require("@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase");
          ╵                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/json-pack/lib/cbor/CborDecoderBase" as external to exclude it
   from the bundle, which will remove this error and leave the unresolved path in the bundle. You can
   also surround this "require" call with a try/catch block to handle this failure at run-time
   instead of bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/json-pack/lib/cbor/CborEncoder"

     node_modules/json-joy/lib/json-crdt-patch/codec/binary/Encoder.js:8:30:
       8 │ const CborEncoder_1 = require("@jsonjoy.com/json-pack/lib/cbor/CborEncoder");
         ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/json-pack/lib/cbor/CborEncoder" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/buffers/Reader"

     node_modules/json-joy/lib/json-crdt-patch/util/binary/CrdtReader.js:4:25:
       4 │ const Reader_1 = require("@jsonjoy.com/util/lib/buffers/Reader");
         ╵                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/buffers/Reader" as external to exclude it from the
   bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/hasOwnProperty"

     node_modules/json-joy/lib/json-pointer/find.js:5:33:
       5 │ const hasOwnProperty_1 = require("@jsonjoy.com/util/lib/hasOwnProperty");
         ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/hasOwnProperty" as external to exclude it from the
   bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/hasOwnProperty"

     node_modules/json-joy/lib/json-pointer/get.js:4:33:
       4 │ const hasOwnProperty_1 = require("@jsonjoy.com/util/lib/hasOwnProperty");
         ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/hasOwnProperty" as external to exclude it from the
   bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/buffers/printOctets"

     node_modules/json-joy/lib/json-crdt/nodes/rga/AbstractRga.js:12:30:
       12 │ const printOctets_1 = require("@jsonjoy.com/util/lib/buffers/printOctets");
          ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/buffers/printOctets" as external to exclude it from
   the bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.

 ✘ [ERROR] Could not resolve "@jsonjoy.com/util/lib/hasOwnProperty"

     node_modules/json-joy/lib/json-pointer/findByPointer/v5.js:5:33:
       5 │ const hasOwnProperty_1 = require("@jsonjoy.com/util/lib/hasOwnProperty");
         ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   You can mark the path "@jsonjoy.com/util/lib/hasOwnProperty" as external to exclude it from the
   bundle, which will remove this error and leave the unresolved path in the bundle. You can also
   surround this "require" call with a try/catch block to handle this failure at run-time instead of
   bundle-time.
macmillen commented 1 month ago

I solved it by installing these peer dependencies:

@jsonjoy.com/base64
@jsonjoy.com/json-pack
@jsonjoy.com/util

This should be noted in the Getting started guide.

streamich commented 1 month ago

Yes, indeed. A number of dependencies have been moved to "peer dependencies" to ensure they are the same version across libraries.