Closed eonarheim closed 9 months ago
Perhaps this useful insight: I ran into instanceof
not working properly when npm linking @excaliburjs/plugin-tiled
to my project. This caused the tilemap to not render anything at all, exactly like #344. The problem ended up being multiple excalibur installs in node_modules
, rather than anything with minification. This is a common problem with linking, as you might be linking to a project with its devDependencies installed (as was the case for me with @excaliburjs/plugin-tiled
), but it could also happen if there are different versions of excalibur installed too.
Since I was using Vite, the solution was to configure a dedupe, ensuring only 1 instance was bundled in my project.
React does some magic to detect possible multiple installs of itself, perhaps there's something to learn from there to do the same? This is the error it throws, though I'm not sure how it gets to throwing it.
This issue hasn't had any recent activity lately and is being marked as stale automatically.
I think we got to the bottom of this, instanceof
is okay as long as you have the right peerDependency setup and vite has dedup enabled
Steps to Reproduce
Using
instanceof
internally in Excalibur has been a source of bugs depending on the bundle/minifier. Vite and Angular appear to need additional configuration to work around their default minification settings so they preserve constructor names.See
Expected Result
Excalibur should be resilient to build tool minification steps. At minimum there should be a warning logged with documentation linked when an
instanceof
check fails.Actual Result
Excalibur silently fails and users are mystified to what is wrong.
Environment
Current Workaround
Update used bundler configuration to preserve names