-
Notifications
You must be signed in to change notification settings - Fork 29
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
chore: fix css-element-queries import #714
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for exploring this issue. This is my fault. I used css-element-queries
over other modern packages in the hope that reusing a HiGlass dependency may make things easier, but it wasn't.
I wonder if we can somehow check similar issues at the early stage in this repo (without needing to deploy/test in gosling-widget
) whenever we add dependencies in the future.
Seriously no worries! It was just tricky to track down what was going on since the original error in Jupyter was so opaque.
Agreed, and unfortunately don't have any solutions off the top of my head. A primary issue is that the feedback loop of making changes to Gosling library and trying the final "build" in different applications is too long (as you've pointed out). It's also important to note that the source code for the Gosling library ( This was part of the motivation for #697, which is still in progress. The idea there is to have true separation of "packages" for Gosling. With a monorepo, we could actually move |
In the meantime, some thoughts to hopefully make us less susceptible to issues like this in the future.
EDIT: It's also worth noting that |
Thanks a lot for summarizing these! I will keep those in mind when adding new dependencies. Also, I think it might be valuable to add these instructions to our contributing guidelines.
This sounds really helpful! |
The
css-element-queries
package is causing real issues ingosling-widget
(and likely and other systems using requirejs).gosling.js
gosling-widget#1It seems to stem from this annonymous
define
inElementQueries.js
.https://github.com/marcj/css-element-queries/blob/4eae4654f4683923153d8dd8f5c0d1bc2067b2a8/src/ElementQueries.js#L10
When importing from
css-element-queries
, theindex.js
file is commonjs with two exports:Commonjs modules cannot be tree-shaken, so all the code for
ResizeSensor
andElementQueries
end up in resulting bundles even though we don't useElementQueries
at all in the code.The error in
gosling-widget
arises as a side-effect./src/ElementQueries.js
inspects the global namespace fordefine
when loaded. We don't see this in the Editor or when loading gosling via a script tag sincedefine
is not provided as a global.I think we can avoid this issue all together with changes suggested in the PR by avoiding the import for
ElementQueries
all together.As a side note, we should be thoughtful when adding new NPM dependencies since how they are packaged can have serious implications on where
gosling.js
can work. I would look for dependencies which are widely used, adhere to modern standards, and frequently updated.