Giter VIP home page Giter VIP logo

fis-kernel's Introduction

FIS Kernel

This is fis kernel.

fis-kernel's People

Contributors

2betop avatar fouber avatar hefangshi avatar jiangshuguang avatar microconan avatar oxund avatar shanyucha avatar sunqirui1987 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

Watchers

 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

fis-kernel's Issues

_.find 的性能问题

_.find 中存在一个问题,即便 设定了 exclude 某目录,但如果有 include 规则,那么会递归扫描目录下的所有文件。扫描完成后才把所有的文件按照 include、exclude 规则来过滤。

_.find = function(rPath, include, exclude, root){
    var list = [],
        path = _.realpath(rPath),
        filterPath = root ? path.substring(root.length) : path;
    if(path){
        var stat = fs.statSync(path);
        if(stat.isDirectory() && (include || _.filter(filterPath, include, exclude))){
            fs.readdirSync(path).forEach(function(p){
                if(p[0] != '.') {
                    list = list.concat(_.find(path + '/' + p, include, exclude, root));
                }
            });
        } else if(stat.isFile() && _.filter(filterPath, include, exclude)) {
            list.push(path);
        }
    } else {
        fis.log.error('unable to find [' + rPath + ']: No such file or directory.');
    }
    return list.sort();
};

在大项目中,如大规模的基于 react/angular 等的方案下,由于 node_modules 的依赖,扫描的内容将很多。特别是在 cnpm 的机制中(npminstall 的加速安装方式),依赖拉平,软链接的形式,在扫描文件的时候会直接陷入死循环状态直至内存溢出崩溃。

建议优化下处理逻辑,扫描到一个目录时,同时判断目录是否 exclude,如果 exclude 了,那么就不递归扫描该目录了。

示例(在大项目中(如 react 系列)使用 npm3)

app
├── node_modules/
└── src/
    ├── exclude/
    ├── a/
    └── b/
// root 是项目根目录
_.find(root, ['src/'], [/\/exclude/], root)

为何要对isHtmlLike, isCssLike, isJsLike 设置进行互斥呢?

现在__inline都不能愉快的工作了,编译时,不能将模板作为js文件处理,被包装成字符串了

下面是我的配置

fis.config.merge({
    roadmap : {
        path: [{
            reg : '**.tmpl',
            isHtmlLike : true,
            release : false
        }],
        ext : {
            tmpl : 'js'
        }
    }
});

源码

IndexView = MyView.extend({
    template: __inline('/template/index.tmpl'),
})

编译结果

IndexView = MyView.extend({
    template: "function(obj){\nvar __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\nwith(obj||{}){\n__p+='<header id=\"topBar\" class=\"topBar\"></header>\\n<div class=\"content clearfix\"></div>';\n}\nreturn __p;\n}",
})

npm test报错

执行自动化测试时候,遇到如下报错。报错文件在/test/ut/compile/js/expect_require.js中的require

module.js:340
throw err;
      ^
Error: Cannot find module 'js/main.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

Trying to get in touch regarding a security issue

Hey there!

I'd like to report a security issue but cannot find contact instructions on your repository.

If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

Thank you for your consideration, and I look forward to hearing from you!

(cc @huntr-helper)

不兼容高版本 node

[2023-07-17 20:12:49] TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined
[2023-07-17 20:12:49]     at Object.writeFileSync (node:fs:2239:5)
[2023-07-17 20:12:49]     at _.write (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/fis-kernel/lib/util.js:466:12)
[2023-07-17 20:12:49]     at F.save (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/fis-kernel/lib/cache.js:31:18)
[2023-07-17 20:12:49]     at Command.<anonymous> (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/fis-command-release/release.js:279:27)
[2023-07-17 20:12:49]     at Command.<anonymous> (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/commander/index.js:256:8)
[2023-07-17 20:12:49]     at Command.emit (node:events:513:28)
[2023-07-17 20:12:49]     at Command.parseArgs (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/commander/index.js:479:12)
[2023-07-17 20:12:49]     at Command.parse (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/commander/index.js:377:21)
[2023-07-17 20:12:49]     at fis.cli.run (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/fis/fis.js:136:19)
[2023-07-17 20:12:49]     at Object.<anonymous> (/root/ONLINE_SERVICE/other/ferry/task_workspace/baidu/hpbfe/usrprofile/node_modules/fis/bin/fis:3:26) {
[2023-07-17 20:12:49]   code: 'ERR_INVALID_ARG_TYPE'
[2023-07-17 20:12:49] }

记录 bug 一枚

project.js

exports.getSource = function () {
  //...
}

这个流程里面,当文件 release: false 时过滤源码,理论上来说这样的设定也对,因为都不产出了还编译个毛线;

但是在 watch 的时候没有把这些文件 exclude 掉,这时候就有可能会由于种种原因跟不 watch 时编译不一致;

关于缓存的一个问题

问题描述如下:假如我有一个test的项目,现在项目的版本号是0.1.0,项目中js中又require 文件,现在我更新项目的版本号0.2.0,并且没有修改fis-config.js, 问题出来了,js中requre的路径还是0.1.0中的,报某个模块没有找到。

办法1: 删除cache/conf或者修改fis-config.js这个文件是hash发生变化
办法2:查看源代码。发现lib/cache.js 中的 15行代码如下
this.version = fis.version;
原来问题出在这里,这里的版本号应该获取的是项目的版本号,而不是fis-kernel的版本号,修改如下
this.version = fis.config.get('version');

这样修改应该没有其它的副作用吧,楼主的建议那

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.