fix(ui|git-changelog): missing configurations for @rive-app/canvas #131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summaries and troubleshooting steps
When I was working on #124, I found out that the
@rive-app/canvas
break the other components then came up the temporarily fix at #128. However, the issue didn't went off, after fixing issues withfast-glob
, I noticed that the CJS / UMD limitations for@rive-app/canvas
where I may have a solution to fix.According to
@rive-app/canvas
's documentation, developers should use the package like this:However, the error will appear as follow or either as what users had described in #124:
This seems weird for me, because
@rive-app/canvas
didn't cause any problems at the very first time I introduce it into Nolebase Integration, it worked really well. The error / issue would only appear when importing as dependency of dependency (for example wrapped the@rive-app/canvas
into a component and then install the component into other packages or projects).I went to search for some advices and suggestions about how the similar issue could get resolved:
After reading those issues, I noticed that the API / export mode has changed to named exports:
I tried to use the named exports. But error remained:
It may even produce errors like this when building:
I thought there may be a delay of the changes to package, I switch back to
default
exports:The error / issue remained still! And even changed every time I change the solution to import it:
At this time, I carefully opened the
node_modules
to find out why, and saw that the@rive-app/canvas
contains no ESM module as exports, with a.d.mjs
as definiations.Until now, I still didn't realize what caused the issue, I thought there might be an issue about SSR, so I changed to dynamic import:
But the issue still remained:
I went to check the code that throwed the error:
and added breakpoints to inspect the scoped values, found that the
root
itself is truely undefined:From this time, I realized that might be issues about interpolation with
esbuild
that used by Vite:I went to search again to find out more, and finally understand the limitations, scope difference between UMD and ESM. I tried to override the
this
totypeof window !== "undefined" ? window : this
:Then the imported module became this:
At the end, I went to read how the CJS interpolation works for Dep Optimization Options | Vite, eventually understood the needed and requirements for nested CJS modules: