[TopGrd] # _

I code something

Recent Posts

webpack 按需加载原理

published on
定义 jack.js export default () => { console.log('fafa'); }; mark.js export const val = 'sd'; export default () => { console.log('jaja'); }; index.js const name = 'jack'; import('./mark').then(mark => mark()); import('./jack').then(jack => jack()); export default name; 使用 webpack 打包 (function(modules) { // webpackBootstrap // install a JSONP callback for chunk loading function webpackJsonpCallback(data) {} // The module cache var installedModules = {}; // 用来存储加载过和加载中的 chunk // undefined = chunk not loaded, null = chunk preloaded/prefetched // Promise = chunk loading, 0 = chunk loaded var installedChunks = { main: 0, }; // script path function function jsonpScriptSrc(chunkId) { return __webpack_require__. Read More...

构造函数中的 return

published on
class Parent { constructor() { this.name = 'tom'; return { aa: 1 }; } } class Child extends Parent { constructor() { super(); this.name = 'sd'; } } const child = new Child(); console.log(child); 看下编译出的代码 var Parent = function Parent() { _classCallCheck(this, Parent); this.name = 'tom'; return { aa: 1 }; }; var Child = (function(_Parent) { _inherits(Child, _Parent); function Child() { _classCallCheck(this, Child); var _this = _possibleConstructorReturn( this, (Child. Read More...

webpack 模块化原理

published on
定义 mark.js export const val = 'sd'; export default () => { console.log('jaja'); }; index.js import mark from './mark'; const name = 'jack'; mark(); export default name; 下面的代码是 webpack 打包后生成的代码 (function(modules) { // webpackBootstrap // The module cache var installedModules = {}; // The require function function __webpack_require__(moduleId) { // Check if module is in cache if (installedModules[moduleId]) { return installedModules[moduleId].exports; } // Create a new module (and put it into the cache) var module = (installedModules[moduleId] = { i: moduleId, l: false, exports: {}, }); // Execute the module function modules[moduleId]. Read More...

Tags

medium (1) node (1) react (2) webpack (2)