You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, June 28th 2019, 2:21pm

krpano.js error in strict-mode via webpack

Dear krpano Team,
I tried to include the krpano.js via webpack, but it is throwing an error due to the automatically introduced strict-mode:
"TypeError: Cannot set property length of [object Object] which has only a getter"

Due to the heavy obfuscation of the js I don't wont to spend the time for reverse engeneering, but would love to see this fixed in one of the next versions of the file.

Nowadays it is generally concidered good practise to have your code run in strict mode and it is supposed to also help performance: https://stackoverflow.com/questions/1335…oning-behind-it
It would be also cool (but not nesessary), if the code could be wrapped a bit, so that it can be included using modern commonJs tools like webpack but still would work backwards compatible as standalone browser include:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(function (root, factory) {
  // https://github.com/umdjs/umd/blob/master/returnExports.js
  if (typeof module === 'object' && module.exports) {
    // Node & commonJs
    module.exports = factory();
  } else if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define([], factory);
  } else {
    // Browser globals (root is window) - fallback for direct script includes
    root.embedpano = factory();
  }
}(this, function() {  
  // current code

  return currentEmbedpanoFunction
}));


I'm happy to contribute a PR, but I guess you'll not want that ;)

Best wishes
Andreas