Error in importing a variable when runing in a webbrowser

Đang mở
#669 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, python
Lĩnh vực
compilers, web-dev

Hướng nghiên cứu

Start with the primitive.py and b.py example, inspect the generated primitive.js, and reproduce the import in Chrome. Trace how Transcrypt handles imported variables and JavaScript module exports; done means the generated module exports is_desktop so b.py runs without the reported SyntaxError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

IS: bug?

Transcrypt (v3.7.16) compiles the following files without an error.

file primitive.py:

is_desktop=True

file b.py:

from primitive import is_desktop
print(is_desktop)

But my web browser(Chrome) throws an error: when running

Uncaught SyntaxError: The requested module './primitive.js' does not provide an export named 'is_desktop'

I think that it is because Javascript requires an explicit export command to export a variable, while Python doesn't. I guess that Transcypt is not inserting an export command into compiled javascript output.

Ngôn ngữ chính
Python
Star
2.9k
Fork
218
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TranscryptOrg/Transcrypt

Tất cả issue của TranscryptOrg/Transcrypt

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.