Skip to content
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

Make the parser/compiler usable under Node.js (in a nice way). #41

Closed
3 tasks done
ChALkeR opened this issue Feb 18, 2016 · 6 comments
Closed
3 tasks done

Make the parser/compiler usable under Node.js (in a nice way). #41

ChALkeR opened this issue Feb 18, 2016 · 6 comments
Milestone

Comments

@ChALkeR
Copy link
Member

ChALkeR commented Feb 18, 2016

This means:

  • Using proper module.exports instead of setting globals.

  • Making sure that we don't set globals in the parser.

  • Making an entrance point that allows users to do something as simple as:

    const qmlweb = require('qmlweb');
    const data1 = qmlweb.parsePath(path_to_file);
    const data2 = qmlweb.parseQML(qml_file_content);
    const data3 = qmlweb.parseJS(js_file_content);
@ChALkeR ChALkeR changed the title Make the compiler usable under Node.js (in a nice way). Make the parser/compiler usable under Node.js (in a nice way). Feb 18, 2016
@ChALkeR ChALkeR added this to the 0.2.0 milestone Feb 18, 2016
@ChALkeR ChALkeR mentioned this issue Feb 18, 2016
@labsin
Copy link
Contributor

labsin commented Feb 18, 2016

Should we add a UMD? Something like github.com/umdjs/umd/blob/master/templates/returnExports.js

@henrikrudstrom
Copy link
Member

@ChALkeR Yeah, i was getting annoyed at all the globals floating around.
Think it would be good to make a separate module for the parser/loading stuff, 'qmlweb-parse' for example, then this module can be required by the gulp task or future server side needs.

@labsin UMD looks good. Are there any implications except the extra code to wrap around?

@ChALkeR
Copy link
Member Author

ChALkeR commented Feb 19, 2016

@henrikrudstrom Actually, I think we can just use CJS and Browserify/Webpack. I will take a look at this soon.

@Plaristote
Copy link
Member

Checkout the browserified branch to see a few tweaks I've done to make qmlweb usable directly from nodejs.
The encapsulate helpers are gone, there aren't any global variables left (apart from the AutoLoader, which might need to move somewhere else, since it's useless for the nodejs environment).

I've made some exports, but mainly I've cut the access from the external world to most of what was stored in global variables. We should discuss on what gets exported and what doesn't.

We might also consider removing some of the gulp concatenation in favor of uses of require. That would be a much harder piece of work though, and not being an expert in node's require function, I'm not completely sure this is the best approach.
Anyhow, it would definitely help in making qmlweb more modular.

I can make a PR if you figure what I did in browserified was the way to go.
I'm not sure about the last step. I had to generate two lib/qt.js: one for nodejs, and one that takes the nodejs version and uses browserify on it.

@ChALkeR
Copy link
Member Author

ChALkeR commented May 3, 2016

The proper way to fix this is described in #173, I think.
I nearly completed the split, see #215, #216, qmlweb/qmlweb-parser#6.

All those three points are done in qmlweb/qmlweb-parser#6.

@ChALkeR
Copy link
Member Author

ChALkeR commented May 3, 2016

Implemented in qmlweb-parser.

@ChALkeR ChALkeR closed this as completed May 3, 2016
@ChALkeR ChALkeR removed the blocked label Jun 13, 2016
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

No branches or pull requests

4 participants