-
Notifications
You must be signed in to change notification settings - Fork 41
Hyperclick breaks when import is inside if (Meteor.isClient) #122
Comments
The js-hyperclick is powered by Babel@7, so if you put a Babel config in your project that can parse Meteor's custom syntax, it will pick it up and work. |
Thanks for the reply and suggestion @AsaAyers For now I've resolved the issue by hacking parse-code.js I'd make a pull request to include the above hack, but I imagine you'd probably prefer to keep your code clean and to spec. I can't invest more time in it right now so a hack is good enough for me for now. I've asked for suggestions here: meteor/babel#30 |
Can it be solved with a dynamic import?
I just searched "Meteor Babel" on npm and found babel-preset-meteor. This could be another option, but personally I'd try to stick with standard JS if possible. |
Hey @AsaAyers... interestingly my webapp (using fourseven:scss) still works if the SCSS is dynamically imported as per your example. Wow, you've just opened up a whole new level of control for me. Because fourseven:scss has always felt a bit hacky and didn't seem to be a very active project I never thought of loading scss dynamically, but it actually works. I just tested loading it in a setTimeout for a dramatic test and it works as expected! (fourseven-scss seems to be better maintained now than the last time I looked and Meteor got acquired by Tiny recently, so it should continue to improve) But the weird part is using fourseven-scss (which is now called meteor-scss) with standard-minifiers bundles ALL resulting css files together. So the concept of loading via dynamic import seems to contradict that architecture. Anyway, tweaking the syntax prevents the parser crash. I'm going to keep my Thanks again!! |
In a Meteor project with fourseven:scss package included
The following 2 file will demonstrate the bug
At first I thought the problem was the .scss
I added this as line 209 of parse-code.js
if (moduleName.indexOf('.scss')>-1) return console.log('Detected .scss import, exiting function');
But then I discovered that js-hyperclick craps out when it sees an import inside an if statement. The parser does not even seem to run.
If you comment out the if statement import, and do the hyperclick hover it underlines React or Component, etc.
If you uncomment the 2nd line, hyperclick breaks and then you can't hover over React or Component anymore, and can't hyperclick anything.
=================
A parseError occurs in parse-code.js Line 105ish
parseError SyntaxError: unknown: 'import' and 'export' may only appear at the top level
Atom 1.47 x86_64 on Linux
hyperclick 0.1.5
js-hyperclick 1.19.0
Meteor 1.10.1
You probably don't need Meteor to test the above.
Suggested quick and simple fix:
Just ignore any import statements that contain .scss on the same line.
The text was updated successfully, but these errors were encountered: