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

Edge case: require("..") error #467

Open
novitae opened this issue Jan 10, 2025 · 0 comments
Open

Edge case: require("..") error #467

novitae opened this issue Jan 10, 2025 · 0 comments

Comments

@novitae
Copy link

novitae commented Jan 10, 2025

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

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

No branches or pull requests

1 participant