Git Product home page Git Product logo

wpu_webpack's Introduction

Module System

  • Reusability

    • Modul bisa digunakan kembali oleh bagian program lain atau bisa menjadi package untuk app lain.
  • Isolation

    • Satu modul mengerjakan hanya hal yang spesifik saja.
  • Organization

    • Kemudahan pengelolaan aplikasi secara keseluruhan.

No Modules (sebelum ada module)

  • Harus membuat fungsi pembungkus / wrapper function
  • Agar memiliki scope, sehingga tidak ada global variable
  • Tetap muncul function wrapper yang bisa diakses secara global
  • Kurang reusable
  • Masalah pengelolaan dependency

IIFE (Immediately Invoked Function Expression)

  • Tidak perlu membuat nama function
  • Tidak perlu menjalankan function
  • Tidak ada function yang bisa diakses secara global
  • Harus ditulis di setiap module
  • Masih bukan module system

CommonJS (Module formatting system)

  • Menggunakan keyword module.exports dan require()
  • Diterapkan di dalam nodeJS
  • Butuh module bundler jika ingin dijalankan di browser

ES6 Module (ECMAScript Harmony)

  • Menggunakan keyword exports dan import
  • Asynchronous
  • Tidak butuh module bundler jika ingin dijalankan di browser
  • Tambahkan type="module" saat pemanggilan script

Module Bundler

Sebuah tool yang mengambil code-code javascript yang kita gunakan (beserta dengan dependency-nya) dan mem-bundle/menggabungkannya menjadi sebuah file (biasanya untuk digunakan di browser).

Fungsi:

  • Melakukan penggabungan dan pengelolaan dependencies secara otomatis
  • Melakukan minify/uglify terhadap file agar ukurannya menjadi semakin kecil

Contoh:

  • browserify.org
  • webpack.js.org
  • rollupjs.org
  • parceljs.org
  • snowpack.dev
  • vitejs.dev

Fitur Webpack:

  • Dependency management
  • Hot module replacement
  • Caching
  • Supported modules: ES Modules, CommonJS, AMD Modules

Kelebihan Webpack:

  • Transpile older JS
  • Bundle CSS & Images
  • Asset optimization
  • Increase developer productivity & experience

Komponen konfigurasi Webpack:

  • Entry
  • Output
  • Mode
  • Loaders
  • Plugins
  • Browser Compatibility

Webpack Loaders

Melakukan bundle pada sumber daya statis selain javascript.

Caching

Sebuah teknik untuk menyimpan data di dalam komponen hardware atau software, dilakukan agar request (berikutnya) untuk data tersebut terjadi dengan lebih cepat.

hard refresh - Ctrl + Shift + R

๐Ÿ“Œ Useful Commits

wpu_webpack's People

Contributors

fnurrahmah125 avatar

Watchers

 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.