Skip to content

struggling with relative imports #251

@dckc

Description

@dckc

I have the following layout:

src/kernel/index.js
test/test-kernel-xs/main.js
test/test-kernel-xs/manifest.json

In main.js I'd like to use import buildKernel from '../../src/kernel/index'; because that way my editor (vs-code) will know what I'm talking about.

I can't figure out what to put in manifest.json to get mcconfig to play along (with cwd = test/test-kernel-xs). Clues?

With manifest 1 below, I can build and run, but I get:

# Break: (host): module "../../src/kernel/index" not found

with manifest 2, mcconfig -d -m -p lin says ### Error: No such file or directory.
strace output includes:

[pid 27019] mkdir("/home/connolly/projects/moddable/build/tmp/lin/debug/mc/test-kernel-xs", 0755) = -1 EEXIST (File exists)
[pid 27019] mkdir("/home/connolly/projects/moddable/build/tmp/lin/debug/mc/test-kernel-xs/modules", 0755) = -1 EEXIST (File exists)
[pid 27019] mkdir("/home/connolly/projects/moddable/build/tmp/lin/debug/mc/test-kernel-xs/modules/../../src/kernel", 0755) = -1 ENOENT (No such file or directory)

Manfest 1

{
    "include": [
        "$(MODDABLE)/examples/manifest_base.json"
    ],
    "modules": {
        "*": [
            "./main",
            "../../src/kernel/*"
        ],
        "@agoric/harden": "../../node_modules/@agoric/harden/dist/harden.esm",
        "@agoric/make-hardener": "../../node_modules/@agoric/make-hardener/index",
        "@agoric/nat": "../../node_modules/@agoric/nat/dist/nat.esm",
        "tape-promise/tape": "../../node_modules/tape-promise/index.compiled",
        "onetime": "../../node_modules/onetime/index"
    }
}

Manifest 2

{
    "include": [
        "$(MODDABLE)/examples/manifest_base.json"
    ],
    "modules": {
        "*": [
            "./main"
        ],
        "../../src/kernel/*": "../../src/kernel/*",
        "@agoric/harden": "../../node_modules/@agoric/harden/dist/harden.esm",
        "@agoric/make-hardener": "../../node_modules/@agoric/make-hardener/index",
        "@agoric/nat": "../../node_modules/@agoric/nat/dist/nat.esm",
        "tape-promise/tape": "../../node_modules/tape-promise/index.compiled",
        "onetime": "../../node_modules/onetime/index"
    }
}

I guess I can attach a .zip of my working dir...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions