Skip to content

Strange behavior when importing JS library  #34

@jakelowen

Description

@jakelowen

After I install via npm install @tangramdotdev/tangram
and attempt to import using let tangram = require("@tangramdotdev/tangram")
and follow the remainder of the tutorial steps

I can run the script and get a working prediction as expected. However I am noticing some strange behaviors.

A) - Eslint is not happy with the import. It always gives me "Unable to resolve path to module '@tangramdotdev/tangram'.eslintimport/no-unresolved"

B) Even though the script will execute and work as expected, I can not test any function that imports the tangram library. Jest always throws the "Cannot find module '@tangramdotdev/tangram' from 'index.js' "

I've never observed this before in any other library. Any guidance? I've included some screenshots:

Working script: (Note the ESLINT error on import)
image
Ignore blocks at line 13 and 161 - Just some data marshalling / cleaning to get it in the right shape.

Working result: (after directly uncommenting line 177 in above image to run directly)
image

A simple jest test of above foo function:

const foo = require("./index")

test("foo", () => {
    expect(foo()).toEqual({})
})

But when I run above test:
image

It's so baffling to me that I can run the script and all works as normal, but ESLINT and Jest are both throwing fits.

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