You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
913 B

  1. #!/usr/bin/env node
  2. "use strict";
  3. /* eslint-env node */
  4. // Small server whose main purpose is to ensure that both the benchmarked code
  5. // and the benchmark get passed through Babel & Browserify before they are
  6. // served to the browser.
  7. let babelify = require("babelify");
  8. let browserify = require("browserify");
  9. let express = require("express");
  10. let glob = require("glob");
  11. let logger = require("morgan");
  12. let app = express();
  13. app.use(logger("dev"));
  14. app.use(express.static(__dirname));
  15. app.use("/examples", express.static(`${__dirname}/../examples`));
  16. app.get("/bundle.js", (req, res) => {
  17. let files = glob.sync(`${__dirname}/**/*.js`, {
  18. ignore: `${__dirname}/vendor/**/*`
  19. });
  20. browserify(files)
  21. .transform(babelify, { presets: "es2015", compact: false })
  22. .bundle()
  23. .pipe(res);
  24. });
  25. app.listen(8000, () => {
  26. console.log("Benchmark server running at http://localhost:8000...");
  27. });