You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing a local (non-NPM) module the import fails if the file extension is not included. For example import { Worker } from './worker';
If "js.commonjs-require" is "false" the error is Error: Error reading: /path/to/file/worker
If "js.commonjs-require" is "true" the error is TypeError: Module not found: './worker'
I had a quick look at your example, and -- if I am not mistaken -- node.js also throws an error with import './worker' in your case:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/danieleb/Downloads/graaljs-import/src/main/resources/worker' imported from /Users/danieleb/Downloads/graaljs-import/src/main/resources/main.mjs
Did you mean to import ../worker.js?
In any case, you can use a Truffle FS to customize how ES modules are loaded, and there is no need to use js.commonjs-require to load non-NPM modules like in your case. We have an example here, and in our unit tests.
When importing a local (non-NPM) module the import fails if the file extension is not included. For example
import { Worker } from './worker';
If "js.commonjs-require" is "false" the error is
Error: Error reading: /path/to/file/worker
If "js.commonjs-require" is "true" the error is
TypeError: Module not found: './worker'
Example attached.
graaljs-import.zip
To run:
mvn package exec:java
Expected: It should be able to resolve
./worker
to./worker.js
, as node does.The text was updated successfully, but these errors were encountered: