1

尝试使用 shadow-cljs 构建 Clojurescript 项目时出现此错误。该错误发生在优化级别设置为简单的情况下。

浏览器控制台中的完整输出如下所示:

js.js:74 shadow-cljs - failed to load 34
shadow.js.jsRequire @ js.js:74
shadow$provide.<computed> @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
(anonymous) @ index.js:2
(anonymous) @ append.js:2
js.js:74 shadow-cljs - failed to load 49
shadow.js.jsRequire @ js.js:74
shadow$provide.<computed> @ index.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
(anonymous) @ index.js:2
(anonymous) @ append.js:2
js.js:74 shadow-cljs - failed to load 124
shadow.js.jsRequire @ js.js:74
shadow$provide.<computed> @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
(anonymous) @ index.js:2
(anonymous) @ append.js:2
js.js:74 shadow-cljs - failed to load 148
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:113
(anonymous) @ index.js:2
(anonymous) @ append.js:2
index.js:5 Uncaught TypeError: $jscomp.inherits is not a function
    at Object.shadow$provide.<computed> (index.js:5)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.<computed> (index.js:5)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.<computed> (index.js:8)
    at shadow.js.jsRequire (js.js:66)
    at Object.shadow$provide.<computed> (index.js:6)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at index.js:2
shadow$provide.<computed> @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:5
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:8
shadow.js.jsRequire @ js.js:66
shadow$provide.<computed> @ index.js:6
shadow.js.jsRequire @ js.js:66
shadow.js.require @ js.js:113
(anonymous) @ index.js:2
(anonymous) @ append.js:2
favicon.ico:1 GET http://localhost:8000/favicon.ico 404 (File not found)

我创建了一个示例 repo,它尽可能简单地复制了我在这里看到的内容。

我已经尝试过清除缓存等等,如此处所述。

将优化设置为高级时,我没有遇到这个问题,但是我更随机地遇到了其他错误,更难阅读堆栈跟踪。由于这似乎是同一个问题以不同的方式出现,并且因为这更容易复制,所以我试图首先让事情在简单模式下工作。我在具有高级编译的完整应用程序中遇到的错误如下所示:

core.cljs:2564 Uncaught TypeError: pe is not a function
    at Ib (core.cljs:2564)
    at Function.wn.b (set.cljs:56)
    at Nn.g._update_watching (ratom.cljs:408)
    at yn (ratom.cljs:62)
    at Qn (ratom.cljs:539)
    at c.render (component.cljs:271)
    at kg (react-dom.production.min.js:188)
    at qi (react-dom.production.min.js:187)
    at ak (react-dom.production.min.js:270)
    at Ni (react-dom.production.min.js:251)
Ib @ core.cljs:2564
wn.b @ set.cljs:56
g._update_watching @ ratom.cljs:408
yn @ ratom.cljs:62
Qn @ ratom.cljs:539
(anonymous) @ component.cljs:271
kg @ react-dom.production.min.js:188
qi @ react-dom.production.min.js:187
ak @ react-dom.production.min.js:270
Ni @ react-dom.production.min.js:251
me @ react-dom.production.min.js:251
Ag @ react-dom.production.min.js:244
(anonymous) @ react-dom.production.min.js:124
e.unstable_runWithPriority @ scheduler.production.min.js:19
cd @ react-dom.production.min.js:123
Oh @ react-dom.production.min.js:124
uc @ react-dom.production.min.js:123
Vc @ react-dom.production.min.js:238
enqueueForceUpdate @ react-dom.production.min.js:135
r.forceUpdate @ react.production.min.js:13
g.flush_render @ batching.cljs:39
g.flush_queues @ batching.cljs:98
g.run_queues @ batching.cljs:78
a @ batching.cljs:59
requestAnimationFrame (async)
g.schedule @ batching.cljs:59
mn @ batching.cljs:52
g.queue_render @ batching.cljs:64
pn @ batching.cljs:112
Qn.d.ob.d.Ja @ ratom.cljs:544
g._handle_change @ ratom.cljs:402
Hc @ ratom.cljs:345
Cn @ ratom.cljs:104
g.ua @ ratom.cljs:146
Qc @ core.cljs:864
qf @ core.cljs:4493
(anonymous) @ lobby.cljs:53
fa @ react-dom.production.min.js:53
ma @ react-dom.production.min.js:53
wa @ react-dom.production.min.js:54
nh @ react-dom.production.min.js:101
ih @ react-dom.production.min.js:102
(anonymous) @ react-dom.production.min.js:114
$g @ react-dom.production.min.js:293
eb @ react-dom.production.min.js:51
eh @ react-dom.production.min.js:106
yb @ react-dom.production.min.js:76
ub @ react-dom.production.min.js:75
e.unstable_runWithPriority @ scheduler.production.min.js:19
cd @ react-dom.production.min.js:123
rb @ react-dom.production.min.js:293
Fb @ react-dom.production.min.js:74

有趣的是,当我打开伪名称时,这些特定的错误就会消失。

有谁知道这里发生了什么?

4

1 回答 1

3

解决此问题的最简单方法是设置:compiler-options {:output-feature-set :es6}$jscomp.inherits是由 Closure Compiler 插入的 polyfill ,用于转译class和其他更“现代”的结构。设置:es6将阻止这种情况发生。除非您需要关心古老的浏览器版本,否则这是最佳选择。

感谢您设置可重现的示例。我可以用 复制它:simple,但是将其设置为可以:advanced正常工作吗?我对正在发生的事情有一个粗略的了解:simple,并将了解如何正确修复它。

于 2021-02-24T08:54:58.520 回答