Giter Club home page Giter Club logo

gulp-amd-wrap's Introduction

gulp-amd-wrap

Language Build Status Coveralls npm package npm downloads semantic-release

gulp-amd-wrap是一个分析amd模块,并进行预编译处理的的gulp插件,主要完成根据依赖分析及项目路径生成模块声明及引用的moduleID,并封装成amd规范的模块。

Install

npm i gulp-amd-wrap --save-dev

Example

import { amdWrap } from 'gulp-amd-wrap';

gulp.src(
  // 资源
  `${__dirname}\/assert/*.js`, {
      // 工程baseUrl
      base: __dirname,
    },
).pipe(amdWrap({
  baseUrl: '/assert/',
  prefix: 'wiseindex/',
  // 不参与amd-hook分析的文件
  exelude: ['/exclude-**.js', '/dist/**'],
  alias: [{
    moduleId: 'debug',
    path: 'util/debug',
    prifix: false
  }]
})).pipe(
  gulp.dest(`${__dirname}\/dist\/`),
);
// Before
define(function() {
  'use strict';

  var fishObj = {
    name: 'nimo'
  };
  var moduleA = require('@scope/moduleA');
  var moduleB = require('./moduleB');

  require(['A', './B', '/C', '@D/E', './util/debug'], function(a, b, c, d){
    console.log(a, b, c, d);
  });

  return fishObj;

});

// After
define('wiseindex/assert/minify-define', [
    'require',
    '@scope/moduleA',
    'wiseindex/assert/moduleB'
], function (require, moduleA, moduleB) {
    'use strict';
    var fishObj = { name: 'nimo' };
    require([
        'A',
        'wiseindex/assert/B',
        '/C',
        '@D/E',
        'debug'
    ], function (a, b, c, d) {
        console.log(a, b, c, d);
    });
    return fishObj;
});

API

API DOC

gulp-amd-wrap's People

Contributors

dependabot[bot] avatar lijie0981 avatar qiansc avatar semantic-release-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.