GithubHelp home page GithubHelp logo

webpack-mini's Introduction

webpack-mini

从零实现一个 JS 模块打包器

如何使用

git clone https://github.com/daweilv/webpack-mini.git

cd webpack-mini

npm i

git checkout step1

实现

一、实现一个 es6 module 打包功能

该分支实现了对 es6 module,即 import/export 语法代码的打包。执行 node webpack-mini/index.jssrc 下的代码打包成一个 bundle.js 。 代码见分支 step1,详细分析请查看文章

二、支持 commonjs 打包

es6 module 都已经啃下来了,commonjs 的 module.exports/require 就很简单了。 代码见分支 step2

三、优化

  • 模块缓存
  • 循环依赖
  • 省略后缀的文件查找

代码见分支 step3

nodejs 官网经典依赖的例子测试

main starting
a starting
b starting
in b, a.done = false
b done
in a, b.done = true
a done
in main, a.done = true, b.done = true

webpack-mini's People

Contributors

daweilv avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.