forked from mirrors/gecko-dev
This used to be a node package. Let's make it become regular commonjs devtools modules. This will make it trivial to migrate this to ES Modules. Also possibly make this code become the unique layer in m-c on top of the source-map package. We no longer use webpack to build the two bundles (index.js and worker.js), instead, we are using the toolkit worker loader (require.js) in order to load all this code without any build step. As this is no longer a node package, I removed node-specific modules (assertRoot/wasmAsset) and simplify the definition of wasm file URIs as they are now fixed. Also moving the debugger to load internal "devtools/client/shared/source-map/source-map.js" module in jest as running the Web Worker instantiated by source-map/index.js is too complex. Differential Revision: https://phabricator.services.mozilla.com/D159115
58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
/* 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");
|
|
var fs = require("fs");
|
|
const rimraf = require("rimraf");
|
|
const webpack = require("webpack");
|
|
|
|
const projectPath = path.resolve(__dirname, "..");
|
|
const bundlePath = path.join(projectPath, "./dist");
|
|
const clientPath = path.join(projectPath, "../");
|
|
|
|
process.env.NODE_ENV = "production";
|
|
|
|
function moveFile(src, dest) {
|
|
if (!fs.existsSync(src)) {
|
|
return;
|
|
}
|
|
|
|
fs.copyFileSync(src, dest);
|
|
rimraf.sync(src);
|
|
}
|
|
|
|
/**
|
|
* The `bundle` module will build the following:
|
|
* - vendors.js and vendors.css:
|
|
* Bundle for all the external packages still used by the Debugger frontend.
|
|
* Source at devtools/client/debugger/src/vendors.js
|
|
* - parser-worker.js, pretty-print-worker.js, search-worker:
|
|
* Workers used only by the debugger.
|
|
* Sources at devtools/client/debugger/src/workers/*
|
|
*/
|
|
(async function bundle() {
|
|
process.env.TARGET = "firefox-panel";
|
|
process.env.OUTPUT_PATH = bundlePath;
|
|
|
|
const webpackConfig = require(path.resolve(projectPath, "webpack.config.js"));
|
|
const webpackCompiler = webpack(webpackConfig);
|
|
|
|
const result = await new Promise(resolve => {
|
|
webpackCompiler.run((error, stats) => resolve(stats));
|
|
});
|
|
|
|
if (result.hasErrors()) {
|
|
console.log(
|
|
"[bundle] Something went wrong. The error was written to assets-error.log"
|
|
);
|
|
|
|
fs.writeFileSync(
|
|
"assets-error.log",
|
|
JSON.stringify(result.toJson("verbose"), null, 2)
|
|
);
|
|
return;
|
|
}
|
|
|
|
console.log(`[bundle] Done bundling.`);
|
|
})();
|