playcanvas / editor

Issue tracker for the PlayCanvas Editor
https://playcanvas.com/
160 stars 28 forks source link

Concatenation issue #1133

Closed LeXXik closed 1 month ago

LeXXik commented 7 months ago

Creating worker fails, when Launcher is started with "Concatenate Scripts" option:

image

Related forum: https://forum.playcanvas.com/t/new-worker-causing-build-fail/35411 Repro: https://playcanvas.com/project/1204252/overview/concatenation-issue

leonidaspir commented 7 months ago

I think that works as expected given all preloaded scripts will be included in the concatenated script file.

Does setting preload = false to the worker script fix this? That's the proposed way to treat worker script files on production builds too. There is rarely a reason to preload worker scripts since the worker will request the files separately.

LeXXik commented 7 months ago

Yes, it works correctly without concatenation. In our production builds, we download non-concatenated build and concatenate/minify it ourselves, so we have a control over what is concatenated.

Still could be useful in Launcher, when the project has many scripts, as loading is much faster with concatenated option in that case. Perhaps a boolean property could be added to script asset to be excluded from concatenation.

Edit: Leonidas, your suggestion on the forums is a good one, so adding here for record - the workaround would be to set the worker script preload to false.

marklundin commented 1 month ago

The concatenate flag will inline this, which will always be a problem when creating workers. You can probably get around this using URL.createObjectURL with inline workers etc. Closing for now