-
-
Notifications
You must be signed in to change notification settings - Fork 694
[js] Module import support #12384
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
[js] Module import support #12384
Conversation
|
I tested this branch on real pixijs with minimal externs and now generate imports like that: import { Application as pixi_PixiApplication } from "./pixi.js";
var app = new pixi_Application({...});Also added test that The only problem i see is that if we will generate es6 externs like @:js.import("./pixi.js")
extern class Application {}I'm not sure that @haxiomic do you have some idea how If there is no universal way, i think it will make sense to also add this syntax: @:js.import(pixijs_esm)And parse |
|
This looks good at first read. @RblSb I'm not certain I fully follow the question regarding Let's get a version of this merged as is a critical feature! I imagine we lost a lot of js users while we could not use modern js libs |
|
I added
Let me know if things can be improved. |
|
CC @Simn, this is a massive feature for js integration, pretty much all new library use js modules which haxe currently cannot use |
|
I don't know if this is useful or not, but if everyone says so I'm happy to merge it. Let's update the branch for green CI though. |
|
@back2dos do you think this approach with defines is fine for haxe libs? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent some time thinking about all the different possibilities in the wild and I'm satisfied this PR covers everything we'd need in practise. Great work @RblSb !
Just need to fix the failing test, looks like missing "type": "module" in a package.json in the test
When this is in haxe I'll add support to dts2hx
|
Shouldn't the tests go into |
Hmm, I would say the "typical" approach is to install JS libraries via npm and import from there, with some bundler then doing the remaining work. I'm not sure what one would use relative paths for, unless the libs are checked into the repo or something. But the cool part about this is that one could actually use the defines to point to CDN versions, e.g. |
Not sure if this covers all cases. Maybe @haxiomic knows
Closes #10615