explorigin / modular-js Goto Github PK
View Code? Open in Web Editor NEWA custom Javascript generator for Haxe that outputs AMD modules.
License: MIT License
A custom Javascript generator for Haxe that outputs AMD modules.
License: MIT License
Right now the generator doesn't seem to recognise externs with @:jsRequire as dependencies. That would be really useful and allow mixing with node_module code through browserify or webpack.
Hey there Timothy!
Thanks for this lib, it's a great example on how to modify the js output, quite neat! Works fine for the most part.... but:
I'm having an issue. Whenever I compile the first time (when the module js don't exit) it works fine. If I make any changes to any of the module classes and compile again, I get this:
Warning : File already exists at /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Module1.js. Saving to /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Module1.js.1459556590.
Warning : File already exists at /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Main.js. Saving to /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Main.js.1459556590.
Warning : File already exists at /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Module1.js. Saving to /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Module1.js.1459556590.
Warning : File already exists at /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Main.js. Saving to /Users/fullofcaffeine/workspace/code/modular-js-haxe-test/bin/Main.js.1459556590.
Do you know why this happens?
The sample project/sandbox is available here: https://github.com/fullofcaffeine/modualr-haxe-js-test
(PS: I'm looking into exteding/modifying this to support Ember 2 through Ember-CLI)
Thanks in advance!
When running a build I get this error :
pieter$ haxe build.hxml
/usr/local/lib/haxe/std/neko/_std/sys/io/File.hx:30: characters 20-51 : /usr/local/lib/haxe/lib/modular-js/js/enum_stub.js: No such file or directory
/usr/local/lib/haxe/lib/modular-js/0,9,1/src/modular/js/JsGenerator.hx:145: characters 3-64 : Called from
/usr/local/lib/haxe/lib/modular-js/0,9,1/src/modular/js/JsGenerator.hx:384: characters 3-40 : Called from
/usr/local/lib/haxe/lib/modular-js/0,9,1/src/modular/js/JsGenerator.hx:438: characters 46-77 : Called from
<null pos>:1: character 0 : Called from
Aborted
You can see that /usr/local/lib/haxe/lib/modular-js/js/enum_stub.js
is not found, but when I look at the filesystem it seems that the root path to modular-js is incorrect because /usr/local/lib/haxe/lib/modular-js/0,9,1/js/enum_stub.js
does exist.
Is this a bug in modular-js?
I stumbled upon an issue where I cannot reference any of the global primitives in my haxe code. It seems they are not available when the code is running in the browser.
Do you have any idea on how to tackle this?
class Test {
static function main() {
var value:Dynamic = true;
var bool:Bool = cast(value,Bool);
trace(bool);
}
}
Error in the browser console :
bundle.js:20 Uncaught ReferenceError: Bool is not defined
Hi, I use Haxe 3.4.2.
When I want to compile my project (NodeJS) I got this error:
/Volumes/Work/Haxe/libs/modular-js/git/src/modular/js/Klass.hx:131: characters 19-72 : Invalid input value
/Volumes/Work/Haxe/libs/modular-js/git/src/modular/js/JsGenerator.hx:211: characters 2-14 : Called from
/Volumes/Work/Haxe/libs/modular-js/git/src/modular/js/JsGenerator.hx:240: characters 5-21 : Called from
<builtin>:1: character 0 : Called from
/usr/local/lib/haxe/std/neko/_std/Array.hx:275: characters 12-18 : Called from
/Volumes/Work/Haxe/libs/modular-js/git/src/modular/js/JsGenerator.hx:354: characters 2-29 : Called from
/Volumes/Work/Haxe/libs/modular-js/git/src/modular/js/JsGenerator.hx:462: characters 46-77 : Called from
<null pos>:1: character 0 : Called from
Aborted
This issue is related to these lines of code (was this in Haxe 3.4.2) in the compat classes, perhaps these existing Haxe issues (6491, 4467), maybe these people (@nadako @andyli @elsassph @kevinresol @MatthijsKamstra) would have some ideas, and this testcase:
class Test {
static function main() {
var b = haxe.io.Bytes.ofString("hello world!");
trace(b.toString());
}
}
Without modular-js, just the default JS generator and Haxe 3.4.2, the above testcase generates this code. That's all well and good, though the var Uint8Array on line 442 does something interesting. It overrides the global Uint8Array
for the scope of the whole file, and doesn't set it until execution of that line. It doesn't happen to be a problem with the default JS generator.
But now, consider the output when using modular-js
. The output js/html/compat/Uint8Array.js
file is here. By definition, this can't work, because the var Uint8Array
at the bottom. In this scope, Uint8Array
is a null reference until that line executes, so the first line in the scope (Uint8Array.BYTES_PER_ELEMENT = 1
) is a null reference. Not only that, declaring a var Uint8Array
in this file does not effectively override the global scope (which I believe is the intent / effect of the default JS generator.)
I'm not sure what needs to change -- the modular-js generator, or this line in the compat files in the standard library. But since this issue is currently specific to modular-js, I filed it here. (BTW, @elsassph, I wanted to see what happens in haxe-modular but couldn't get it to work. After installing the npm lib and haxelib, running the testcaes I got sh: 1: haxe-plit: not found
)
First, is the idea behind the compat files this: a polyfill for browsers without Uint8Array / DataView / ArrayBuffer / etc? Second, is it a good idea for the compat files to declare a var in untyped __js__
, much less a var name that overrides a (browser) global?
Thoughts?
Compiling throws:
JsGenerator.hx:62: characters 2-30 : Invalid input value
<builtin>:1: character 0 : Called from
Seems to be a problem in Haxe, though. See my simplified testcase: HaxeFoundation/haxe#5963
Hey there. I've forked the project, and would love to add CommonJS support to my fork. I've been exploring the code, and it seems pretty easy to understand. I'm just posting this "issue" to both give you my props for having made such a neat library, and ask if you had any pointers to perhaps point me in the right direction towards adding said feature?
Thanks in advance.
More of a question than an issue: I'm attempting a basic test using webpack, but it seems to expect modules to define relative dependencies. Seems simple enough to implement, just wondering if I'm doing something wrong :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.