PythonMonkey
PythonMonkey copied to clipboard
Edge case: `require("..")` error
Issue type
Bug
How did you install PythonMonkey?
Installed from pip
OS platform and distribution
macOS 15.1.1
Python version (python --version)
Python 3.13.1
PythonMonkey version (pip show pythonmonkey)
1.1.0
Bug Description
Pythonmonkey isn't able to follow imports in js when require("..") is written.
Standalone code to reproduce the issue
import pythonmonkey
import os
pythonmonkey.globalThis["process"] = {"env": os.environ}
pythonmonkey.require('@babel/generator')
Relevant log output or backtrace
Traceback (most recent call last):
File "/Users/n/fff/main.py", line 5, in <module>
pythonmonkey.require('@babel/generator')
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/Users/n/fff/.venv/lib/python3.13/site-packages/pythonmonkey/require.py", line 431, in require
return createRequire(filename)(moduleIdentifier)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
pythonmonkey.SpiderMonkeyError: Error in file /Users/n/fff/.venv/lib/python3.13/site-packages/pythonmonkey/node_modules/ctx-module/ctx-module.js, on line 238, column 21:
Error: module not found -- require('') from /Users/n/fff/node_modules/@babel/types/lib/builders/validateNode.js
Additional info if applicable
The content of `/Users/n/fff/node_modules/@babel/types/lib/builders/validateNode.js`:
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = validateNode;
var _validate = require("../validators/validate");
var _ = require(".."); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ERROR HAPPENING HERE
function validateNode(node) {
const keys = _.BUILDER_KEYS[node.type];
for (const key of keys) {
(0, _validate.default)(node, key, node[key]);
}
return node;
}
//# sourceMappingURL=validateNode.js.map
What branch of PythonMonkey were you developing on? (If applicable)
No response