how to work


How it works
Parcel converts a resource tree into a bundle tree. Many other packaging tools are basically based on JavaScript resources, but also with other formats - such as strings embedded as JS files. Parcel is file type-agnostic - it will work the way you expect with any type of resource, no configuration required. Parcel’s packaging process has three steps.
1. Build resource tree
Parcel accepts a single entry resource as input, which can be any type: JS file, HTML, CSS, image, etc. There are various resource types defined in Parcel that know how to handle specific file types. Resources are parsed, their dependencies extracted, and transformed into their final compiled form. This process creates a resource tree.
2. Build the packaging tree
Once the resource tree is built, the resources are placed into the packaging file tree. Create a package for the entry resource and create a sub-package for the dynamic import(), which causes code splitting to occur.
Sibling bundles are created when importing different types of resources, for example, if you import a CSS file from JavaScript, it will be put into a sibling bundle into the corresponding JavaScript.
If a resource needs to be packaged into multiple files, it will be promoted to the nearest common ancestor in the file bundle tree so that the resource will not be packaged multiple times.
3. Packaging
After the packaging file tree is built, each package is written to the file by the packager specific to that file type. The packager knows how to merge the code for each resource into a final file that can be loaded by the browser.