-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fixed relative paths for require.js #387
Conversation
moved the require calls for require.js to be inside the define function so relative paths will work.
Do you have any suggestions for how we could implement tests for this functionality? We keep making modifications but they don't seem to land this area. |
did you have unit tests in mind or a html test page that uses requirejs to load in the html beautifier and beautifies some code ? |
I was hoping that since you have the expertise to fix the bug, you could show an example of it's use. So, sure, if you can add an html test page that uses requirejs to load in the html beautifier that would be great. |
Sorry did not have any time the last couple of weeks. I looked into the issue again and it turns out that the error i was having only happens when using predefined path definitions with requirejs. I made 2 examples, the first one loads in the html-beautifier directly in the require call using a relative path. The second example uses predefined path definitions for requirejs.
requirejs test with path definitions If you were to run the second test without my modifications to beautify-html.js, requirejs would complain that it cannot find beautify.js and beautify-css.js. Please verify this by putting the tests in your repository without updating beautify-html.js |
Also note that in the examples i have to do
Maybe it is better to return the html_beautify function directly instead of wrapping it in an object before returning it ?
Just to be clear the define statement in beautify-html would have to become :
If you think that is a good idea i will go ahead and change it, and also change my examples. |
Regarding your last comment about returning a function or an object: Take a look at #376. In that PR, the submitter seems to going the opposite direction adding an object wrapper around the function. |
i see :) i don't have too much experience with node-js |
I took the point you made here and made it work with the newly added requirejs tests. Kept your requirejs test page. Looks like it works. Thanks! |
moved the require calls for require.js to be inside the define function so relative paths will work.