I wanted to utilize a import map so that I only needed to change things in one place if the location of files in project needed to be changed. However, I ran into an issue that makes me think this will not work well with a Construct 3 project.
The problem is that the simplest way to make the import path work in all cases is to base it off the the root of the web app. A issue arises when you export the project lets say for windows. So here is what a possible import map file looks like and a directory structure I am using.
{
"imports" : {
"ecs_manager": "/ECS/ECSManager.js",
"player": "/ECS/Player.js",
"enemy": "/ECS/Enemy.js",
"text": "/ECS/Text.js",
"move_system": "/ECS/MoveSystem.js",
"collision_system": "/ECS/CollisionSystem.js",
"component": "/ECS/Component.js",
"move_component": "/ECS/MoveComponent.js",
"coll_polygon_component": "/ECS/CollPolygonComponent.js",
"entity": "/ECS/Entity.js",
"utilities": "/Utilities/Utilities.js",
"vector": "/Utilities/Vector.js",
"enemy_component": "/ECS/EnemyComponent.js",
"system": "/ECS/System.js"
}
}
In preview mode the /ECS directory is off of the root so I can use the key in an import statement in main.js and in a file that's in ECS folder that reference the same import because it's based off the root.
When I export for windows there are additional directories before the ECS now so the path from root is different.
This makes you revert back to relative paths, but now you can't use the same import map key because the path to the file is different from different directories.
Just wondering if anyone else has a solution to this or I may just not use import maps at all.
Thanks