Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.4.4 || Uncaught ReferenceError: jsVectorMap is not defined #69

Closed
Mgrmjp opened this issue Feb 15, 2022 · 8 comments
Closed

Comments

@Mgrmjp
Copy link

Mgrmjp commented Feb 15, 2022

Barebones project and trying to use the package. Getting this in console:

Uncaught ReferenceError: jsVectorMap is not defined
    at Object.3r67O ((index):2496:1)
    at newRequire ((index):89:24)
    at localRequire ((index):101:14)
    at Object.5HwUs.lodash/range ((index):490:16)
    at newRequire ((index):89:24)
    at localRequire ((index):101:14)
    at Object.fUiC5../app.js ((index):480:14)
    at newRequire ((index):89:24)
    at (index):138:5
    at (index):161:3

3r67O @ (index):2496
newRequire @ (index):89
localRequire @ (index):101
5HwUs.lodash/range @ (index):490
newRequire @ (index):89
localRequire @ (index):101
fUiC5../app.js @ (index):480
newRequire @ (index):89
(anonymous) @ (index):138
(anonymous) @ (index):161

Downgrading to 1.3.3 worked, but what might be the problem?

Importing like so:

import 'jsvectormap';
import 'jsvectormap/dist/maps/world.js';

const map = new jsVectorMap({
  selector: '#map',
  map: 'world',
});

Installed via npm. Node version 14.19.0.

themustafaomar added a commit that referenced this issue Feb 16, 2022
@themustafaomar
Copy link
Owner

Hi @Mgrmjp

There's was a typo in the documentation website and readme file about import statement, sorry for that.

It's fixed now, you can import like so:

import jsVectorMap from 'jsvectormap'
import 'jsvectormap/dist/maps/world.js'

const map = new jsVectorMap({
  selector: '#map',
  map: 'world',
})

@Mgrmjp
Copy link
Author

Mgrmjp commented Feb 16, 2022

Still doing the same even after changing the import. 😢

@themustafaomar themustafaomar pinned this issue Feb 17, 2022
@themustafaomar
Copy link
Owner

themustafaomar commented Feb 17, 2022

Thank you for letting me know about this issue!

It looks like it's failing, starting from v1.4.0 when using ESM or CJS modules, but it works just fine on HTML files.

As a temporary workaround you can do so:

import jsVectorMap from "jsvectormap"

window.jsVectorMap = jsVectorMap

import "jsvectormap/dist/maps/world-merc"

const map = new jsVectorMap({
  selector: "#map",
  map: "world_merc"
})

@Mgrmjp
Copy link
Author

Mgrmjp commented Feb 18, 2022

That didn't seem to help either. 😂

Maybe it's something on my end. 🤷🏻‍♂️

@themustafaomar
Copy link
Owner

🤷🏻‍♂️

https://codesandbox.io/s/jvm-temp-workaround-iqp6rj

@rushenn
Copy link

rushenn commented Feb 21, 2022

🤷🏻‍♂️

https://codesandbox.io/s/jvm-temp-workaround-iqp6rj

Try to change the jsvectormap version to 1.4.4, the issue is still present.

@themustafaomar
Copy link
Owner

@rushenn Gonna publish a new version today which fixes the issue.

@themustafaomar
Copy link
Owner

Please update to v1.4.5 https://iqp6rj.csb.app/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants