Use modules in C3 SDK addon external scripts?

0 favourites
  • 3 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Is it possible to use modules (import, export) in C3 SDK addon external script files?

    Right now it does not seem possible, because the external script files are not referenced with the module type in the generated index.html? Is there a way to change this or a different external file dependency type to use?

    Also, I am not sure this is another problem, but in preview, it _seems_ like when trying import, the path may not be intercepted by the service worker to change to something appropriate for import/export (in the way that included C3 project JS scripts do?) Heavy speculation here. The reason I suspect this is I see different import/export error messages in preview compared to using HTML5 project (HTML5 project error is just related to script not having a module tag.)

    This is the error I get on preview:

    Uncaught TypeError: Failed to resolve module specifier "./spine-gl-cache.js". Invalid relative url or base scheme isn't hierarchical.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Is it possible to use modules (import, export) in C3 SDK addon external script files?

    Right now, the answer is no, simply because the engine still supports classic mode for backwards compatibility at the moment.

    Sooner or later we'll remove classic mode though so you can rely on modules mode. However there are still complications with importing - in particular when you compile to an APK, imports cannot refer to local files, so they stop working. To fix this we actually have to minify all the JavaScript code in the project even when you choose not to minify it when exporting to Android (or the legacy file: scheme on iOS) to work around this.

    Whether or not that works with third party addons, to be honest I don't know, I've not tested anything with that and nothing in the official Construct addons attempt to do anything like that.

    To work around the various preview/publishing quirks, you probably cannot use modules in addons and just have to rely on telling Construct about all your script files so it can manage them for you.

  • Thanks for the info, will work around it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)