Skip to content

Commit f4c2bf2

Browse files
committed
Add test support for webpack
1 parent e13f814 commit f4c2bf2

6 files changed

Lines changed: 44 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ browserify-test/script.js
77
browserify-test/script.map
88
header-test/script.js
99
header-test/script.map
10+
webpack-test/compiled.js

build.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ var path = require('path');
55
var querystring = require('querystring');
66
var child_process = require('child_process');
77

8-
var browserify = path.join('node_modules', '.bin', 'browserify');
9-
var coffee = path.join('node_modules', '.bin', 'coffee');
8+
var browserify = path.resolve(path.join('node_modules', '.bin', 'browserify'));
9+
var webpack = path.resolve(path.join('node_modules', '.bin', 'webpack'));
10+
var coffee = path.resolve(path.join('node_modules', '.bin', 'coffee'));
1011

1112
function run(command, callback) {
1213
console.log(command);
@@ -71,3 +72,8 @@ run(coffee + ' --map --compile header-test/script.coffee', function(error) {
7172
var contents = fs.readFileSync('header-test/script.js', 'utf8');
7273
fs.writeFileSync('header-test/script.js', contents.replace(/\/\/# sourceMappingURL=.*/g, ''))
7374
});
75+
76+
// Build the webpack test
77+
child_process.exec(webpack, {cwd: 'webpack-test'}, function(error) {
78+
if (error) throw error;
79+
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"browserify": "3.44.2",
1717
"coffee-script": "1.7.1",
1818
"http-server": "^0.8.5",
19-
"mocha": "1.18.2"
19+
"mocha": "1.18.2",
20+
"webpack": "^1.13.3"
2021
},
2122
"repository": {
2223
"type": "git",

webpack-test/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<p>
2+
Make sure to run build.js.
3+
This test should say either "Test failed" or "Test passed":
4+
</p>
5+
<script src="compiled.js"></script>

webpack-test/script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require('../').install();
2+
3+
function foo() {
4+
throw new Error('foo');
5+
}
6+
7+
try {
8+
foo();
9+
} catch (e) {
10+
if (/\bscript\.js\b/.test(e.stack)) {
11+
document.body.appendChild(document.createTextNode('Test passed'));
12+
} else {
13+
document.body.appendChild(document.createTextNode('Test failed'));
14+
console.log(e.stack);
15+
}
16+
}

webpack-test/webpack.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var webpack = require('webpack');
2+
3+
module.exports = {
4+
entry: './script.js',
5+
devtool: 'inline-source-map',
6+
output: {
7+
filename: 'compiled.js'
8+
},
9+
resolve: {
10+
extensions: ['', '.js']
11+
}
12+
};

0 commit comments

Comments
 (0)