[WP] 14.02.2023 | js bundlers

 

fig 1.1 webpack bundling process scheme

----------------------------------------------------------------------

The time has come to review course notes. Before deployment of web application it need to be processed in producion build. create-react-app webpack commad is an easy way to prepare for development in react Another one is to use vercels framework Next js . Build is a further bundling of resources and dependencies removing unnecesary files/modules/packages, tree shaking and uglifying. Bundlers such as Webpack, Rollup, Vite, Browserify are responsible for bundling up application. At first bundlers need to be configurated via establishing and adjusting eg webpack.config or vite.config file Transpiling is a proces of reducing more abstract variant of language(eg JSX or TS) to simple form(eg JS).


Codebase is set of code connected with one particular project or app. It may be that codebase is represented by single github repository. ./dist folder where transpiled ts to js files are located by tsc compilation proces is named in such way because dist is an abbreviation from distribution. Cascading effect is unwanted -it reveals as repeated actions. when using next js webpack splits over routes using next js. Bundlers widely apply tools such as linters, formatting tools, transpiling tools(eg Babel).


The one new thing which i learned recently about bundlers such as webpack is that they can be used to import resoures such as images into the apps. SVG, CSS and all sorts of stuff.Example:import catSrc from „../../assets/cat.jpgs”


Rules of hooks are regulations to be followed when making use of hook within react app. First rule says that hooks cannot be used conditionally(clone the vatiable, modify and use on state setter. It is extremely important as react uses the order of the function calls to figure out which state to provide to each hook. When we render a hook conditionaly we make it possible for the hooks from one render to another.


Regards

g-marcin


Komentarze

Popularne posty z tego bloga

[WP] 23.06.2023 | subjects

15.07.2024 | simplicity

[WP] 05.06.2023 | angular-intro