-
Notifications
You must be signed in to change notification settings - Fork 68
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
Clarification on the use of the JavaScript modules #75
Comments
To be honest, I don't really know the point of those Also, thank you very much for tackling with #52! I plan to make a new npm package, will that resolve the issue or change its solution? It would be grateful if you or somebody else could give me some advice on making/moving a package on npm. Thank you! |
No problem, to be clear the main entry point files, I'm happy to help with moving the npm package if needed, after the package is moved we should also update the As for which syntax, for consistency with the non-module library files, I'm thinking we should use the following import syntax for the ES module as well: import * as OIMO from 'oimophysics';
... This is the same convention that three.js uses too. |
Actually, now that I'm taking a closer look at the non-module library files (I've never used them before), the namespaces are being exported by name there, for example: window["OIMO"] = {};
window["OIMO"]["BroadPhase"] = oimo_collision_broadphase_BroadPhase; This is different from the JS modules generated: var oimo = oimo || {};
if(!oimo.collision) oimo.collision = {};
if(!oimo.collision.broadphase) oimo.collision.broadphase = {};
oimo.collision.broadphase.BroadPhase = class oimo_collision_broadphase_BroadPhase { I think that was maybe the original intent of the OimoPhysics/bin/js_modules/index.js Line 4 in 68c1ba6
Is there an option for Haxe to export the JS modules with the same exports that the non-module library files have? For example, where the JS module file exports both I still think we should delete the |
I prefer the way the non-module library exposes its content too. Currently the module library keeps its nested namespace, which is because of the compiler option I tried removing Haxe's I can insert a flattener function just before I agree to delete the |
Hey @saharan! 👋
So related to the previous TypeScript issue, I have a fix for that and can create a PR, but I'm unsure on the intended use of the
index
files in the bin directory.They appear to be leftover from a three.js implementation by @mrEuler (@VBT-YTokan?), which has since been removed by three.js and has never been used by the package entry point itself, including the old version on npm.
Anyone who's been using this package in the past or currently through GitHub has been importing directly from the namespaces, for example:
Or re-exporting the namespaces like in the
index
files, which allows the use of the library with a more traditional syntax:The
index
files are also missing some exports, and renaming some primitives likeBoxGeometry
toOBoxGeometry
to prevent conflicts when used in other libraries like three.js.It's also worth noting we don't need to rename the classes in the exports, a user who needs to import those classes can also rename the named import to whatever they want in their own app, for example:
Anyways, all this to say, I'm fine using the library any of these ways, just wanted to clarify how you want to move forward with the
index
files, if they are meant to be the main entry point for the JavaScript package, or more as an example of how to re-export the namespaces for your own app?For reference:
The text was updated successfully, but these errors were encountered: