In a browser that supports es6 modules these files will work out of the box. The browser will make the requests as it understands import
.
<html>
<head>
<title>ES6 modules tryout</title>
</head>
<body>
<!-- in case ES6 modules are supported -->
<script src="dist/modules/index.js" type="module"></script>
<!-- in case ES6 modules aren't support -> fallback to bundle -->
<script src="dist/bundle.js" nomodule></script>
</body>
</html>
I'm looking for a build process that creates me:
- A bundle that is transpiled for browsers that don't support es6 modules
- ->
dist/bundle.js
(minified and prod ready)
- Seperated files for browsers that support es6 modules (served then with preload and H2)
- ->
dist/modules/index.js
(minified and prod ready) - ->
dist/modules/dep-1.js
(minified and prod ready) - ->
dist/modules/dep-2.js
(minified and prod ready)