Coder Social home page Coder Social logo

Comments (14)

Driptap avatar Driptap commented on May 28, 2024 3

I had this problem too, building v3.0.6 with the previously used version of pdfjs-dist works (2.0.203). I'm guessing there is some problem with that.

from react-pdf-js.

Driptap avatar Driptap commented on May 28, 2024

Ok no - it's a peer dependencies.
Make sure you have the correct pdfjs-dist version in your package.json:

"pdfjs-dist": "2.0.303", "react-pdf-js": "3.0.6",

from react-pdf-js.

romax94 avatar romax94 commented on May 28, 2024

@Driptap issue still persist
package json - web - visual studio code
sell my car - tootle - google chrome

from react-pdf-js.

Driptap avatar Driptap commented on May 28, 2024

Try manually deleting the react-pdf-js & pdfjs-dist folders from node modules, then installing the correct versions from the command line:

I left the caret in by mistake on the previous comment, it still grabs latest version of pdfjs-dist

from react-pdf-js.

mikecousins avatar mikecousins commented on May 28, 2024

I'd remove the pdfjs-dist from your package.config and let this package handle it.

from react-pdf-js.

romax94 avatar romax94 commented on May 28, 2024

@Driptap Thanks.

from react-pdf-js.

sebastianmenge avatar sebastianmenge commented on May 28, 2024

What is the solution for the problem now? When letting react-pdf-js handle it, thats exactly when i'm getting the error and i can't ged rid of it.

from react-pdf-js.

Driptap avatar Driptap commented on May 28, 2024

Letting the package handle it seems to results in a newer version of pdfjs-dist (2.0.328) to be installed - this seems to be causing the Module Not Found error.

@sebastianmenge For now you should be able to install the correct version by adding "pdfjs-dist": "2.0.303" to your package.json, removing pdfjs-dist from node_modules and reinstalling.

@mikecousins maybe it is worth specifying the exact version of pdfjs-dist in react-pdf-js's package.json?

from react-pdf-js.

sebastianmenge avatar sebastianmenge commented on May 28, 2024

thanks @Driptap for clearing it up. i was just confused by the answer and thought the way to go would be not putting the pdfjs-dist in the package. working now.

from react-pdf-js.

romax94 avatar romax94 commented on May 28, 2024

@mikecousins When there will be release with corrected bugs?

from react-pdf-js.

netpoetica avatar netpoetica commented on May 28, 2024

Currently, in my project I had to add

    "pdfjs-dist": "2.0.139",
    "react-pdf-js": "3.0.0",

to this specific version of pdfjs-dist. It appears that the newer version of pdfjs-dist is missing pdf.combined JS file, which even the master branch of this repo depends on still.

Which, is probably a good thing, because that file (old version) injects an override of Object.defineProperty which does not work as expected: https://raw.githubusercontent.com/mozilla/pdfjs-dist/846bbae9bcb9ce06ca3d04da9e99beecb9900e82/build/pdf.combined.js

Object.defineProperty = function objectDefineProperty(obj, name, def) {
      delete obj[name];
      if ('get' in def) {
        obj.__defineGetter__(name, def['get']);
      }
      if ('set' in def) {
        obj.__defineSetter__(name, def['set']);
      }
      if ('value' in def) {
        obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
          this.__defineGetter__(name, function objectDefinePropertyGetter() {
            return value;
          });
          return value;
        });
        obj[name] = def.value;
      }
    };

This library should use the non "combined" version of this file, no?

from react-pdf-js.

netpoetica avatar netpoetica commented on May 28, 2024

@Driptap I can confirm that the Object.definePropert tomfoolery is removed in this version of pdfjs-dist (https://raw.githubusercontent.com/mozilla/pdfjs-dist/d90724150fdff57ba76c25e2f3167d12105ba2a1/build/pdf.combined.js, find "defineProperty =" missing). However, if I have dependencies

  "dependencies": {
    "pdfjs-dist": "2.0.303",
    "react-pdf-js": "3.0.6"
  },

I still end up with the new version of pdfjs-dist, which is incompatible, in the local node_modules/ of react-pdf-js


➜  myproj git:(master) ✗ npm list pdfjs-dist
[email protected] /Users/rosenbek/myproj
├── [email protected] 
└─┬ [email protected]
  └── [email protected] 

and version 2.0.332 is missing pdf.combined.js.

The PR above should fix this problem because it is in the dependencies of react-pdf-js that this issue arises (https://github.com/mikecousins/react-pdf-js/pull/62/files), however, it still stands that isn't it a bad idea to use the pdf.combined.js file? It seems like so much bloat is in there? And like I said, that polyfill/hijacking of Object.defineProperty seems to behave differently from native Object.defineProperty.

from react-pdf-js.

mikecousins avatar mikecousins commented on May 28, 2024

I have merged and released the change to hardcode the version to the old one.

I like this talk about switching away from pdf.combined but I'm unsure of the ramifications of it.

from react-pdf-js.

MichaelDeBoey avatar MichaelDeBoey commented on May 28, 2024

@mikecousins We should indeed get rid of the pdf.combined 🙂
Since the provided polyfills won't be included anymore, that would be a major version bump.

from react-pdf-js.

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.