wickedest / Mergely

Merge and diff documents online
http://www.mergely.com
Other
1.17k stars 228 forks source link

(...).mergely is not a function #172

Closed azdurov closed 1 year ago

azdurov commented 1 year ago

Hello. There are problems with importing the Mergely My js file is used as a module: <script type="module" src="/assets/diff.js"></script>

diff.js file content:

import $ from 'jquery';
import 'mergely';

$(document).ready(function () {
    $('#compare').mergely({
        width: 'auto',
        cmsettings: {
            readOnly: false,
            lineNumbers: true
        },
        lhs_cmsettings: {
            readOnly: true,
            lineNumbers: true
        }
    });
});

Apparently method pluginMaker doesn't add method mergely to jquery.

As I see, there is an actual pull request with a large number of changes. And maybe the changes will help in my case. https://github.com/wickedest/Mergely/pull/171 When will the pull request be completed?

wickedest commented 1 year ago

@azdurov, have you seen mergely-webpack? It is a good starting point on how to start working with Mergely. You're using import too, so I am a bit puzzled.

azdurov commented 1 year ago

@wickedest , thanks for the example. I have seen this before and it works. The fact is that my js script is used as a module. Because of this, I have already encountered several problems with the initialization of various npm dependencies. And now, a simple import from Mergely executes the code inside, but does not register the method in the jQuery.

wickedest commented 1 year ago

@azdurov, what are you trying to do exactly? Mergely is jquery plugin that needs to be bundled together with jquery and codemirror, and also requires a browser to work.

azdurov commented 1 year ago

@wickedest, when using a js script as a module, the jQuery is not added to the global "window". Therefore, Mergely does not see it. And I wanted to be able to specifically pass the jQuery inside, to initialize the "mergely" method.

The changes in the "webpack-upgrade" branch are fine for me. And I wanted to see it as an npm library.

wickedest commented 1 year ago

@azdurov, try again with the latest mergely (v5).

azdurov commented 1 year ago

@wickedest , thanks a lot for the new release! Problem solved.

jiangyuhang0506 commented 8 months ago

"mergely": "^5.1.1" $(...).mergely() is not a function