在 Safari 中,只有当我打开 devtools 时,我才会得到 TypeError: 模块说明符:不以 "/" 开头、"./" 或 "../"



Chrome不会出现此问题。再次注意,只有当devtools打开时,页面才会出现此错误。该软件可以工作,但我无法用Safari测试或调试它。这是一个问题,因为我将无法调查任何Safari特定的问题。

该页面基于一个three.js示例页面。以下是HTML的设置方式:

<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.139.0/build/three.module.js"
}
}
</script>
<script type="module" src="v2.js"></script>

错误为:

[Error] TypeError: Module specifier, 'three' does not start with "/", "./", or "../". Referenced from http://localhost:8000/v2.js
promiseReactionJob

根据CanIUse的说法,Safari甚至不支持导入地图。然而,这个软件实际上是有效的,所以兔子洞更深。

我现在也安装了Firefox。它的行为与Safari显示的相同,但如果devtools是打开的,就不会出现损坏。基于这个主题,esm装载机polyfill正在发挥作用。我相信可能是这样的:https://github.com/guybedford/es-module-shims

最新更新