Imports of local files in Addons (preview)?

0 favourites
  • 6 posts
From the Asset Store
Ludo Local Multiplayer board game can be played by 2 to 4 players
  • I am having issues importing a local file in an addon, for example in it's 'instance.js' during preview. (e.g. import * as Api from './api.js') - I know that preview mangles file names to blobs, but I thought there was a service worker which helped to make it compatible. Right now it cannot find the file.

    Anyone else do 'import's in addons?

    My workaround for now is importing from a full URL/CDN (which requires an online connection and is slower.)

    e.g. this works fine:

    import * as Comlink from "https://kindeyegames.com/forumfiles/comlink.js";

  • Mikal

    I've had this problem for a long time, tried various methods but to no avail.

    For now I only use the CDN link method, which depends on the internet connection.

  • This works for me, but I need to figure out how to change it during export, besides hacking it.

    import * as Comlink from "https://preview.construct.net/comlink.js";

  • Ashley - any suggestions on how to import modules in addons (for example in instance.js)? Right now it seems to work in preview (import * as Comlink from...) However it fails in export (due to fail in workermain.js, unable to Loadscripts, it sees 'import *' as an error).

  • The SDK doesn't really support modules yet. It would probably be a lot of complicated work to make sure they are compiled/bundled properly on export (especially with no-minify mode) and have difficult compatibility implications (e.g. legacy file: protocol Cordova apps). However using dynamic import should work, or use the file dependency system to bundle a script (using the old-style browser script approach of adding to global variables instead).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply Ashley. For now I have inserted one of the smaller libraries directly into my addon files and may go with the globalThis for the other larger one.

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