Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011

    Using LS within a typescript project

    We've created a react web client in typescript that uses lightstreamer. We wrote our own typings to cover the types we need from LS.

    We have used the AMD module generated from the current downloads page. When using requirejs to import the module at runtime, there's no problem.

    If we instead use create-react-app to scaffold an app then webpack does the bundling and therefore module importing at runtime. At runtime we get an error like the one in this github issue:

    `Uncaught Error: define cannot be used indirect`

    This appears to be caused by the problem mentioned in the comment

    >I've found the issue. Problem is that define is redefined and shadows global.define. If you replace remove var in the source, then it works as expected. I'm not sure webpack can do anything about this.

    >tl;dr: var define is hoisted and shadows global.define which breaks the build.

    Rather than modify the lib to fix this issue and have the bundle work, we now treat LS as a global. This is also the case in the only LS typescript sample app I've seen. Treating LS as a global works, but is non-ideal

    I would like to know whether you have a fix or workaround for this so that LS can be imported as a module.

    And whether you have any upcoming releases that makes LS easier to use in a typescript context, like a web client npm package (although the package lightstreamer-client works in a web context it doesn't have some features) and @types package.


  2. #2

    Unfortunately the global version of the library is the only solution at the moment.
    The support for bundlers such as Webpack may improve in the future but I cannot say the exact date.

  3. #3

    After having discussed your request and similar ones, we have decided to improve the support for Typescript and other modern tools like Webpack and Rollup. We have also decided to open source our client library to widespread its adoption.
    We cannot say an exact date but the Lightstreamer team is committed to deliver such enhancements in the near future.

    Lightstreamer Support
    Last edited by Alessandro Carioni; July 10th, 2019 at 09:16 AM.



Similar Threads

  1. Replies: 1
    Last Post: February 4th, 2010, 06:31 PM
  2. Replies: 3
    Last Post: January 21st, 2010, 01:25 PM
  3. Consuming Web Services within Lightstreamer
    By Isanderthul in forum General
    Replies: 2
    Last Post: August 6th, 2009, 11:10 AM
  4. Demo not working within my framework...
    By athanasius2 in forum General
    Replies: 3
    Last Post: April 17th, 2009, 01:40 PM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
All times are GMT +1. The time now is 11:05 AM.