镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Open

Description

@novitae

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions