Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
205 views
in Technique[技术] by (71.8m points)

JavaScript module not working in Edge browser

I am having trouble with my JavaScript module in the Edge browser. In Chrome everything works perfectly. Since my users have both Edge and Chrome available to them, the application has to work in both.

I asked the question here earlier, but I failed to to provide enough code to reproduce the problem. I have now made this pen https://codepen.io/johannes1/pen/GRjBpxz, that works in Chrome but not in Edge.

In my header I have:

<script type="module" src="js/app.js"></script>

It is my understanding that ES6 modules work in Edge and chrome alike, so the mistake has to be mine, but I cannot find it. I am really stuck and would very much appreciate any insight.

question from:https://stackoverflow.com/questions/65626093/javascript-module-not-working-in-edge-browser

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Edge only supports ES6 modules in version 79 (Jan 2020) or newer.

Since Edge releases are tied to major updates to Windows 10, it is easy to get stuck on an old version.

In general I recommend that Windows users make it a point to check Windows Update for prompts to install upgrades to the OS, but that doesn't help much from the typical developer's point of view.

If you need to support old versions of Edge, then use Webpack (or one of its rivals like rollup) to bundle your modules instead of relying on browser support for them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...