1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 04:35:25 +00:00
code-server-2/packages/vscode/webpack.config.bootstrap.js
Asher 72bf4547d4
Getting the client to run (#12)
* Clean up workbench and integrate initialization data

* Uncomment Electron fill

* Run server & client together

* Clean up Electron fill & patch

* Bind fs methods

This makes them usable with the promise form:
`promisify(access)(...)`.

* Add space between tag and title to browser logger

* Add typescript dep to server and default __dirname for path

* Serve web files from server

* Adjust some dev options

* Rework workbench a bit to use a class and catch unexpected errors

* No mkdirs for now, fix util fill, use bash with exec

* More fills, make general client abstract

* More fills

* Fix cp.exec

* Fix require calls in fs fill being aliased

* Create data and storage dir

* Implement fs.watch

Using exec for now.

* Implement storage database fill

* Fix os export and homedir

* Add comment to use navigator.sendBeacon

* Fix fs callbacks (some args are optional)

* Make sure data directory exists when passing it back

* Update patch

* Target es5

* More fills

* Add APIs required for bootstrap-fork to function (#15)

* Add bootstrap-fork execution

* Add createConnection

* Bundle bootstrap-fork into cli

* Remove .node directory created from spdlog

* Fix npm start

* Remove unnecessary comment

* Add webpack-hot-middleware if CLI env is not set

* Add restarting to shared process

* Fix starting with yarn
2019-02-05 11:15:50 -06:00

123 lines
3.5 KiB
JavaScript

const path = require("path");
const webpack = require("webpack");
const root = path.resolve(__dirname, "..", "..");
const fills = path.join(root, "packages", "ide", "src", "fill");
const vscodeFills = path.join(root, "packages", "vscode", "src", "fill");
const merge = require("webpack-merge");
module.exports = (env) => {
const afterCompileCommand = env && env.afterCompileCommand;
return merge(require(path.join(root, "scripts", "webpack.general.config.js"))({
typescriptCompilerOptions: {
target: "es5",
},
}), {
entry: path.join(root, "lib/vscode/src/bootstrap-fork.js"),
mode: "development",
target: "node",
externals: ["node-pty", "spdlog"],
output: {
chunkFilename: "[name].bundle.js",
path: path.resolve(__dirname, "./bin"),
publicPath: "/",
filename: "bootstrap-fork.js",
libraryTarget: "commonjs",
globalObject: "this",
},
module: {
rules: [{
loader: "string-replace-loader",
test: /\.(js|ts)$/,
options: {
multiple: [
{
search: "require\\.toUrl\\(",
replace: "requireToUrl(",
flags: "g",
},
{
search: "require\\.__\\$__nodeRequire",
replace: "require",
flags: "g",
},
],
},
}, {
loader: "string-replace-loader",
test: /vs\/loader\.js/,
options: {
multiple: [
{
search: "var recorder = moduleManager.getRecorder\\(\\);",
replace: `
var recorder = moduleManager.getRecorder();
const context = require.context("../", true, /.*/);
if (scriptSrc.indexOf("file:///") !== -1) {
const vsSrc = scriptSrc.split("file:///")[1].split(".js")[0];
if (vsSrc && vsSrc.startsWith("vs/")) {
scriptSrc = \`node|./\${vsSrc}\`;
}
}
`,
flags: "g",
},
{
search: "nodeRequire\\(",
replace: "require(",
flags: "g",
},
{
search: "moduleExports_1 = require\\(",
replace: "moduleExports_1 = context(",
flags: "g",
},
],
},
}, {
test: /\.wasm$/,
type: "javascript/auto",
}, {
// Ignore a bunch of file types we don't have loaders for. Also ignore
// test directories, some files with invalid JSON, and files we don't
// actually require but throw warnings or errors. This all seems to be a
// case of dynamic loading including things we won't require.
// This also results in the bundle being significantly smaller which
// makes uglify much faster.
test: /(\/vs\/code\/electron-main\/)|(\/test\/)|(OSSREADME\.json$)|(\.(test\.ts|test\.js|d\.ts|qwoff|node|html|txt|exe|wuff|md|sh|scpt|less)$)/,
use: ["ignore-loader"]
}],
},
resolve: {
alias: {
"gc-signals": path.join(fills, "empty.ts"),
"native-keymap": path.join(fills, "native-keymap.ts"),
"windows-process-tree": path.resolve(fills, "empty.ts"),
"electron": path.join(vscodeFills, "stdioElectron.ts"),
"vs/platform/node/product": path.resolve(vscodeFills, "product.ts"),
"vs/platform/node/package": path.resolve(vscodeFills, "package.ts"),
"vs/base/node/paths": path.resolve(vscodeFills, "paths.ts"),
"vs/base/common/amd": path.resolve(vscodeFills, "amd.ts"),
"vs": path.resolve(root, "lib/vscode/src/vs"),
},
},
resolveLoader: {
alias: {
"vs/css": path.resolve(vscodeFills, "css.js"),
},
},
plugins: [
new webpack.ProgressPlugin((percentage, msg) => {
if (percentage === 1) {
if (afterCompileCommand) {
require("child_process").execSync(afterCompileCommand, {
stdio: "inherit"
});
}
}
}),
],
});
};