Closed flaviouk closed 2 years ago
The problem with this style is that nodejs requires you to explicitly set the extensions when importing a local module. This is why the tests fail.
lib0
is supposed to be a pure esm module. node ./test.js
should just work without a transpilation step. It bothers me that some tools (e.g. jest) define custom rules on the style format that are incompatible with the standardized esm format. However, I somehow got to get this working in jest for the jupyter project. So I don't think this change is necessary.
We talked about this earlier. When importing modules from lib0 from an external module, you should do import .. from 'lib0/logging'
instead of import .. from 'lib0/logging.js'
. But this is different when importing local module files.
Ahh I understand why the tests were failing, isomorphic.js
is an external package, and I just did a find and replace, could you reopen, tests are passing locally now
So I tried this out again. I can still not run the test using node ./test.js
because node expects absolutely qualified name imports (with the .js
extension). You can only import without the .js
extension from other modules.
This causes jest to complain as it tries to use the esm version instead of cjs