ECMAScript Cookbook
上QQ阅读APP看书,第一时间看更新

Introduction

In the preceding chapter, we covered how to take advantage of the new ECMAScript modules to load code from multiple files and organize our code. This cutting-edge technique has only recently become available in browsers. In practice, production websites try to target as many users as possible. This often means targeting older browsers. In addition, JavaScript also runs in other environments (such as Node.js) that do not support ECMAScript modules.

The good news is that we don't have to change our source code in order to support these platforms. There are tools available that produce a single JavaScript file from multiple source files. This way we can use modules to organize our code, and run our programs on more platforms.

The recipes in this chapter focus on installation and configuration of webpack in order to provide a fallback option for platforms that don't support ES modules and other more recent additions to the language.