Home Reference Source Test
import Module from 'amd-bundle/source/Module.js'
public class | source

Module

Extends:

events~EventEmitter → Module

CommonJS or AMD module

Test:

Static Method Summary

Static Public Methods
public static

Constructor Summary

Public Constructor
public

constructor(name: string, path: string, includeAll: boolean, nameMap: NameMap)

Member Summary

Public Members
public

CLI engine (Hash bang)

public

Directory path of this module

public
public get

Paths of all the dependency needed to be bundled

public

Full name of this module file

public get

Identifier of this module in JS code

public
public

source: *

Method Summary

Public Methods
public

mapName(module: string): string

public
public
Protected Methods
protected

addChild(type: string, name: string, varName: string): String

Add a depended module of this module

protected
protected
protected
protected

Static Public Methods

public static identifierOf(name: string): string source

Params:

NameTypeAttributeDescription
name string

Name of a module

Return:

string

Public Constructors

public constructor(name: string, path: string, includeAll: boolean, nameMap: NameMap) source

Params:

NameTypeAttributeDescription
name string

Path of this module

path string
  • optional
  • default: '.'

Root path of the package which this module belongs to

includeAll boolean
  • optional
  • default: false

Treat NPM modules as CommonJS modules

nameMap NameMap
  • optional

Map to replace some dependencies to others

Public Members

public CLI: String source

CLI engine (Hash bang)

public base: string source

Directory path of this module

public dependency: Object source

Properties:

NameTypeAttributeDescription
compile DependencyMap

Compile-time dependency from AMD

runtime DependencyMap

Runtime dependency from CommonJS

outside DependencyMap

Outside dependency from NPM

public get dependencyPath: string[] source

Paths of all the dependency needed to be bundled

Test:

public fileName: string source

Full name of this module file

public get identifier: string source

Identifier of this module in JS code

public nameMap: NameMap source

public source: * source

Public Methods

public mapName(module: string): string source

Params:

NameTypeAttributeDescription
module string

Module name from source code

Return:

string (nullable: true)

New module name if module is matched in the name map

Emit:

ReplaceEvent

Test:

public parse(): string source

Return:

string

Factory code of this parsed module

Test:

public toString(): string source

Return:

string

Factory code of this parsed module

Protected Methods

protected addChild(type: string, name: string, varName: string): String source

Add a depended module of this module

Params:

NameTypeAttributeDescription
type string

compile for AMD & runtime for CJS

name string

Name of a module

varName string
  • optional

Variable name of a module in another module

Return:

String (nullable: true)

Replaced module name

protected load(): string source

Return:

string

Original source code of this module

Test:

protected parseAMD(): DependencyMap source

Return:

DependencyMap

Compile-time dependency

Test:

protected parseCJS(): DependencyMap source

Return:

DependencyMap

Runtime dependency

Test:

protected searchNPM(): string source

Return:

string (nullable: true)

Entry file path of this module in ./node_modules/