grunt-fix-module-ids

1.0.4 • Public • Published

grunt-fix-module-ids

NPM version Downloads Dependency status Dev Dependency status Built with Grunt

Fixed module ids for systemjs modules.

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-fix-module-ids --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-fix-module-ids');

The "fix_module_ids" task

Overview

In your project's Gruntfile, add a section named fix_module_ids to the data object passed into grunt.initConfig().

grunt.initConfig({
  fix_module_ids: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.fixModuleId

Type: Function Default value:

function(moduleId, fileName) {
    return moduleId;
}

Convert module id.

options.fixModuleDepsId

Type: String Default value:

function(moduleId, fileName) {
    return moduleId;
}

Convert module dependencies.

options.appendModuleId

Type: Boolean|Function Default value: false

Append module id.

Usage Examples

var path = require('path');
 
grunt.initConfig({
  fix_module_ids: {
    options: {
        fixModuleId: function(moduleId, fileName) {
            return path.basename(fileName);;
        },
        fixModuleDepsId: function(moduleId, fileName) {
            return path.basename(fileName);;
        },
        appendModuleId: function(fileName) {
            return path.basename(fileName, '.js');
        }
    },
    files: {
      'dest/index-fixed.js': 'src/index.js'
    },
  },
});
// index.js
// Before
System.register(['./base'], function(){
    System.import('./lazy');
})
 
// After
System.register('index', ['base'], function(){
    System.import('lazy');
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Dependents (0)

Package Sidebar

Install

npm i grunt-fix-module-ids

Weekly Downloads

4

Version

1.0.4

License

none

Last publish

Collaborators

  • yinyongcom666