diff options
Diffstat (limited to 'devtools/client/debugger/test/mochitest/examples/sourcemapped/builds/webpack4/index.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/examples/sourcemapped/builds/webpack4/index.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/examples/sourcemapped/builds/webpack4/index.js b/devtools/client/debugger/test/mochitest/examples/sourcemapped/builds/webpack4/index.js new file mode 100644 index 0000000000..a472b3bcc8 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/examples/sourcemapped/builds/webpack4/index.js @@ -0,0 +1,66 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +const path = require("path"); +const util = require("util"); +const _ = require("lodash"); +const webpack = require("webpack"); + +const TARGET_NAME = "webpack4"; + +module.exports = exports = async function(tests, dirname) { + const fixtures = []; + for (const [name, input] of tests) { + if (/babel-/.test(name)) { + continue; + } + + const testFnName = _.camelCase(`${TARGET_NAME}-${name}`); + const evalMaps = name.match(/-eval/); + + console.log(`Building ${TARGET_NAME} test ${name}`); + + const scriptPath = path.join(dirname, "output", TARGET_NAME, `${name}.js`); + await util.promisify(webpack)({ + mode: "development", + context: path.dirname(input), + entry: `./${path.basename(input)}`, + output: { + path: path.dirname(scriptPath), + filename: path.basename(scriptPath), + + devtoolModuleFilenameTemplate: `${TARGET_NAME}://./${name}/[resource-path]`, + + libraryTarget: "var", + library: testFnName, + libraryExport: "default" + }, + devtool: evalMaps ? "eval-source-map" : "source-map", + module: { + rules: [ + { + test: /\.tsx?$/, + exclude: /node_modules/, + loader: require.resolve("ts-loader"), + options: {} + } + ].filter(Boolean) + } + }); + + fixtures.push({ + name, + testFnName, + scriptPath, + assets: [scriptPath, evalMaps ? null : `${scriptPath}.map`].filter( + Boolean + ) + }); + } + + return { + target: TARGET_NAME, + fixtures + }; +}; |