Giter Site home page Giter Site logo

cube's People

Contributors

a8397550 avatar albin3 avatar alsotang avatar cctv1005s avatar cwtuan avatar elvira1112 avatar ericdum avatar fishbar avatar hqidea avatar lenzhang avatar tinysymphony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cube's Issues

support remotebase

服务端变更

  • 更改build的wraper: Cube(moduleName, [require], callback, namespace), 只影响到build环节
  • process_js 解析require中的路径 require("remote:/asdfad")
  • 引用远端脚本的文件,编译之后Cube(moduleName, [['remote', path]], callback, namespace)

客户端runtime的更改

wraper函数更新,支持namespace参数,但保持和requireJS的风格兼容

Cube(moduleName, [a, b, c], callback, namespace);

初始化增加 remoteBase 选项,该选项为Object,支持多源

Cube.init({
   ....
   remoteBase: {
     'remoteAlias': 'http://remote_real_path'
   }
   ....
});

代码合并 - 半自动

分析出整个工程的结构,自动合并一些代码, 并支持人工干预,使最终结果更准确

循环引用的问题

循环引用解法

循环引用在前端的依赖中,必须断开链路。 什么时候断开合适,看看下面的两种场景。

场景一,起始文件弱依赖

a.js

module.exports = function () {
   var b = requrie('./b');
}

b.js

var a = require('./a');
module.exports = function () {
  a.hello();
};

场景二,末尾文件弱依赖

a.js

var b = requrie('./b');
module.exports = function () {
   b();
}

b.js

module.exports = function () {
  require('./a').hello();
};

细节优化

  • node_modules 目录编译时,减少无关代码copy
  • less 编译出错时,更友好的提示信息
  • 原生模块加载时不要出现 ‘/assets${module_name}’ 这种无谓的寻址

后端忽略强制解析buildInModule

后端忽略强制解析buildInModule, 抛出warning, 但不打断请求, 模块继续输出
寻址失败的错误在模块依赖加载时触发。

cube build error: lodash

lodash模块 : lodash/fp/valueOf.js

会提示模块找不到,而valueOf.js的代码非常简单

module.exports = require('./wraperValue');

入口文件自动修复路径问题

通常情况需要传入的模块是绝对路径开头

cube.use('/test/fish.js');

这在编译出来的模块中没问题,因为编译之后的地址都是绝对地址,但是在页面的初始配置中就容易忽略,加入容错机制

cube.use('test/fish.js');  // 兼容此种场景
cube.use('./test/fish.js'); // 兼容更规范的场景

在html页面上部署cube时, Cube.use 的场景, 可以解释为 pwd = Cube.base

__filename

是否能去掉__filename, 如果引用数据,数据为对象格式,经常会报错

cube支持相对路径

base 的配置, 支持为空时,相对当前页面路径寻址文件

Cube.init({
  main: '/test.js'
  base: ''
})

编译--remote问题

viewport.js 进行第一层引用

Grid = require 'DBU_REMOTE:/com/grid/index.js'

第一层grid/index.js 在去引用第二层grid/index.jade.js

Cube("DBU_REMOTE:/com/grid/index.js",["DBU_REMOTE:/com/grid/index.jade.js"]

第二层grid/index.jade.js在编译的时候,应该也要加上DBU_REMOTE:/才对

Cube("/com/grid/index.jade.js",["jade_runtime"]

css内资源依赖问题

需要将css中的资源地址转为绝对地址, 比如:

.btn_close {
  background: url(./icon_close.png)
}

转为

.btn_close {
  background: url(/img/icon_close.png) /* abs path */
}

彻底的插件化

将现有语言的支持拆解出来,变成独立的node_module,方便用户自定义。
在开发和编译过程,都将带来一些方便

路径回归

--XX
  | --d-chart
      |-- src
           |--util
                |-- index(用underscore,找不到)
      |-- node_module
          |-- underscore (没有了)
--underscore(理应找这里)

.cubecache的清理问题

当出现极端情况的异常时,.cubecache中的代码需要被清理,需要提供一个便捷的方式。

目前设想的方案,在页面上提供一个浮动小图标,点击清理并刷新页面

前端打包压缩

希望增加前端js打包合并压缩的功能 并可以有是否uglify、css的压缩策略等压缩选项。

支持glslify等类似模块的加载

glslify等模块带有后端代码,如:
2017-02-24 4 45 31

希望有个类似于Browserify的Browserify Transform, 如下:
2017-02-24 4 45 46

或者类似Webpack的glslify-loader module。
😀

v3.0.0-beta.1

  • mock process、global, 兼容前后端一体的模块
  • build时模块智能合并,并清理require,压缩体积
  • 完善的文档,结构、用法、接口说明
  • 支持需要运行时做browserify进行转换的模块

关于前端require

cube 前端会执行函数内部并不执行的require,造成一些库不能运行

css 文件的 url()转换

打包时对 css 文件中 url(...)进行了转换,即使配置了 skip、ignore 还是没有跳过
需要增加配置运行跳过这个步骤,css 原文输出

一个异常

testcode:

Cube.use('a.js', function (a) {
   Cube.use('a.js', function () {
       // TODO something
   });
});

require(module) 参数支持变量

支持类似形式的路径分析

require('./' + variable + '.jade');
require('./path_' + variable + '/config.js');

部分支持类似形式的路径分析

async(variable + '.jade');    // 默认variable在最前的情况,为绝对路径,不做相对路径计算,只改变后缀
async(variable); // 默认为全局变量,  考虑是否嵌套方法处理变量

把执行顺序反过来

将模块的执行顺序由叶子模块->根模块修改为根模块->叶子模块

好处:无需解循环引用的问题,发生循环引用时按node的逻辑处理

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.