zoukankan      html  css  js  c++  java
  • webpack bundle.js的格式

    1. 整个bundle.js打包后,是一个匿名自执行函数,参数是一个数组。

    2. 数组每一项都是一个function,function的内容就是每个模块的内容,并按照require的顺序排列。

    3. webpack的每个模块都有一个唯一的id,是从0开始递增的,其他模块通过id来引用该模块

    具体形式如下:

    // bundle.js
    /******/ (function(modules) { // webpackBootstrap
    /******/    // The module cache
    /******/    var installedModules = {};
    
    /******/    // The require function
    /******/    function __webpack_require__(moduleId) {
                    ......
    /******/    }
    
                ......
    
    /******/    return __webpack_require__(0);
    /******/ })
    /************************************************************************/
    /******/ ([
    /* 0 */
    /***/ function(module, exports, __webpack_require__) {
        //通过id引用其他模块
        var b = __webpack_require__(1);
    
        console.log('a');
    
        b.b1();
    
    
    /***/ },
    /* 1 */
    /***/ function(module, exports) {
    
        exports.b1 = function () {
          console.log('b1')
        };
    
        exports.b2 = function () {
          console.log('b2')
        };
    
    /***/ }
    /******/ ]);
  • 相关阅读:
    上传文件到七牛云
    工具类
    SpringBoot 整合 JWT Token
    JWT
    SpringBoot使用RedisTemplate整合Redis
    poj1850 Code
    洛谷P1313 计算系数
    洛谷P1602 Sramoc问题
    —Libre#2009. 「SCOI2015」小凸玩密室
    2014-9-27 NOIP模拟赛
  • 原文地址:https://www.cnblogs.com/mengff/p/12592534.html
Copyright © 2011-2022 走看看