Build your own bundler, two ways手写打包器(两种写法)

Parse imports, build a dependency graph and emit one file: first as plain functions, then as a small compiler.解析 import、构建依赖图、输出一个文件;先用几个函数写,再改成一个小型编译器。

The procedural bundle logs my lord saber to the browser console. The layered bundle writes its greeting below. Both files sit next to this page in dist/.

过程式版本打出的包在浏览器控制台里打印 my lord saber。分层版打出的包把问候语写在下面。两个文件都和这个页面一起放在 dist/ 里。