You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the technical portion of the RFC. Explain the design in sufficient detail that:
Its interaction with other features is clear.
It is reasonably clear how the feature would be implemented.
Corner cases are dissected by example.
The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work.
The first stage - porting data structures
Webpack's data structures is based on object oriented programming, so there are a lot of circle references between objects.
In other words, the "references" means that the objects own each other.
There are two ways to porting data structures in Webpack
One way, we use Arc<Mutex<T>> to simulate the behaviors, which is the objects own each other.
Pros
Easy for porting
Cons
Possibility for casuing memory leak
Possibility for casuing dead lock
No guarantee for compiler
Poor performance with Arc and Mutex
The other way, we separate the representation and the storage for data. We will assign ever object a unique id to represent themselves and store the data in the other place.
The references between data will be made with id instead of the actual object.
Pros
Compiler guarantee for
No possibility for casuing memory leak
No possibility for casuing dead lock
No lock
Cons
More boilerplate code for passing the storage of data
In most case, the place for storing data will be Compilation .
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
Motivation
Adjust the output of the bundler to fit the real-world demands.
See the post to see the real-world use case.
Guide-level explanation
How to use
Reference-level explanation
This is the technical portion of the RFC. Explain the design in sufficient detail that:
The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work.
The first stage - porting data structures
Arc<Mutex<T>>
to simulate the behaviors, which is the objects own each other.Arc
andMutex
Compilation
.Rid
Rid
stand for Resource Id. I'm open to a better name.Rid
is a new type forusize
.Rid
is the unique id we are going to assign to objects.The scond stage - porting code splitting
In this stage, we will
ChunkGroup
andEntrypoint
The third stage - implment basic bundle spliiting
The four stage - align with Webpack
Drawbacks
Nope
Rationale and alternatives
Runtime rendering
Prior art
Webpack
A chinese article for studying code splitting and bundle splitting in Webpack
Swcpack
Swcpack supports name feature of bundle splitting
The implementation is different to webpack.
ChunkGroup
IMO, the current implementation of Swcpack is hard to port the bundle splitting features in Webpack
Unresolved questions
Future possibilities
Nope
Beta Was this translation helpful? Give feedback.
All reactions