This is an experimental project and still in development. Use it on your own risk!
preprocessing-loader
This is a simple loader, it will simply pre process few of the code which wont effect the normal execution of the program in the run time. It will pre process codes like these
const a = 123;var whatsTheNumber = a;
Now this will convert into the following
const a = 123;var whatsTheNumber = 123;
Why ? as a
is const
and its value will not change in the rest of the program, We can simply change all those variables which are assign using a
with a
's value that is 123
in future release, this line
const a = 123
will be removed from the output file as it doesnt have anything to do with the program after compiling using this loader
Another example can be,
const dumyFN = { return 'demo';}; console;
This code will convert into the following
console;
Preprocessing few codes like this increases the run time of the program as the program doesn't need to jump from one part to another to get the value of the variable.
As of now, the support for pre processing is very limited with this loader, for example
const obj = { return 'value'; };
This can be converted into this
const obj = prop1: 'value';
but this loader doesnt support this. Support of this will be added in future. function bodies where the return statements are wrapped with other statements like another function or if-statement or callbacks are not supported by this loader as of now. Support of this will be added in future
Getting Started
To begin, you'll need to install preprocessing-loader
:
$ npm install preprocessing-loader --save-dev
Then add the loader to your webpack
config. For example:
webpack.config.js
moduleexports = module: rules: test: /.ext$/ use: loader: 'preprocessing-loader' options: ...options ;
And run webpack
via your preferred method.
Options
[option]
As of now, no options are available
Examples
webpack.config.js
moduleexports = entry: 'index.js' output: filename: 'bundle.js' module: rules: test: /\.js$/ use: loader: 'preprocessing-loader' ;
index.js
// Source code here...const v = 5;const z = 'a'; { console;}const tests = 5 + 2;const afn = { return v;};const fn = { return 'fn';};var a = v;let a2 = z;const fn2 = { return a2;};;; const he = // Not supportable { return 'qwe'; }; const fntest = he; // needs to cover this !!! console;console;console;console;console;;console;
bundle.js
// Bundle code here... { console;} var a = 5;let a2 = 'a'; const fn2 = { return a2;}; ;;const he = // Not supportable { return 'qwe'; };const fntest = he; // needs to cover this !!! console;console;console;console;console;;console;
Contributing
Please take a moment to read our contributing guidelines if you haven't yet done so.