Git Product home page Git Product logo

Comments (1)

lionellc avatar lionellc commented on September 22, 2024

webpack 从启动到结束会依次执行以下流程:

  1. 初始化: 解析 webpack 配置参数,生产 Compiler 实例
  2. 注册插件:调用插件的 apply 方法, 给插件传入 compiler 实例的引用,插件通过 compiler 调用 webpack 提供的 API,让插件可以监听后续的所有事件节点
  3. 开始编译:读取入口文件
  4. 解析文件:使用 loader 将文件解析成抽象语法树 AST
  5. 生成依赖图谱:找出每个文件的依赖项(遍历)
  6. 输出: 根据转换好的代码,生成 chunk
  7. 生成最后打包的文件

ps:由于webpack是根据依赖图动态加载所有的依赖项,所以,每个模板都可以明确表述自身的依赖,可以避免打包未使用的模块。

from web-interview.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.