Skip to content

Commit 64af867

Browse files
committed
added require.js stuff, fixed progress
1 parent b0a7d77 commit 64af867

File tree

7 files changed

+41
-40
lines changed

7 files changed

+41
-40
lines changed

bin/convert-argv.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,12 @@ module.exports = function(optimist, argv, convertOptions) {
189189
if(percentage < 100) msg = " " + msg;
190190
if(percentage < 10) msg = " " + msg;
191191
}
192+
for(; chars > msg.length; chars--)
193+
process.stderr.write("\b \b");
194+
chars = msg.length;
192195
for(var i = 0; i < chars; i++)
193196
process.stderr.write("\b");
194197
process.stderr.write(msg);
195-
chars = msg.length;
196198
}));
197199
});
198200

buildin/amd-define.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1 @@
11
module.exports = function() { throw new Error("define cannot be used indirect"); };
2-
/*var amdRequire = require("!!./amd-require.js");
3-
module.exports = function(module) {
4-
function define(id, dependencies, factory) {
5-
if(typeof id != "number") {
6-
factory = dependencies;
7-
dependencies = id;
8-
id = null;
9-
}
10-
if(!factory) {
11-
factory = dependencies;
12-
dependencies = [amdRequire, module.exports, module];
13-
}
14-
var result = typeof factory == "function" ? factory.apply(null, dependencies) : factory;
15-
if(result !== undefined)
16-
module.exports = result;
17-
return module.exports;
18-
}
19-
define.amd = amdRequire.amd;
20-
return define;
21-
}*///

buildin/amd-require.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/APIPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var REPLACEMENTS = {
1616
};
1717
var IGNORES = [
1818
"call require.valueOf",
19+
"expression require.onError",
1920
];
2021
APIPlugin.prototype.apply = function(compiler) {
2122
Object.keys(REPLACEMENTS).forEach(function(key) {

lib/RequireJsStuffPlugin.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra
4+
*/
5+
var path = require("path");
6+
var ConstDependency = require("./dependencies/ConstDependency");
7+
8+
function RequireJsStuffPlugin() {
9+
}
10+
module.exports = RequireJsStuffPlugin;
11+
RequireJsStuffPlugin.prototype.apply = function(compiler) {
12+
function remove(expr) {
13+
var dep = new ConstDependency(";", expr.range);
14+
dep.loc = expr.loc;
15+
this.state.current.addDependency(dep);
16+
return true;
17+
}
18+
compiler.parser.plugin("call require.config", remove);
19+
compiler.parser.plugin("call requirejs.config", remove);
20+
21+
compiler.parser.plugin("expression require.version", function(expr) {
22+
var dep = new ConstDependency(JSON.stringify("0.0.0"), expr.range);
23+
dep.loc = expr.loc;
24+
this.state.current.addDependency(dep);
25+
return true;
26+
});
27+
compiler.parser.plugin("expression requirejs.onError", function(expr) {
28+
var dep = new ConstDependency(JSON.stringify("require.onError"), expr.range);
29+
dep.loc = expr.loc;
30+
this.state.current.addDependency(dep);
31+
return true;
32+
});
33+
};

lib/WebpackOptionsApply.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var UglifyJsPlugin = require("./optimize/UglifyJsPlugin");
2020
var ConsolePlugin = require("./ConsolePlugin");
2121
var APIPlugin = require("./APIPlugin");
2222
var ConstPlugin = require("./ConstPlugin");
23+
var RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
2324
var NodeStuffPlugin = require("./NodeStuffPlugin");
2425
var CompatibilityPlugin = require("./CompatibilityPlugin");
2526
var ProvidePlugin = require("./ProvidePlugin");
@@ -101,8 +102,9 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
101102
});
102103
}
103104
compiler.apply(
104-
new NodeStuffPlugin(),
105105
new CompatibilityPlugin(),
106+
new NodeStuffPlugin(),
107+
new RequireJsStuffPlugin(),
106108
new APIPlugin(),
107109
new ConstPlugin(),
108110
new RequireEnsurePlugin(),

test/browsertest/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ library1.on("exit", function(code) {
3636
if(code === 0) {
3737
// node ../../bin/webpack --output-pathinfo --colors --resolve-alias vm=vm-browserify --output-public-path js/ --module-bind json --module-bind css=style!css --module-bind less=style!css!less --module-bind coffee --module-bind jade ./lib/index js/web.js
3838
var main = cp.spawn("node", join(["../../bin/webpack.js", "--output-pathinfo", "--colors", "--resolve-alias", "vm=vm-browserify", "--workers",
39-
"--output-public-path", "js/", "--module-bind", "json", "--module-bind", "css=style!css", "--module-bind", "less=style!css!less", "--module-bind", "coffee", "--module-bind", "jade", "./lib/index", "js/web.js"], extraArgs));
39+
"--output-public-path", "js/", "--module-bind", "json", "--module-bind", "css=style!css", "--module-bind", "less=style!css!less", "--module-bind", "coffee", "--module-bind", "jade", "./lib/index", "js/web.js", "--progress"], extraArgs));
4040
bindOutput(main);
4141
}
4242
});

0 commit comments

Comments
 (0)