Skip to content

Import-map that defines a local path alias does not resolve. #29

Closed
@masataka

Description

@masataka

When using Aleph's routing, if I refer to components from files under the "/pages/" folder, the URL will become dirty as the folder layer gets deeper. Therefore, I want to replace the project root folder with "@ /". This is possible with simple Deno projects but Aleph.js can't compile them.

Is there a solution?

./import_map.json

{
    "imports": {
        "react": "https://esm.sh/react",
        "@/": "./"
    }
}

import in a page file

// import React from 'https://esm.sh/react';
import React from 'react';    // ALL OK
// import Navigation from '../../../components/Navigation.ts';
import Navigation from '@/components/Navigation.ts';    // VS Code editor OK, Aleph compile NG

error message

error: Uncaught (in promise) NotFound: No such file or directory (os error 2)
    at processResponse (core.js:224:13)
    at Object.jsonOpAsync (core.js:242:12)
    at async open (deno:cli/rt/30_files.js:44:17)
    at async Object.readFile (deno:cli/rt/40_read_file.js:15:18)
    at async Project._compile (project.ts:977:29)
    at async Project._compile (project.ts:1127:28)
    at async Project._init (project.ts:613:21)
    at async project.ts:106:13
    at async start (server.ts:12:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions