Skip to content

Bug: @motionone/solid causing an error #7575

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

Closed
danilowoz opened this issue Apr 17, 2023 · 10 comments · Fixed by #7613
Closed

Bug: @motionone/solid causing an error #7575

danilowoz opened this issue Apr 17, 2023 · 10 comments · Fixed by #7613

Comments

@danilowoz
Copy link
Contributor

🐛 bug report

Solid.js templates using @motionone/solid is throwing an error when trying to load it. Currently, this template has been used on motion.dev documentation, which is failing due to the following error:

Screenshot 2023-04-17 at 14 28 38

Debugging

I can see that this error is coming from a @motionone/solid. However, I couldn't find the _standard function on the original source code, so I guess it's an issue on our evaluation function, which is not including that function.

Screenshot 2023-04-17 at 14 25 07

Screenshot 2023-04-17 at 14 26 30

Link to sandbox: link (optional)

You can run it here: https://codesandbox.io/s/sandpack-project-forked-ovjfhc?file=/package.json:132-148

@danilowoz
Copy link
Contributor Author

@DeMoorJasper, by any chance, do you know what's going on here?

@DeMoorJasper
Copy link
Member

Strange, also don't find any reference to _standard, seems like some babel stuff is failing to load at first look, but will dig deeper into it later today

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 3, 2023

Seems related to a bug in solid-refresh on all versions below 0.5.0, will try and update our solid-refresh version. But new solid-refresh version seems incompatible with our babel version, will figure it out though

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 4, 2023

Seems like the latest version has another issue _$$component is not defined created a repro to be sent to the solid-refresh team I guess: https://github.com/DeMoorJasper/solid-refresh-bug

For now I'll work around it by filtering out refresh plugins for node modules

@danilowoz
Copy link
Contributor Author

Hey, @davedbase. We encountered a bug on solid-refresh, which can be reproduced on the repo mentioned above.
What's the best way to address this issue?

Thanks

@lxsmnsyc
Copy link

@danilowoz Hi, I'm the one working on solid-refresh. May I ask what bundler setup are you using?

@danilowoz
Copy link
Contributor Author

Maybe @DeMoorJasper can clarify our current bundler setup

@davedbase
Copy link

Hi folks, we're getting a lot of flack from the broader Solid ecosystem on this topic. It's really hampering the perspective of Solid as a maintained ecosystem. I'm really apologetic to ask once again but we could really use support to solve this.

Thank you.

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 30, 2023

@davedbase there's a repro in this thread that reproduces it consistently even locally, let me know if you need any more help

Seems like the latest version has another issue _$$component is not defined created a repro to be sent to the solid-refresh team I guess: https://github.com/DeMoorJasper/solid-refresh-bug

For now I'll work around it by filtering out refresh plugins for node modules

@lxsmnsyc
Copy link

lxsmnsyc commented Jul 7, 2023

Hmm Okay I revisited this again. The specific babel setup is kinda wonky.

There are parts where it works as intended (the automatic import for the $$refresh) while there are parts that doesn't get translated properly ($$component). I don't know why this happens, but removing the preset-env and commonjs module transform has the correct output.

edit:
after some playing with the repro, I had this output:

var Presence = (0, _solidRefresh.$$component)(_REGISTRY, "Presence", function (props) {
// ...
var MotionComponent = _$$component(_REGISTRY, "MotionComponent", function (props) {

I can safely say that this is either a preset bug or a bug in Babel itself. Either way, I would recommend not using preset-env/transform-commonjs-modules and use other transpiling tool instead (maybe ESBuild)

edit 2:
Even the minimal code is kinda correct:

// Input
function Example() {

}
"use strict";

var _solidRefresh = require("solid-refresh");
var _REGISTRY = (0, _solidRefresh.$$registry)();
var Example = (0, _solidRefresh.$$component)(_REGISTRY, "Example", function Example() {}, {
 location: "index.js:1:0"
});
if (module.hot) {
 (0, _solidRefresh.$$refresh)("standard", module.hot, _REGISTRY);
}

Afterwards it just fails when there's multiple components defined:

// Input
function Foo() {

}
function Bar() {
  
}
function Baz() {
  
}
"use strict";

var _solidRefresh = require("solid-refresh");
var _REGISTRY = (0, _solidRefresh.$$registry)();
var Foo = (0, _solidRefresh.$$component)(_REGISTRY, "Foo", function Foo() {}, {
  location: "index.js:1:0"
});
var Bar = _$$component(_REGISTRY, "Bar", function Bar() {}, {
  location: "index.js:4:0"
});
var Baz = _$$component(_REGISTRY, "Baz", function Baz() {}, {
  location: "index.js:7:0"
});
if (module.hot) {
  (0, _solidRefresh.$$refresh)("standard", module.hot, _REGISTRY);
}

Take note that I've tried fixing this in the plugin myself but to no avail. I'm convinced that the preset-env/transform-modules-commonjs is the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants