OHIF / Viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages
https://docs.ohif.org/
MIT License
2.98k stars 3.12k forks source link

[Bug] Build bug with production for deployment (Either maybe babel or Webpack issue variable obfuscation) #4245

Closed Joeycho closed 1 week ago

Joeycho commented 1 week ago

Describe the Bug

Screenshot 2024-06-20 at 22 20 09 You'll get this error if following the steps I described (standard way from docs). If I miss any step, please let me know.

I have debugged by myself for a couple of days, and I recognized that some variables are accessed incorrectly. But I understand why Babel or Webpack is confused (This is my current guess.. where the issue is..).

This bug does not happen only for Texture.js. There are other files as well in @kitware/vtk.js.

I have tried turning off all mangling.. minimize.. but, I cannot find a way to fix it. As you can see in the below image, "B" and "dJ" are already inserted. I think Both.. "B" and "dJ" should be gone..

Screenshot 2024-06-20 at 22 41 10

Steps to Reproduce

  1. Clone the current Viewer master branch
  2. # Enable Yarn Workspaces
    yarn config set workspaces-experimental true
    # Restore dependencies
    yarn install
  3. yarn build: Production build. This will lead dist folder under platform/app.
  4. 
    # Install http-server as a globally available package
    yarn global add http-server

Change the directory to the platform/app

Serve the files in our current directory

npx serve ./dist -c ../public/serve.json


5. Go to [localhost:3000](url)
6. Check the console in developer mode

https://github.com/OHIF/Viewers/blob/master/platform/docs/docs/deployment/build-for-production.md

### The current behavior

[
![Screenshot 2024-06-20 at 22 22 47](https://github.com/OHIF/Viewers/assets/29337166/ace8f430-e68a-48bc-a76d-4001d38d4e7f)
](url)

### The expected behavior

![Screenshot 2024-06-18 at 18 21 10](https://github.com/OHIF/Viewers/assets/29337166/994e0b7b-ac36-4c6c-ac97-5fb3e5bd713e)

### OS

mac OS 14.4

### Node version

18.20.3

### Browser

Chrome 126.0.6478.62
wowczarczyk commented 1 week ago

I am having the same issue

wowczarczyk commented 1 week ago

I checked out tag beta.45 and works flawlessly, my guess it is the babel-loader here:

https://github.com/OHIF/Viewers/commit/88575c6c09fd778a31b2f91524163ce65d1639dd

sedghi commented 1 week ago

yeah we fixed this

Joeycho commented 1 week ago

Hmm.. beta.45 works for you? @wowczarczyk

In my case, Webpack version was critical... "webpack": "5.89.0" https://github.com/OHIF/Viewers/commit/b6136acff6e2d0fb3cf5a28068f519ab9b1e61dd

What do you think @wayfarer3130? Which PR fixes this issue? If downgrade of webpack fixed the issue, then.. did you find some relevant issues or discussion in webpack community? This is a temporary fix, right?

wowczarczyk commented 6 days ago

Yep, beta.45 works fine