Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

Hedges

1
Posts
1
Topics
A member registered 96 days ago

Recent community posts

(1 edit)

UPDATE :

I was able to fix the "Uncaught ReferenceError: a is not defined" message by adding 'const' to the forloop on line 954. So it's now, for (const a in attrs). type="module" can now be added to the main.js <script> tag and static imports work. Using dynamic imports is no longer needed. I'll add a new pastebin example.

https://pastebin.com/fCCzG1p5

Original Post:

I finally found a working solution using dynamic imports. For some reason adding type="module" to <script src="main.js"... breaks at line 954. Using dynamic imports skips the need for type="module" and allows imported modules to be used. All you need to do is all 'async' to the IIFE in main.js then dynamically import the modules. I have added a simple pastebin example moving 'gametitle' to another file. 

https://pastebin.com/4Y0P3VsW

I don't know the limitations of this solution, but it has been working so far. I was able to create a sound.js file and move the sfx constant into it. 

(1 edit)

My main.js file is getting pretty big, is there a way to split this into multiple files? I tried exporting and importing modules but this caused an "Uncaught ReferenceError: a is not defined" error.

Update: Error was fixed by adding const to the forloop on line 954. See post below for more details.