Import Maps don't seem to work

0 favourites
  • 2 posts
From the Asset Store
A template which allows you to customise the controls of your game.
  • I am on version 407.2

    I created a simple project and imported a simple class without issue.

    I was testing import maps and it throws an error that it can't resolve the import name and it needs to be relative or direct path with a . or /

    I did make the import map json of the type import map.

    This works correctly

    import {Item} from "/Items/Item.js";
    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	
    	const test = new Item(123);
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    

    I then created a json file and set it's type to import map

    Changed my main.js file like so

    import {Item} from "myItem";
    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	
    	const test = new Item(123);
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    

    I then get the following error

    [C3 preview] Browser opened wrong size popup: wanted 854 x 480, got 854 x 479; resizing to compensate
    local.html:1 Uncaught TypeError: Failed to resolve module specifier "myItem". Relative references must start with either "/", "./", or "../".Understand this error
    domSide.js:37 Error loading project main script: Error: main script did not run to completion
     at RuntimeInterface._InitDOM (domSide.js:37:143)
     at async RuntimeInterface._Init (domSide.js:29:261)
    _InitDOM @ domSide.js:37Understand this error
    runtime.js:26 
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I also get this issue when running the example project. So I reported it on GitHub.

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