-
Notifications
You must be signed in to change notification settings - Fork 192
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
CommonJS module loader is error-prone #621
Comments
I just verified this with this module code:
Calling |
This module code demonstrates the line/column offsets being incorrect in a stack trace:
Output in JS launcher:
The column offset is off by the length of |
Hi, Thank you for reporting this issue, we will take a look into it and get back to you |
Hi, I'll ask @eleinadani to have a look at your problem; maybe there is a simple way to improve our loader. In general, though, you will be right: it is a "naive" implementation that tries to mimic what Node is doing, but is certainly far from perfect. -- Christian |
@eleinadani I meant to add this comment here a few days ago, but I was delayed and I just noticed you closed this issue. A function should be added internally which behaves like Node's |
@wirthi @oubidar-Abderrahim Please see the above comment. |
Graal.js's CommonJS module loader implementation is naive. A module's source code is prepared in exactly the same manner that Node.js used to do it and could suffer from the same problems.
Here is the relevant section from CommonJSRequireBuiltin.java
ContextifyContext::CompileFunction
was created to fix this in Node and is used byvm.compileFunction
. Some other implementations of CommonJS, such as jvm-npm, useFunction
to create the module function.The text was updated successfully, but these errors were encountered: