tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

index.js (1727B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 const path = require("path");
      6 const util = require("util");
      7 const _ = require("lodash");
      8 const webpack = require("webpack");
      9 
     10 const TARGET_NAME = "webpack3";
     11 
     12 module.exports = exports = async function(tests, dirname) {
     13  const fixtures = [];
     14  for (const [name, input] of tests) {
     15    if (/babel-/.test(name)) {
     16      continue;
     17    }
     18 
     19    const testFnName = _.camelCase(`${TARGET_NAME}-${name}`);
     20    const evalMaps = name.match(/-eval/);
     21 
     22    console.log(`Building ${TARGET_NAME} test ${name}`);
     23 
     24    const scriptPath = path.join(dirname, "output", TARGET_NAME, `${name}.js`);
     25    await util.promisify(webpack)({
     26      context: path.dirname(input),
     27      entry: `./${path.basename(input)}`,
     28      output: {
     29        path: path.dirname(scriptPath),
     30        filename: path.basename(scriptPath),
     31 
     32        devtoolModuleFilenameTemplate: `${TARGET_NAME}://./${name}/[resource-path]`,
     33 
     34        libraryTarget: "var",
     35        library: testFnName,
     36        libraryExport: "default"
     37      },
     38      devtool: evalMaps ? "eval-source-map" : "source-map",
     39      module: {
     40        loaders: [
     41          {
     42            test: /\.tsx?$/,
     43            exclude: /node_modules/,
     44            loader: require.resolve("ts-loader"),
     45            options: {}
     46          }
     47        ].filter(Boolean)
     48      }
     49    });
     50 
     51    fixtures.push({
     52      name,
     53      testFnName,
     54      scriptPath,
     55      assets: [scriptPath, evalMaps ? null : `${scriptPath}.map`].filter(
     56        Boolean
     57      )
     58    });
     59  }
     60 
     61  return {
     62    target: TARGET_NAME,
     63    fixtures
     64  };
     65 };