Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

模块编译在有define声明的情况下修改脚本导致错误 #105

Open
kekee000 opened this issue Oct 23, 2015 · 3 comments
Open

模块编译在有define声明的情况下修改脚本导致错误 #105

kekee000 opened this issue Oct 23, 2015 · 3 comments

Comments

@kekee000
Copy link

下面这行代码:

CodeMirror.defineMode('shell', function() {
  var words = {};
  function define(style, string) {
  };

  // Atoms
  define('atom', 'true false');

编译之后:

CodeMirror.defineMode('shell', function () {
        var words = {};
        function define(style, string) {
        } ;
        define('atom', [], 'true false'); // 错误

编译之后会增加define依赖,实际上不应该改动代码
如果define的模块不是在顶级作用域定义的是不是可以不用改动代码
刚才试了下,不知道为什么配置excludes不生效,不应该扫到dep里面的非模块化代码啊

    var moduleProcessor = new ModuleCompiler({
        configFile: './module.conf',
        files: [
            'src/main.js'
        ]
    });

    var jsProcessor = new JsCompressor({
        files: [
            'src/main.js'
        ]
    });
@otakustay
Copy link
Member

不行诶,UMD就不是在顶层的,这个比较麻烦……

在 2015年10月23日,下午5:41,mkwiser [email protected] 写道:

下面这行代码:

CodeMirror.defineMode('shell', function() {
var words = {};
function define(style, string) {
};

// Atoms
define('atom', 'true false');
编译之后:

CodeMirror.defineMode('shell', function () {
var words = {};
function define(style, string) {
} ;
define('atom', [], 'true false'); // 错误
编译之后会增加define依赖,实际上不应该改动代码
如果define的模块不是在顶级作用域定义的是不是可以不用改动代码


Reply to this email directly or view it on GitHub.

@leeight
Copy link
Member

leeight commented Oct 23, 2015

edp-build处理的时候,基本上就是默认代码都是

define(function () {

})

或者

define([], function(a,b,c){

})

这种格式的。如果其它的格式也没问题,那可能是凑巧。

@errorrik
Copy link

看起来,你是不想让ModuleCompiler编译这货。

dep目录是会扫描到的(因为你import的很多package其实是amd的)。如果你不想扫描到,可以通过files去排除它们

var moduleProcessor = new ModuleCompiler({
        configFile: './module.conf',
        files: [
            '*.js',
            '!dep/CodeMirror/**/*.js'
        ]
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants