TeselaGen / tg-oss

Teselagen Open Source modules
https://teselagen.github.io/tg-oss/
MIT License
37 stars 18 forks source link

Unexpected token (40059:10) in @teselagen/ui/index.es.js #42

Closed nicolazilio closed 9 months ago

nicolazilio commented 9 months ago

Hello @tnrich,

I've been trying to merge your latest changes to the OVE demo into my fork https://github.com/helle-ulrich-lab/ove-plasmid-viewer but when I try to build the app, I get the following error

[commonjs--resolver] Unexpected token (40059:10) in /home/xxx/dev_ove/node_modules/@teselagen/ui/index.es.js
file: /home/xxx/dev_ove/node_modules/@teselagen/ui/index.es.js:40059:10
40057:         return __spreadValues({
40058:           key: id2,
40059:           {}: props.global !== false,
                 ^
40060:           onKeyDown: function(e2) {
40061:             return handlers2[id2](e2);

Any ideas why?

Thanks in advance!

tnrich commented 9 months ago

Hi @nicolazilio I'm not sure what might be causing that.. I can look into it real quick

tnrich commented 9 months ago

Hi @nicolazilio this is basically being caused by a difference in how vite/webpack handle the polyfilling of the global object. I had tried to work around vite NOT adding the global polyfill by adding this line in the vite config:

image

However it looks like that is causing issues elsewhere because blueprintjs uses global as a local variable name:

image

The vite config adds the empty object there {} and we get an error. I'm going to try to fix this by shimming the global object as per this answer: https://stackoverflow.com/a/73208485/2178112

I'll let you know when I publish a new version.

tnrich commented 9 months ago

@nicolazilio it appears that you'll need to add that shim for the global object yourself to your project. You can see how I do it here:

https://github.com/tnrich/ove-react-demo-repo

nicolazilio commented 9 months ago

Worked like a charm, thanks!