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
We list some problems of different model about loader plugin here #315,
we propose a new loader plugin api.
The Loader Plugin API are split into three parts
Loader Filter API: decide which loader apply to which module
Loader API: decide How to transform the Module
Internal Loader implementation:
Loader Filter API
{
transformers: [{include: [path.resolve(__dirname,'./src')],exclude: [path.resolve(__dirname),'./node_modules'],resourceQuery: '?loader=svg',schmea: 'data'|'http',// 'http://xxxx', or 'data:javascript,xxx',test: /\.svg/,// an rust regexassert: {type: 'css'},// import assertionuse: [require('svg-loader')(svgOptions),'jsx'],// if we pass an function it's a user implemented loader,if we pass string it is internal loader},{include: [path.resolve(__dirname,'./src')],exclude: [path.resolve(__dirname),'./node_modules'],resourceQuery: '?vue&lang=script',schmea: 'vue',// 'vue://xxxx', or 'data:javascript,xxx',test: /\.vue/,// an rust regexassert: {type: 'vue'},// import assertionuse: [require('vue-loader')(svgOptions),'...'],// ... means default loader},];}
For Most of case, test is enough
[{test: /\.svg/,use: [require('svgr)(svgOptions), 'babel']
},{test: /\.vue/,use: [require('vue-loader')(vueOptions),'...']// means default loader}]
Internal Plugin
Loader API
sharing ast
we should consider combine transform and transform_ast into one transform api, and support pass ast from transform to rspack for performance reason.
There are two kinds of ast sharing
share ast between plugin and bundler
share ast between plugin
change module type
There are two ways to change module type, parcel way setType(otherType) or webpack way set virtualResource
provide clean url
we should provide clean(unpolluted) url for plugin author like webpack, so provide resource, resourcePath, resourceQuery to plugin author
virtual module
using data url to handle virtual module other than virtual id or query
cache
Todo
sourcemap
Todo
Internal Loader implementation
There is one problem in current implementation, we put our filter logic in the transform implementation, which not works well for filter API. so we need to split the filter logic out of transform implementation.
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
-
We list some problems of different model about loader plugin here #315,
we propose a new loader plugin api.
The Loader Plugin API are split into three parts
Loader Filter API
For Most of case, test is enough
Internal Plugin
Loader API
sharing ast
we should consider combine transform and transform_ast into one transform api, and support pass ast from transform to rspack for performance reason.
There are two kinds of ast sharing
change module type
There are two ways to change module type, parcel way
setType(otherType)
or webpack way setvirtualResource
provide clean url
we should provide clean(unpolluted) url for plugin author like webpack, so provide resource, resourcePath, resourceQuery to plugin author
virtual module
using data url to handle virtual module other than virtual id or query
cache
Todo
sourcemap
Todo
Internal Loader implementation
There is one problem in current implementation, we put our filter logic in the transform implementation, which not works well for filter API. so we need to split the filter logic out of transform implementation.
Beta Was this translation helpful? Give feedback.
All reactions