Skip to content

[bug] import still doesn't behave predictably #38

Open
@evolbug

Description

@evolbug

When compiling imports should behave by this system:

compile file:       all imports are relative to initial file
compile directory:  all imports are relative to initial directory
build project:      all imports are relative to src/

The resulting require statements should also use . to separate path elements instead of / and should not contain a ./ prefix

project/
    src/
        lib/
            init.wu
            mylib.wu
        main.wu
    wu.toml

Contents:

# main.wu
import lib { mylib }

# init.wu
import mylib { MyType }

# mylib.wu
MyType: struct {}

Building project: ~/project$ wu build
Expected contents:

-- main.wu
local lib = require "lib"
local mylib = lib["mylib"]

-- init.wu
local mylib = require "lib.mylib"

-- mylib.wu
<empty>

Building directory: ~/project$ wu src/lib
Expected contents:

-- init.wu
local mylib = require "mylib"

-- mylib.wu
<empty>

Building file: ~/project$ wu src/lib/init.wu
Expected contents:

-- init.wu
local mylib = require "mylib"

-- mylib.wu
<empty>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghigh priorityIssue that significantly hinders usability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions