0.0.3 • Published 7 years ago

private-loader v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

npm license

This is a webpack loader that handle private variables in js

From NPM:

npm install --save-dev private-loader

From GitHub:

cd path/to/node_modules
git clone https://github.com/SergiiSharpov/private-loader.git

webpack.config.js

module.exports = {
    module: {
        rules: [{
            test: /\.js$/,
            use: [ '...', 'private-loader' ],
            exclude: path.resolve(__dirname, 'node_modules')
        }]
    }
}
class Test {
    constructor() {
        this.__hello = "World";
        this.qwerty = 5;
    }

    __test() {
        return this.__hello;
    }

    get example() {
        return this.__test();
    }
}

let object = new Test();

console.log(object.__hello);// Undefined
console.log(object.example);// World
console.log(object.__test());// TypeError: object.__test is not a function
console.log(object.qwerty);// 5
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago