Skip to content
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

Macro for jQuery Plugins doesn't work when having more than 1 plugin #20

Open
mmauri opened this issue Sep 28, 2017 · 3 comments
Open

Comments

@mmauri
Copy link

mmauri commented Sep 28, 2017

Andy,
When you have to import more than 1 Jquery plugin in the hxml file, it fails:
(with only 1 plugin it works)

-lib jQueryExtern
-cp src
-js bin/DataTables.js
-main Main
--macro js.jquery.Config.addPlugin('externs.DataTable')
--macro js.jquery.Config.addPlugin('externs.Semantic')

It throws this compile error:
src/externs/Semantic.hx:4: lines 4-30 : JQuery class is already built before inserting plugin. Most likely due to missing
compiler option: --macro js.jquery.Config.addPlugin('externs.Semantic')
The terminal process terminated with exit code: 1

Sample project:
https://github.com/mmauri/DataTablesSample/

Thanks for your help!

@andyli
Copy link
Owner

andyli commented Sep 29, 2017

The problem is the import js.jquery.JQuery; statements in the extern modules. One extern module importing JQuery forces the compiler to build JQuery, so the other extern can no longer inject fields into JQuery.

The solution is simply to remove the import statements. You can still use JQuery (no need to use js.jquery.JQuery) in the extern body, because the extern fields are only typed after they are "pasted" into the JQuery class. Since JQuery is in js.jquery, you can reference any types in js.jquery without using fully-qualified names.

In fact, currently import statements are not supported in the plugin extern modules... I will have to think about how to support that. At the moment, please use fully-qualified names for any other types not existed in top-level or js.jquery.

Let me know if you can make the plugins work.

@mmauri
Copy link
Author

mmauri commented Oct 2, 2017

Thank you very much Andy,
I will remove the imports.
This should be a common issue, that maybe have to be in the README file....

Thanks again for your help!
Marc

@mmauri
Copy link
Author

mmauri commented Oct 2, 2017

Oops! just saw you already did it.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants