Skip to content

Instantly share code, notes, and snippets.

@azl397985856
Created January 19, 2020 03:23
Show Gist options
  • Save azl397985856/55387d3802cda476f1457021f1b6ab30 to your computer and use it in GitHub Desktop.
Save azl397985856/55387d3802cda476f1457021f1b6ab30 to your computer and use it in GitHub Desktop.

支持esm的浏览器我们可以不polyfill,反之我们才需要polyfill。 我们构建的时候需要打两份,如果将来规则更加细化,我们可以做到更加细致。当然这个东西可以做成服务化,类似polyfill.io

  • build 两次,而且只在 build 阶段做,可以用 webpack 的多配置,也可以多 webpack 实例
  • mjs 格式配 babel-preset-env 的 targets.esmodules 为 true
  • HTML部分
<script type="module" src="bundle.mjs"></script>
<script nomodule src="bundle.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment