apache / cordova-plugman

Apache Cordova Plugman
https://cordova.apache.org/
Apache License 2.0
400 stars 151 forks source link

`plugman platform add --platform_name windows` generates crashing default #122

Open janpio opened 5 years ago

janpio commented 5 years ago
plugman create --name cordova-plugin-math --plugin_id cordova-plugin-math --plugin_version 0.0.1
plugman platform add --platform_name windows

leads to

    <js-module name="cordova-plugin-math" src="www/cordova-plugin-math.js">
        <clobbers target="cordova.plugins.math" />
    </js-module>
    <platform name="windows">
        <js-module name="cordova-plugin-math" src="src/windows/cordova-plugin-math.js">
            <runs target="" />
        </js-module>
    </platform>

Those files being named identical, leads to this exception:

image

SCRIPT5022: Unhandled exception at line 74, column 13 in ms-appx-web://io.cordova.hellocordova/www/cordova.js
0x800a139e - JavaScript runtime error: module cordova-plugin-math.cordova-plugin-math already defined

because both files begin with

cordova.define("cordova-plugin-math.cordova-plugin-math", function(require, exports, module) {

Updating js-module.name to mathProxy (and renaming src/windows/cordova-plugin-math.js to src/windows/mathProxy.js and updating the .src to that) fixes the problem. (Might have to remove and re-add the platform to get rid o the old file though)

raphinesse commented 5 years ago

because both files begin with

cordova.define("cordova-plugin-globalization.GlobalizationProxy", function(require, exports, module) {

Is that module name correct? It does not match the error message you quoted.

janpio commented 5 years ago

Good catch (Sorry). Correct would have been:

cordova.define("cordova-plugin-math.cordova-plugin-math", function(require, exports, module) {

which is probably caused because both modules are defined as <js-module name="cordova-plugin-math" ... in plugin.xml.