-
Notifications
You must be signed in to change notification settings - Fork 65
Strange behavior when importing JS library #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After reading through the installed module in my node_modules folder, I figured out a workaround. If I change my import statement to the full path: Hope that helps. |
@jakelowen thank you so much for the detailed bug report. We will investigate this tomorrow morning. I think this may be caused by eslint and jest not respecting the package.json |
Thanks @isabella. No particular rush on my side to resolve. Enjoy your labor day weekend! Versions: |
@jakelowen thanks for opening this issue. I was able to reproduce it, find the cause, and implement a solution. Your detailed report was very helpful. We want to have a single npm package that supports commonjs, esm, node, and bundlers. We do this using the new import-js/eslint-plugin-import#1868 As a workaround, I added in the old |
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)

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)

A simple jest test of above foo function:
But when I run above test:

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.
The text was updated successfully, but these errors were encountered: