Skip to content
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

Fix resolving modules with .js in module name #34

Closed
wants to merge 1 commit into from

Conversation

conla
Copy link

@conla conla commented Sep 15, 2016

When using nashorn and loading a script with a dependency to a node
module that contains .js in its name e.g. decimal.js, the actual js
file inside the module couldn't be resolved.

The fix is achieved by trying to resolve to directory first and then
to file.

When using nashorn and loading a script with a dependency to a node
module that contains .js in its name e.g. decimal.js, the actual js
file couldn't be resolved.

The fix is achieved by trying to resolve to directory first and then
to file.
@lance
Copy link
Contributor

lance commented Sep 15, 2016

Hi @conla, can you please provide a test case which fails, and show that this change fixes it? We already have a test for finding a module with an extension here https://github.com/nodyn/jvm-npm/blob/master/src/test/javascript/specs/requireSpec.js#L114-L117.

Copy link
Contributor

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here is modeled on the Node.js module resolution algorithm, loosely outlined here: https://nodejs.org/api/modules.html#modules_all_together. I'm not keen on changing this. I would like to see a failing test case, because there may be another way to solve the issue without these modifications.

@conla
Copy link
Author

conla commented Sep 19, 2016

The code change presented here helped me to fix an issue in one of my projects.
The error message was:
"Error: Cannot read file [C:\dev\eru\svn\trunk\source\test\eru-test-generated\node_modules\decimal.js]: in node_modules/jvm-npm/src/main/javascript/jvm-npm.js at line number 108 at column number 8".
It looked like the decimal.js file inside the decimal.js folder wasn't resolved correctly before. Afterwars it worked.
But I couldn't prove the effect of the fix in a simpler test project. So the problem must lie somewhere else in my specific setup. I have to investigate further. Sorry for bothering.

@conla conla closed this Sep 19, 2016
@conla
Copy link
Author

conla commented Sep 19, 2016

Maybe this is a windows-specific issue and has something to do with issue #15. But I'm only guessing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants