The project contains a list of folders of tests containing
- The same app & lib code with a different bundler per folder group
- The first name is the lib bundler and second is the app/consumer bundler
rollup-webpack
: Lib is build with Rollup and the app is built with Webpack
- Each group uses NPM workspaces
Goal: Build a tree-shakeable Vue component library and tree-shake it in a consuming Vue app.
Verification: Compile app
in production mode (Webpack) or dev mode (Rollup/Vite) and verify the output file inside app/dist
does not contain ds-switch
anywhere in the bundled output.
Library | Application |
---|---|
Webpack | Webpack |
Rollup | Webpack |
Vite | Webpack |
Webpack | Rollup |
Rollup | Rollup |
Vite | Rollup |
Webpack | Vite |
Rollup | Vite |
Webpack | Vite |
-
webpacksfc-vite: This build purpose is to try the lastest Vue Compiler to experiment with the different type of build output and attempt to tree-shake it with Vite to verify if it could be tree-shaken with Webpack library build somehow.
-
manual: Create a consuming app that would test tree-shaking with a TS functions library and a Vue component library.
See the section "Aditional Experiments" at the bottom for details on how to use these two experiments.
Each group requires to be installed individually:
$ cd rollup-vite
$ npm run install
Builds the library and creates a bundled file inside lib/dist
. In some cases multiple packages will be build in the form of UMD, ESM & CJS bundles, but not with every group.
$ cd rollup-vite
$ npm run lib
Builds the consuming application and creates a bundled file inside app/dist
.
$ cd rollup-vite
$ npm run app
Webpack clients:
In all webpack cases it allows to build in production mode too with
$ npm run prod -w app
The manual
folder contains 3 folders:
- app: Consuming app which can compile in Webpack
- Webpack:
npm run build
- Production:
npm run prod
- Webpack:
- comps: Vue component library that can be compiled in Webpack
- Webpack:
npm run build
- Webpack:
- funcs: Simple TS functions library. Used to demonstrate that normal JS functions get tree-shook by Webpack but not Vue library components. Can be compiled in Webpack & Rollup
- Wepack:
npm run build
- Rollup:
npm run build1
- Wepack:
Build all packages:
$ cd manual
$ npm run build
- The folder
app
consumes code fromfuncs
andcomps
. funcs
gets tree-shaken (Webpack bundle) byapp
, butcomps
does not with any bundler on either side.- If using a different type of
funcs
build than the defined inpackage.json
, use the full route in theimport
statement or change themain
file inside thepackage.json
file to the desired bundled file (i.edist/index.js
)
Uses latest version of (vue-loader)[https://www.npmjs.com/package/vue-loader/v/15.10.0-beta.6] that allows Vue 2.7.x support, which is the 15.10.0-beta.6
.