Giter VIP home page Giter VIP logo

neuron-module-bundler's Introduction

Build Status

neuron-module-bundler

Usage

var builder = require('neuron-module-bundler');

builder(file, options, callback)
  .on('warn', function(message){
    console.warn(message);
  });

builder(filename, options, callback)

  • filename String the pathname of the entry file to be parsed from
  • options Object
    • pkg: Object mixed package json format of project
    • cwd: String current working directory
    • allowImplicitDependencies: Boolean=false whether allows implicit dependencies. If true and a dependency is not found in pkg, it will be treated as the latest version.
  • callback function(err, content)

callback will get err, contents and parsed as its arguments, where:

  • err Error
  • content String the parsed content

neuron-module-bundler's People

Contributors

supersheep avatar ywang1724 avatar

Watchers

Kael avatar  avatar Wei Gao avatar James Cloos avatar wesley avatar Mangix avatar Leo avatar YYY avatar  avatar  avatar  avatar

Forkers

cortexjs-legacy

neuron-module-bundler's Issues

Cannot read property 'assert' of undefined

info: cortex test in local mode
error: Cannot read property 'assert' of undefined
error: TypeError: Cannot read property 'assert' of undefined
    at /usr/local/lib/node_modules/cortex-test/node_modules/neuron-builder/index.js:150:43
    at Array.map (native)
    at Parser.resolveDependencies (/usr/local/lib/node_modules/cortex-test/node_modules/neuron-builder/index.js:145:17)
    at Parser.generateWrapingCode (/usr/local/lib/node_modules/cortex-test/node_modules/neuron-builder/index.js:66:21)
    at /usr/local/lib/node_modules/cortex-test/node_modules/neuron-builder/index.js:40:22
    at /usr/local/lib/node_modules/cortex-test/node_modules/async/lib/async.js:249:17
    at /usr/local/lib/node_modules/cortex-test/node_modules/async/lib/async.js:125:13
    at Array.forEach (native)
    at _each (/usr/local/lib/node_modules/cortex-test/node_modules/async/lib/async.js:46:24)
    at async.each (/usr/local/lib/node_modules/cortex-test/node_modules/async/lib/async.js:124:9)
ERR! Not ok, exit code: 1

pkg.dependencies may be undefined

upgrade to [email protected]

neuron.write(dest) will no longer resolve paths.

  • Save neuron.js to './neurons/neuron.js' instead of './neurons/neuron/<version>/neuron.js'

the array of dependencies should also be lowercased

  • more scenarios for test cases
  • lowercased dependencies
  • lowercased id to be defined
  • id could also be saved into a variable: '[email protected]/A.js'
(function(){
function mix(a,b){for(var k in b){a[k]=b[k]}return a}
var _0 = "[email protected]/A.js";  // >>>> HERE! <<<<
var _1 = "[email protected]/a.js";
var asyncDepsToMix = {};
define("[email protected]/index.js", [_0], function(require, exports, module, __filename, __dirname) {
'use strict';

var a = require('./A');

exports.init = function() {
  a();
};

}, {
    main:true,
    map:mix({"./A":_1}, asyncDepsToMix)
});

// >>>> HERE! <<<<
define("[email protected]/A.js", [], function(require, exports, module, __filename, __dirname) {
module.exports = function () {
  console.log('hello world');
}
}, {
    map:asyncDepsToMix
});
})();

bundled modules should maintain order

facade foo

create mod foo

try to load javascript file of foo

define foo/index.js ->

foo loaded

try to load the dependencies of foo/index.js

found that foo/index.js -> foo/a.js

try to load foo/a.js, but actually foo/a.js is defined after foo/index.js in foo.js


So it is better to maintain order

Code review

  • no try-catch
  • split logic about validation and output

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.