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

Unable to build with Webpack after importing Mediapipe (Module parse failed: Unexpected token) #5296

Open
maxwellmooney13 opened this issue Apr 5, 2024 · 6 comments
Assignees
Labels
os:windows MediaPipe issues on Windows platform:javascript MediaPipe Javascript issues stat:awaiting googler Waiting for Google Engineer's Response task::all All tasks of MediaPipe type:build/install For Build and Installation issues

Comments

@maxwellmooney13
Copy link

OS Platform and Distribution

Windows 11

Compiler version

No response

Programming Language and version

TypeScript 5.4.3

Installed using virtualenv? pip? Conda?(if python)

No response

MediaPipe version

0.10.12

Bazel version

No response

XCode and Tulsi versions (if iOS)

No response

Android SDK and NDK versions (if android)

No response

Android AAR (if android)

None

OpenCV version (if running on desktop)

No response

Describe the problem

We are trying to leverage the mediapipe library in our application. No issues when installing mediapipe, no issues when importing various values from mediapipe and using it in a file, no issues importing that file to a different file, but things go south when calling a function from that file. We have a number of build scripts for this project one of which uses Webpack (version 5.91.0). When running the Webpack related script we end up with a failed build that states Module parse failed: Unexpected token from the vision_bundle.mjs file from mediapipe pointing to 855:53. I've seen a few other posts online where someone ran into the same issue (not with mediapipe but in general) but their solutions do not work for me. Wondering if this was seen before or if there is a concrete solution for this. Thank you in advance and I apologize if this is the wrong issue type.

Complete Logs

ERROR in ./node_modules/@mediapipe/tasks-vision/vision_bundle.mjs 855:53
Module parse failed: Unexpected token (855:53)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     var _context10;
|     const e = [],
>       n = _entriesInstanceProperty(_context10 = super).call(_context10);
|     for (var r; !(r = n.next()).done;) (r = r.value)[0] = t(r[0]), r[1] = t(r[1]), e.push(r);
|     return e;
 @ ./src/media/vbg-utils.ts 2:0-74 33:28-58 34:25-57
 @ ./src/sessions/video-session-handler.ts 18:0-53 543:4-19
 @ ./src/index.ts 8:0-49 8:0-49

webpack 5.91.0 compiled with 1 error and 3 warnings in 10121 ms
@maxwellmooney13 maxwellmooney13 added the type:build/install For Build and Installation issues label Apr 5, 2024
@maxwellmooney13
Copy link
Author

I also tried using require(...) rather than import so it will use commonjs rather than the ESModule but the issue persists.

@kuaashish kuaashish assigned kuaashish and unassigned ayushgdev Apr 8, 2024
@kuaashish kuaashish added os:windows MediaPipe issues on Windows platform:javascript MediaPipe Javascript issues task::all All tasks of MediaPipe labels Apr 8, 2024
@kuaashish
Copy link
Collaborator

Hi @maxwellmooney13,

Could you kindly provide us steps you are following from our documentation? This information will help us to understand the issue better and reproduce it if required.

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Apr 16, 2024
@maxwellmooney13
Copy link
Author

Hi @kuaashish !

I installed the dependency @mediapipe/tasks-vision to my project in order to help with image segmentation. After that I had a file that imports FilesetResolver and ImageSegmenter from the above dependency. From there I used those imports in different ways in that same file. From the mentioned file, I exported a function to be used elsewhere. We still won't have the build issue by this point however once we import the function elsewhere and call it, we will get the issue when attempting to build using Webpack. Hopefully that helps! Let me know if I can provide more information

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting for user response label Apr 16, 2024
@schmidt-sebastian
Copy link
Collaborator

Are you able to force Webpack to use the .cjs files (instead of .mjs)?

@maxwellmooney13
Copy link
Author

Hi @schmidt-sebastian

I did try that as well I believe and I got the same result

@kuaashish kuaashish added the stat:awaiting googler Waiting for Google Engineer's Response label Apr 19, 2024
@maxwellmooney13
Copy link
Author

Hi all, just bumping this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:windows MediaPipe issues on Windows platform:javascript MediaPipe Javascript issues stat:awaiting googler Waiting for Google Engineer's Response task::all All tasks of MediaPipe type:build/install For Build and Installation issues
Projects
None yet
Development

No branches or pull requests

4 participants