-
Notifications
You must be signed in to change notification settings - Fork 5
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
Thoughts: ES6 integration features #63
Comments
I still haven't quite grasped the issue of sharing classes. What we (both my company and my friend's startup) do is concatenate all .oj files together and compile as one unit. We have a file watcher in place, as soon as an .oj file is modified, it spits out a new webapp.js file with the compiled contents. Remind me again why this doesn't work in your case? (You can use your preprocessor to figure out which files to include, and then compile all files at once). In the above example, All you should need is some kind of |
To build my front-end code, I use the WebPack bundler. To bundle files, it scans the input for any However, for this modular aproach to work, it wraps all the modules into a function and assigns it an ID. For instance: function(module, exports, __webpack_require__) {
// module code
} All the var oj = require("oj/src/runtime"); could become: var oj = __webpack_require__(2); As you can see, with all the OJ code being wrapped per-function, I believe you can see what issues it proposes. The classes do indeed get registered into the global That is why I built a C-style preprocessor to put the files together, while still being able to utilize WebPack - which has many other features. For instance, I can litterally Because: OJ actually may not know of a class during compilation. That is the kind of problem I have, and why I built custom tools to tackle it. :) I could add the |
I should add, that the following code does not work in a RequireJS/CommonJS environment. Foo.oj @implementation Foo
+(void) doIt { console.log("Doing something..."); }
@end App.oj
However, var Foo = require("./Foo.oj");
[Foo doIt]; |
This is not really a proposal, but rather a bit of an idea that I had.
While working with OJ, I had faced, back and forth, the issue of how to share classes. Since I use OJ mainly on the client using WebPack and my transformers/loaders, I would always have to somehow get the various files to come together.
My current aproach is to use a custom preprocessor to build my code. It works like the C one, but for OJ.
Since we are nearing proper ES6 support, I had something like this on my mind:
and
The options we have for implementing this:
export
statement, the following class-name should be treatened as if we'd called[ClassName class]
.However, OJ currently knows of the files "statically", as it comes from the array of files. So, when we find an
import
statement, we should consider adding that file to the files list and dropping the statement alltogether. Result:The JavaScript of this "import" would be something like
That would, onc eagain, require us to read the AST and generate a changed statement for what used to be an import atatement.
One example which would be very close to my project's workflow:
These are only thoughts, so feel free to ignore this if you wish to :). I just thought I'd share what I had in my mind.
The text was updated successfully, but these errors were encountered: