Using ES Modules in krpano plugin

  • More and more libraries are using modules to organise the code. it uses import statement to include the functionality inside javascript.

    I have been trying to use such packages inside krpano javascript plugin, but I have not been able to do so using various approaches.

    Attempt 1: Using the import statement inside the plugin

    Fails as krpano throws a parsing error on import statements:

    Code
    ERROR: parsing './plugins/plugin.js' failed:SyntaxError: unexpected garbage after function body, starting with 'from'

    Attempt 2: declaring the modules in the main page or seperate .js

    Fails with: Uncaught ReferenceError: <module_name> is not defined.


    Anybody any tips on how to mix (krpano plugin) javascript with ES modules?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!