jonataswalker/ol-contextmenu

Module parse failed: Unexpected token (93:67)

NilSilva opened this issue · 10 comments

After updating to 5.0.0 when i build using webpack i get the following error:

ERROR in ./node_modules/ol-contextmenu/dist/ol-contextmenu.js 93:67
Module parse failed: Unexpected token (93:67)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| t.style.cssText = 'position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px';
| const n = E("Foo"), i = E("Foo"), o = document.createElement("li"), l = document.createElement("li");

o.append(n), l.append(i), t.append(o), t.append(l), s.parentNode?.append(t);
| const u = t.offsetHeight / 2;
| return s.parentNode?.removeChild(t), u;
@ ./src/main/webapp/core/js/Controls/ContextMenu/ContextMenu.ts 2:0-41 12:48-59
@ ./src/main/webapp/core/js/Instance/Instance.ts
@ ./src/main/webapp/outdoor/js/Instance/OutdoorInstance.ts
@ ./src/main/webapp/core/js/Init.ts

Not sure how to handle/help.

As far as I know in the examples folder there is a working app using vite.

Are you able to provide a fix?

I don't know how to fix this... I has hoping someone here would and that it would be fixed with either a configuration on my side or a quick patch in the package... I'm going to look into the example see if i can figure something out.

I'm getting the same error. Using vue and trying to:
import ContextMenu from 'ol-contextmenu'
Don't know how to fix it

I'm getting the same error. Using vue and trying to: import ContextMenu from 'ol-contextmenu' Don't know how to fix it

Are you using webpack? I think the problem might be there... Or at least it might be the solution. I haven't figured out how yet.

Yes I'm using webpack. I'm trying to find a solution..

Can any of you provide a minimal repro?

I can try to help.

Just pushed (and published 5.1.0) an example with webpack.

Had to add this to webpack.config.js:

  externals: {
    "ol/control/Control": "ol.control.Control",
  },

I tried that and it still has the error it's on a different file now but it's still there...
image
I'm thinking maybe it's the webpack version I'm using 4.46.0. I'm going to try to update webpack.

Hey @NilSilva

Can we close this issue?

Sorry for the late reply... Other things have taken priority in the project, but I was still having this when i last tried it. I guess you can close it for now since it is working, and my problem is probably something wrong in the configuration.