slue-module

A tool of analyse modules relationship.

Usage no npm install needed!

<script type="module">
  import slueModule from 'https://cdn.skypack.dev/slue-module';
</script>

README

slue-module

A tool of analyse modules relationship.

API

const slueModule = require('slue-module');
let realyData = slueModule(options);

options:

{
    // the file to analyse
    filePath: './test/app.js',

    // external global variables
    externals: {
        'react': 'React'
    },

    // when exclude return true, the required module will be ignore
    exclude: function(opts) {
        return opts.moduleId == 'xxx';
    },

    // the ext names of the files which to analyse
    ext: ['.js', '.jsx', '.css', '.less', '.html'],

    // alias make module require shorter
    alias: {
        components: path.join(__dirname, './components')
    }
};

output:

{
    // file path and it's require id
    moduleList: [
        {
            id: 'xxx', // require id
            dir: 'xxx' // file path
        }
    ],

    // all handled files, used file path to be key
    handledFile: {}
};