Require js still not working

Forums Classic DFFS Require js still not working

Viewing 3 reply threads
  • Author
    Posts
    • #17315
      Eike Ahmels
      Participant

      Hello Alexander,

      your require.js solutions isnt working proper. We are facing problems:
      1. if a file has 2 dots in it (“pdf.worker.js”) and (“pdf.js”) require js loads the non-AMD module “pdf” twice
      2. i changed the name of the file to pdf_worker, which loads it, but the global variable PDFJS is not present.

      i saw you configured the shim config so that it always says true (exports: “spjs”), the exports options is there to check if the file registered the object correct.

      I made a solution that worked great, i will send it to you later the day, so you can see what i did different.

      Regards
      Eike Ahmels

    • #17319
      Alexander Bautz
      Keymaster

      Thanks for the feedback. Yes, I used the shim config to try to support non-amd modules loading also and wanted to make a “universal” support without the need to supply the module name and export manually – and to try to make it backwards compatible when upgrading from an older version of DFFS.

      I’m not really friends with require.js right now so I hope your code will help me get it right.

      Alexander

    • #17321
      Eike Ahmels
      Participant

      I fixed it like 2 seconds after i made the post.

      You are loading non-AMD js correct. The main problem was the pdf.js, it got changed to a AMD js and is registering itself but removes the global PDFJS variable.
      Thats why i cant get it to work. I got it to work with require([“module”], …) stuff. I tried that before, but i missed the correct module name, which i found out now.

      Regards
      Eike Ahmels

    • #17323
      Eike Ahmels
      Participant

      I am sorry, i thought pdf.js is non-AMD, but they changed it and notified nobody realy well…

      I am not good with require.js neither, i realy dont like it atm, not because its bad (i guess its good), but because we are forced to use it on SPO without any notification as well.

      Your code is good, i added a little, to make it more consistent and i added a option to define a exports variable for the shim config.

      And you need to change a little, so that double dots (or more dots) wont affect files like pdf.worker.js and pdf.js, where only pdf.js gets loaded, because it overrides pdf.worker.js, which gets registered as “pdf” in the shim config.

      I guess you dont need my code, its a little messy, because we needed a quick fix, and your solution is more clean and works as great as mine did.

      Regards
      Eike Ahmels

Viewing 3 reply threads
  • You must be logged in to reply to this topic.