Skip to content

bempack/ymodules-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ymodules-loader Build Status

Webpack loader for ymodules module definitions

Getting started

npm install ymodules-loader --save-dev

Add the following into your loader list:

module: {
    loaders: [{
        test: /\.js$/,
        loader: 'ymodules-loader'
    }]
}

ProTip: add exclude: /node_modules/ if you don't need to look for that modules among vendor components

Then loader will pass through your js-files and detect all imports in ymodules format. All found dependencies would be added with require() call.

Source file

modules.define('example', ['dep1', 'dep2'], (provide, d1, d2) => {
    //...
});

Processed file

var modules = require('ym');

require('dep1/dep1');
require('dep2/dep2');

modules.define('example', ['dep1', 'dep2'], (provide, d1, d2) => {
    //...
});

After that webpack will find all your modules and put them together as well as usual CommonJS modules.

Example

See the test folder for real usage example.

Technical details

The code processing is performed by babel.

Now we are assuming that your modules placed by default bem-project structure like:

common.blocks/
├── button
│   └── button.js
├── input
│   └── input.js
└── select
    └── select.js

In future versions module path resolving will be configurable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published