Closed benwaffle closed 8 years ago
will test later on if there are side effects but it looks OK to me.
Have you tried dropping babel standalone ?
jsgtk --no-transform your-file.js
oh, thats much faster
so here's the catch: GJS is unfortunately based on moz24 engine which is a pre ES6 era. I've introduced babel standalone at runtime to be able to use modern code like it's possible already in node.
However, if you use already transpiled code that's a huge overhead, but if you don't use the runtime transformer you also miss all modern fun parts of the language, and you cannot extend with ease native GTK classes.
The fact it loads slow is a real bummer, the fact if it's faster you cannot use ES6 is even worst. I've opted for the least bummer by default, and unless GJS updates to a modern engine I have no idea how to solve this.
can you run js files through babel unless they are in node_modules?
not sure I should ... if some cowboy publishes an ES6 comaptible module the whole system would be doomed.
Since the main goal here is to simulate, as seamless as possible, what a node-js env would do, considering that node 4 and 6 already have way more ES6 than moz24 ever dreamed about, I guess, and I am afraid, there's no silver bullet here.
However, if you were thinking about a flag, then maybe it makes sense, as long as you are sure about the module you are using as dependency.
actually thinking about a --no-modules-transform
to have hybrid solution to this ... it's not future proof but sounds like a reasonable approach for now ... thoughts?
yeah sounds like the best option at this point
actually, after quick better analysis, a node module can be pretty much anything.
Are you talking about modules defined as dependency in the initial package.json
where you launch the first jsgtk
compatible script?
anything installed by npm, thus anything in node_modules. technically it doesn't have to be saved in package.json
so, absolute and relative paths would still be transpiled ... deal?
what makes those special?
because that's how you include files in node. Either you want only the main file to be transpiled at runtime, or if you want to keep ES6 compatibility and still use require('./myfile')
we need to agree that only pre-installed modules should not be parsed.
Otherwise --no-transform
already covers your case, right?
thinking about it, a module can have nested dependencies and/or include its own files via relative paths.
TL;DR I am not sure how to solve this, looks more like an overhead full of problems rather than a handy use case.
hints welcome
This makes react load successfully.
Although, loading something as large as react can take multiple seconds: