【问题标题】:Can't get sourcemaps to work in Firefox无法让源映射在 Firefox 中工作
【发布时间】:2018-03-30 14:38:10
【问题描述】:

对于即将发布的Transcrypt Python 到 JS 编译器版本,添加了对 ES6 模块的支持。 但是我无法让源地图在 Firefox 中工作,而在 Chrome 中它们可以完美地工作。 我正在使用 Firefox 开发者版 59.0b13(64 位) 我的问题是(Python)源文件未显示在调试器的“源”窗格中。 以下文件都在同一目录中,由 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 中看起来不错。 只有地图不起作用。

【问题讨论】:

    标签: firefox source-maps transcrypt


    【解决方案1】:

    重启 Firefox 有所帮助,尽管源地图已经启用。 不知道为什么...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-29
      • 1970-01-01
      • 2020-09-29
      相关资源
      最近更新 更多