-
Notifications
You must be signed in to change notification settings - Fork 98
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
ReferenceError: g is not defined #127
Comments
Could this be related to #96? You are correct in that the code is fully generated. |
Yes, it looks like it's the same problem. I'm also using it inside an angular project so strict mode is on. |
As explained in #96, I'm not aware of a "fix" other than excluding elkjs from being handled in strict mode. I'm open for suggestions though. |
Removing strict mode will resolve the issue - depending on what build system you use it might add it automatically. For example, rollup does but u can turn this off like:
|
Browser are strict by default these days, and there's no way to run in non-strict mode. Why that affects execution times is very strange, though. At any rate, there's a missing variable in the declared This is not the only instance - we had to fix about four or five different instances of this in order to get it to run. This is preventing us from using Elk without vendoring it in and manually adjusting things. I'll have to fork and see if I can't get it building myself :/ |
I wrote a patcher for the build process - the repository is at my https://github.com/qix-/elkjs fork. This fixes the broken GWT output (maybe not completely - you'll need to add to I also removed all of the extra layout algorithms as an additional, singular commit. This cut down the output size by almost a megabyte. If you need anything other than If you intend to publish on your own, revert the HEAD commit as well and make whatever changes you need to the package.json yourself. Hope that helps anyone that comes across this bug that nobody (neither the ElkJS nor GWT team) wants to fix. |
I agree. If somebody finds the root cause, is able to address it within GWT and triggers a new release of GWT, I'd the first to create a new elkjs release. Injecting the missing variables as a patch after the actual build seems to be a reasonable workaround to me. Would you be open to create a PR with just this change? Regarding removing the other layouters: they may be "superfluous" to you but not in general. #6 also mentions the size differences. If somebody has a suggestion for a low-effort or automated process to publish variants (for instance, |
Yes of course, I didn't mean to suggest they were superfluous in general, just to my use-case - hence why I gave instructions on how to revert that change if someone wanted to use my version. I will PR in a bit. |
I just realized that a better place to add the missing variables is likely below here
|
Should be fixed in 0.7.3-dev. |
@uruuru do you plan to release 0.7.3 as a full version? |
There are plans for a new elk release within the next month. A subsequent elkjs release would include the fixes. |
Any solutions yet? |
@luanlucho elkjs 0.8.1 is released (but not yet tagged as latest), have you tried whether this fixes the issue? |
elkjs 0.8.1 fixes this issue for me |
Thanks for fixing this uruuru! If you enable donations or sponsorships on GitHub people might be interested! |
Just pointing out that |
I have building by vite, elkjs 0.8.1 is not work for me, I resolved it tricky by EDIT: |
The dist-tag is Maintainers, mind pushing this straight to Everyone else, use |
I get the following error:
This issue is caused by the elk-worker.min.js file. the elk-worker.min.js:formatted has the following code:
It uses the var g, however, g is not being defined as var. It can be fixed manually by adding g to the var declarations, like this.
I would normally create a pull request, however as far as I can tell the elk-worker gets generated from the GWT code and I have no idea how this issue can be solved.
The text was updated successfully, but these errors were encountered: