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

2

Tuesday, March 8th 2022, 4:48pm

I know this is a really old thread, but was there ever a resolution to this? I'm hitting the exact same issue.

Source code

1
Uncaught (in promise) TypeError: Cannot set property length of [object Object] which has only a getter    at krpano.js:219:1  at Object.embedpano (krpano.js:227:10) at gt (krpano.js:127:91) at yt (krpano.js:127:243) at d (krpano.js:168:1) at Object.embedpano (krpano.js:169:4)


Using Typescript and Webpack.

3

Tuesday, March 8th 2022, 8:27pm

Hi,

due the 'dynamics' of the actions/object system using the strict mode is not possible. Some very important Javascript features are otherwise not available. That's intentional and not a bug and will not change.

Generally strict mode should be always applied only to your own code and functions, never to third party stuff.

Best regards,
Klaus