Pannellum: CommonJS vs ES6 Modules

Created on 16 Aug 2018  路  5Comments  路  Source: mpetroff/pannellum

Currently I believe there is either no module system, or a CommonJS module system which I believe is now less favored than the ES6 module approach.

I am attempting to include the pannellum package using require and npm.

var pannellum = require('pannellum'); console.log(pannellum);

which prints {} an empty object.

I get the following editor message in Virtual Studio Code

[ts] File is a CommonJS module; it may be converted to an ES6 module.

Is there a way this can be supported? I believe it would be very useful to developers.

question

Most helpful comment

Module support is important to me, just my two cents. Thank you for your work on this plugin

All 5 comments

It's not a module; it's designed to be directly loaded with a <script> tag. It's on NPM as a convenience for those who don't want to directly include the library files in their repository / use a CDN. I'm also not yet ready to break ES5 compatibility.

@mpetroff Do you mean that you cannot import pannellum as a module?

import 'pannellum/build/pannellum.css'
import pannellum from 'pannellum/build/pannellum.js'

It doesn't export anything, so I assume one can't import it as a module (although I've never tried).

Too bad https://github.com/mpetroff/pannellum/pull/633 was never merged because it covered various improvements that could be beneficial for this library. Overall this was a pretty sweet PR that would make the library work with React, Vue.js

Module support is important to me, just my two cents. Thank you for your work on this plugin

Was this page helpful?
0 / 5 - 0 ratings