无法在Firefox中使用源图

时间:2018-03-30 14:38:10

标签: firefox source-maps transcrypt

对于即将推出的Transcrypt Python to JS编译器版本,增加了对ES6模块的支持。 但是,我无法在Firefox中使用源图,而在Chrome中,它们可以完美运行。 我使用的是Firefox Developer Edition 59.0b13(64位) 我的问题是(Python)源文件没有显示在调试器的Sources窗格中。 以下文件都在同一目录中,由node.js http-server:

提供服务

Python源代码:

from itertools import chain

class SolarSystem:
    planets = [list (chain (planet, (index + 1,))) for index, planet in enumerate ((
        ('Mercury', 'hot', 2240),
        ('Venus', 'sulphurous', 6052),
        ('Earth', 'fertile', 6378),
        ('Mars', 'reddish', 3397),
        ('Jupiter', 'stormy', 71492),
        ('Saturn', 'ringed', 60268),
        ('Uranus', 'cold', 25559),
        ('Neptune', 'very cold', 24766) 
    ))]

    lines = (
        '{} is a {} planet',
        'The radius of {} is {} km',
        '{} is planet nr. {} counting from the sun'
    )

    def __init__ (self):
        self.lineIndex = 0

    def greet (self):
        self.planet = self.planets [int (Math.random () * len (self.planets))]
        document.getElementById ('greet') .innerHTML = 'Hello {}'.format (self.planet [0])
        self.explain ()

    def explain (self):
        document.getElementById ('explain').innerHTML = (
            self.lines [self.lineIndex] .format (self.planet [0], self.planet [self.lineIndex + 1])
        )
        self.lineIndex = (self.lineIndex + 1) % 3

solarSystem = SolarSystem ()

透明到js:

// Transcrypt'ed from Python, 2018-03-30 16:23:19
import {__envir__, __nest__, __init__, __get__, __getcm__, __getsm__, py_metatype, object, __class__, __pragma__, __call__, __kwargtrans__, __globals__, __super__, property, __setProperty__, assert, __merge__, dir, setattr, getattr, hasattr, delattr, __in__, __specialattrib__, len, __i__, __k__, __t__, float, int, bool, py_typeof, issubclass, isinstance, callable, repr, chr, ord, max, min, round, __jsUsePyNext__, __pyUseJsNext__, py_iter, py_next, __PyIterator__, __JsIterator__, py_reversed, zip, range, any, all, sum, enumerate, copy, deepcopy, list, tuple, set, bytearray, bytes, str, dict, __jsmod__, __mod__, __pow__, __neg__, __matmul__, __mul__, __truediv__, __floordiv__, __add__, __sub__, __lshift__, __rshift__, __or__, __xor__, __and__, __eq__, __ne__, __lt__, __le__, __gt__, __ge__, __imatmul__, __ipow__, __ijsmod__, __imod__, __imul__, __idiv__, __iadd__, __isub__, __ilshift__, __irshift__, __ior__, __ixor__, __iand__, __getitem__, __setitem__, __getslice__, __setslice__, BaseException, Exception, IterableError, StopIteration, ValueError, KeyError, AssertionError, NotImplementedError, IndexError, AttributeError, py_TypeError, Warning, UserWarning, DeprecationWarning, RuntimeWarning, __sort__, sorted, map, filter, divmod, __Terminal__, __terminal__, print} from './org.transcrypt.__runtime__.js';
var __name__ = '__main__';
import {chain} from './itertools.js';

export var SolarSystem =  __class__ ('SolarSystem', [object], {
    __module__: __name__,
    planets: (function () {
        var __accu0__ = [];
        for (var [index, planet] of enumerate (tuple ([tuple (['Mercury', 'hot', 2240]), tuple (['Venus', 'sulphurous', 6052]), tuple (['Earth', 'fertile', 6378]), tuple (['Mars', 'reddish', 3397]), tuple (['Jupiter', 'stormy', 71492]), tuple (['Saturn', 'ringed', 60268]), tuple (['Uranus', 'cold', 25559]), tuple (['Neptune', 'very cold', 24766])]))) {
            __accu0__.append (list (chain (planet, tuple ([index + 1]))));
        }
        return __accu0__;
    }) (),
    lines: tuple (['{} is a {} planet', 'The radius of {} is {} km', '{} is planet nr. {} counting from the sun']),
    get __init__ () {return __get__ (this, function (self) {
        self.lineIndex = 0;
    });},
    get greet () {return __get__ (this, function (self) {
        self.planet = self.planets [int (Math.random () * len (self.planets))];
        document.getElementById ('greet').innerHTML = 'Hello {}'.format (self.planet [0]);
        self.explain ();
    });},
    get explain () {return __get__ (this, function (self) {
        document.getElementById ('explain').innerHTML = self.lines [self.lineIndex].format (self.planet [0], self.planet [self.lineIndex + 1]);
        self.lineIndex = __mod__ (self.lineIndex + 1, 3);
    });}
});
export var solarSystem = SolarSystem ();

//# sourceMappingURL=hello.map

地图:

{
    "version": 3,
    "file": "hello.js",
    "sources": [
        "hello.py"
    ],
    "mappings": "AAAA;AAAA;AAAA;AAAA;AAEA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAWA;AAMA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAAA;AAEA;AAEA;AAEA;AAAA;AAAA;AAEA;AAAA"
}

任何人都看到了什么? 该页面在Firefox中看起来不错。 只有地图不起作用。

1 个答案:

答案 0 :(得分:0)

重新启动Firefox有帮助,尽管已启用源映射。 不知道为什么......