diff --git a/.gitignore b/.gitignore index 19c622f..802b41f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ browserify-test/script.js browserify-test/script.map header-test/script.js header-test/script.map +webpack-test/compiled.js \ No newline at end of file diff --git a/build.js b/build.js index fdbf145..998405c 100755 --- a/build.js +++ b/build.js @@ -5,8 +5,9 @@ var path = require('path'); var querystring = require('querystring'); var child_process = require('child_process'); -var browserify = path.join('node_modules', '.bin', 'browserify'); -var coffee = path.join('node_modules', '.bin', 'coffee'); +var browserify = path.resolve(path.join('node_modules', '.bin', 'browserify')); +var webpack = path.resolve(path.join('node_modules', '.bin', 'webpack')); +var coffee = path.resolve(path.join('node_modules', '.bin', 'coffee')); function run(command, callback) { console.log(command); @@ -71,3 +72,8 @@ run(coffee + ' --map --compile header-test/script.coffee', function(error) { var contents = fs.readFileSync('header-test/script.js', 'utf8'); fs.writeFileSync('header-test/script.js', contents.replace(/\/\/# sourceMappingURL=.*/g, '')) }); + +// Build the webpack test +child_process.exec(webpack, {cwd: 'webpack-test'}, function(error) { + if (error) throw error; +}); diff --git a/package.json b/package.json index 0f8bfdf..9a8e1fe 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "browserify": "3.44.2", "coffee-script": "1.7.1", "http-server": "^0.8.5", - "mocha": "1.18.2" + "mocha": "1.18.2", + "webpack": "^1.13.3" }, "repository": { "type": "git", diff --git a/webpack-test/index.html b/webpack-test/index.html new file mode 100644 index 0000000..33520e0 --- /dev/null +++ b/webpack-test/index.html @@ -0,0 +1,5 @@ +

+Make sure to run build.js. +This test should say either "Test failed" or "Test passed": +

+ diff --git a/webpack-test/script.js b/webpack-test/script.js new file mode 100644 index 0000000..223ce6c --- /dev/null +++ b/webpack-test/script.js @@ -0,0 +1,16 @@ +require('../').install(); + +function foo() { + throw new Error('foo'); +} + +try { + foo(); +} catch (e) { + if (/\bscript\.js\b/.test(e.stack)) { + document.body.appendChild(document.createTextNode('Test passed')); + } else { + document.body.appendChild(document.createTextNode('Test failed')); + console.log(e.stack); + } +} diff --git a/webpack-test/webpack.config.js b/webpack-test/webpack.config.js new file mode 100644 index 0000000..10991c0 --- /dev/null +++ b/webpack-test/webpack.config.js @@ -0,0 +1,12 @@ +var webpack = require('webpack'); + +module.exports = { + entry: './script.js', + devtool: 'inline-source-map', + output: { + filename: 'compiled.js' + }, + resolve: { + extensions: ['', '.js'] + } +};