@theia/bundle-plugin 1.72.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/lib/esbuild-plugin.d.ts +30 -0
- package/lib/esbuild-plugin.d.ts.map +1 -0
- package/lib/esbuild-plugin.js +312 -0
- package/lib/esbuild-plugin.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +22 -0
- package/lib/index.js.map +1 -0
- package/lib/monaco-webpack-plugins.d.ts +5 -0
- package/lib/monaco-webpack-plugins.d.ts.map +1 -0
- package/lib/monaco-webpack-plugins.js +27 -0
- package/lib/monaco-webpack-plugins.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/lib/webpack-plugin.d.ts +21 -0
- package/lib/webpack-plugin.d.ts.map +1 -0
- package/lib/webpack-plugin.js +190 -0
- package/lib/webpack-plugin.js.map +1 -0
- package/package.json +38 -0
- package/src/esbuild-plugin.ts +336 -0
- package/src/index.ts +19 -0
- package/src/monaco-webpack-plugins.ts +25 -0
- package/src/package.spec.ts +28 -0
- package/src/webpack-plugin.ts +213 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.NativeWebpackPlugin = void 0;
|
|
19
|
+
const path = require("path");
|
|
20
|
+
const fs = require("fs");
|
|
21
|
+
const os = require("os");
|
|
22
|
+
const REQUIRE_RIPGREP = '@vscode/ripgrep';
|
|
23
|
+
const REQUIRE_BINDINGS = 'bindings';
|
|
24
|
+
const REQUIRE_PARCEL_WATCHER = './build/Release/watcher.node';
|
|
25
|
+
class NativeWebpackPlugin {
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.bindings = new Map();
|
|
28
|
+
this.options = options;
|
|
29
|
+
for (const [name, value] of Object.entries(options.nativeBindings ?? {})) {
|
|
30
|
+
this.nativeBinding(name, value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
nativeBinding(dependency, nodePath) {
|
|
34
|
+
this.bindings.set(dependency, nodePath);
|
|
35
|
+
}
|
|
36
|
+
apply(compiler) {
|
|
37
|
+
let replacements = {};
|
|
38
|
+
let nodePtyIssuer;
|
|
39
|
+
let trashHelperIssuer;
|
|
40
|
+
let ripgrepIssuer;
|
|
41
|
+
compiler.hooks.initialize.tap(NativeWebpackPlugin.name, async () => {
|
|
42
|
+
const directory = path.resolve(compiler.outputPath, 'native-webpack-plugin');
|
|
43
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
44
|
+
const bindingsFile = (issuer) => buildFile(directory, 'bindings.js', bindingsReplacement(issuer, Array.from(this.bindings.entries())));
|
|
45
|
+
const ripgrepFile = () => buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
46
|
+
replacements = {
|
|
47
|
+
...(this.options.replacements ?? {}),
|
|
48
|
+
[REQUIRE_RIPGREP]: ripgrepFile,
|
|
49
|
+
[REQUIRE_BINDINGS]: bindingsFile,
|
|
50
|
+
[REQUIRE_PARCEL_WATCHER]: issuer => Promise.resolve(findNativeWatcherFile(issuer))
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
compiler.hooks.normalModuleFactory.tap(NativeWebpackPlugin.name, nmf => {
|
|
54
|
+
nmf.hooks.beforeResolve.tapPromise(NativeWebpackPlugin.name, async (result) => {
|
|
55
|
+
if (result.request === REQUIRE_RIPGREP) {
|
|
56
|
+
ripgrepIssuer = result.contextInfo.issuer;
|
|
57
|
+
}
|
|
58
|
+
else if (result.request === 'node-pty') {
|
|
59
|
+
nodePtyIssuer = result.contextInfo.issuer;
|
|
60
|
+
}
|
|
61
|
+
else if (result.request === 'trash') {
|
|
62
|
+
trashHelperIssuer = result.contextInfo.issuer;
|
|
63
|
+
}
|
|
64
|
+
for (const [file, replacement] of Object.entries(replacements)) {
|
|
65
|
+
if (result.request === file) {
|
|
66
|
+
result.request = await replacement(result.contextInfo.issuer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
compiler.hooks.afterEmit.tapPromise(NativeWebpackPlugin.name, async () => {
|
|
72
|
+
if (this.options.trash && trashHelperIssuer) {
|
|
73
|
+
await this.copyTrashHelper(trashHelperIssuer, compiler);
|
|
74
|
+
}
|
|
75
|
+
if (this.options.ripgrep && ripgrepIssuer) {
|
|
76
|
+
await this.copyRipgrep(ripgrepIssuer, compiler);
|
|
77
|
+
}
|
|
78
|
+
if (this.options.pty && nodePtyIssuer) {
|
|
79
|
+
await this.copyNodePtyNativeDeps(nodePtyIssuer, compiler);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async copyRipgrep(issuer, compiler) {
|
|
84
|
+
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
85
|
+
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}`, { paths: [issuer] });
|
|
86
|
+
const targetFile = path.join(compiler.outputPath, this.options.out, `rg${suffix}`);
|
|
87
|
+
await this.copyExecutable(sourceFile, targetFile);
|
|
88
|
+
}
|
|
89
|
+
async copyNodePtyNativeDeps(issuer, compiler) {
|
|
90
|
+
const dist = `${process.platform}-${process.arch}`;
|
|
91
|
+
const src = `node-pty/prebuilds/${dist}`;
|
|
92
|
+
const targetDirectory = path.resolve(compiler.outputPath, '..', 'prebuilds', dist);
|
|
93
|
+
const copyFile = async (source) => {
|
|
94
|
+
const file = require.resolve(`${src}/${source}`, { paths: [issuer] });
|
|
95
|
+
const targetFile = path.join(targetDirectory, source);
|
|
96
|
+
await this.copyExecutable(file, targetFile);
|
|
97
|
+
};
|
|
98
|
+
if (process.platform === 'win32') {
|
|
99
|
+
await copyFile('conpty.node');
|
|
100
|
+
await copyFile('conpty_console_list.node');
|
|
101
|
+
await copyFile('conpty/conpty.dll');
|
|
102
|
+
await copyFile('conpty/OpenConsole.exe');
|
|
103
|
+
}
|
|
104
|
+
else if (process.platform === 'darwin') {
|
|
105
|
+
await copyFile('spawn-helper');
|
|
106
|
+
}
|
|
107
|
+
// On non-windows platforms
|
|
108
|
+
if (process.platform !== 'win32') {
|
|
109
|
+
await copyFile('pty.node');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async copyTrashHelper(issuer, compiler) {
|
|
113
|
+
let sourceFile;
|
|
114
|
+
let targetFile;
|
|
115
|
+
if (process.platform === 'win32') {
|
|
116
|
+
sourceFile = require.resolve('trash/lib/windows-trash.exe', { paths: [issuer] });
|
|
117
|
+
targetFile = path.join(compiler.outputPath, 'windows-trash.exe');
|
|
118
|
+
}
|
|
119
|
+
else if (process.platform === 'darwin') {
|
|
120
|
+
sourceFile = require.resolve('trash/lib/macos-trash', { paths: [issuer] });
|
|
121
|
+
targetFile = path.join(compiler.outputPath, 'macos-trash');
|
|
122
|
+
}
|
|
123
|
+
if (sourceFile && targetFile) {
|
|
124
|
+
await this.copyExecutable(sourceFile, targetFile);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
async copyExecutable(source, target) {
|
|
128
|
+
const targetDirectory = path.dirname(target);
|
|
129
|
+
await fs.promises.mkdir(targetDirectory, { recursive: true });
|
|
130
|
+
await fs.promises.copyFile(source, target);
|
|
131
|
+
await fs.promises.chmod(target, 0o777);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.NativeWebpackPlugin = NativeWebpackPlugin;
|
|
135
|
+
function findNativeWatcherFile(issuer) {
|
|
136
|
+
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
|
137
|
+
if (process.platform === 'linux') {
|
|
138
|
+
const { MUSL, family } = require('detect-libc');
|
|
139
|
+
if (family === MUSL) {
|
|
140
|
+
name += '-musl';
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
name += '-glibc';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return require.resolve(name, {
|
|
147
|
+
paths: [issuer]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async function buildFile(root, name, content) {
|
|
151
|
+
const tmpFile = path.join(root, name);
|
|
152
|
+
let write = true;
|
|
153
|
+
try {
|
|
154
|
+
const existing = await fs.promises.readFile(tmpFile, 'utf8');
|
|
155
|
+
if (existing === content) {
|
|
156
|
+
// prevent writing the same content again
|
|
157
|
+
// this would trigger the watch mode repeatedly
|
|
158
|
+
write = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// ignore
|
|
163
|
+
}
|
|
164
|
+
if (write) {
|
|
165
|
+
await fs.promises.writeFile(tmpFile, content);
|
|
166
|
+
}
|
|
167
|
+
return tmpFile;
|
|
168
|
+
}
|
|
169
|
+
const ripgrepReplacement = (nativePath = '.') => `
|
|
170
|
+
const path = require('path');
|
|
171
|
+
|
|
172
|
+
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
173
|
+
`;
|
|
174
|
+
const bindingsReplacement = (issuer, entries) => {
|
|
175
|
+
const cases = [];
|
|
176
|
+
for (const [module, node] of entries) {
|
|
177
|
+
const modulePath = require.resolve(node, {
|
|
178
|
+
paths: [issuer]
|
|
179
|
+
});
|
|
180
|
+
cases.push(`${' '.repeat(8)}case '${module}': return require('${modulePath.replace(/\\/g, '/')}');`);
|
|
181
|
+
}
|
|
182
|
+
return `
|
|
183
|
+
module.exports = function (jsModule) {
|
|
184
|
+
switch (jsModule) {
|
|
185
|
+
${cases.join(os.EOL)}
|
|
186
|
+
}
|
|
187
|
+
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
188
|
+
}`.trim();
|
|
189
|
+
};
|
|
190
|
+
//# sourceMappingURL=webpack-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack-plugin.js","sourceRoot":"","sources":["../src/webpack-plugin.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,6BAA6B;AAC7B,yBAAyB;AACzB,yBAAyB;AAIzB,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,sBAAsB,GAAG,8BAA8B,CAAC;AAW9D,MAAa,mBAAmB;IAK5B,YAAY,OAAmC;QAHvC,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;QAIzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,CAAC;YACvE,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;Q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ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theia/bundle-plugin",
|
|
3
|
+
"version": "1.72.0-next.11+b1c4bde4705",
|
|
4
|
+
"description": "Contains bundler plugins for Theia.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/eclipse-theia/theia.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/eclipse-theia/theia/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/eclipse-theia/theia",
|
|
17
|
+
"files": [
|
|
18
|
+
"lib",
|
|
19
|
+
"src"
|
|
20
|
+
],
|
|
21
|
+
"main": "lib/index.js",
|
|
22
|
+
"typings": "lib/index.d.ts",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "theiaext build",
|
|
25
|
+
"clean": "theiaext clean",
|
|
26
|
+
"compile": "theiaext compile",
|
|
27
|
+
"lint": "theiaext lint",
|
|
28
|
+
"test": "theiaext test",
|
|
29
|
+
"watch": "theiaext watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"detect-libc": "^2.1.2",
|
|
33
|
+
"resolve-package-path": "^4.0.3",
|
|
34
|
+
"tslib": "^2.6.2",
|
|
35
|
+
"webpack": "^5.105.4"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "b1c4bde470503b1cc20454841cf2c84ed7deb63f"
|
|
38
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2026 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import * as fs from 'fs';
|
|
19
|
+
import resolvePackagePath = require('resolve-package-path');
|
|
20
|
+
|
|
21
|
+
import type { Plugin, PluginBuild } from 'esbuild';
|
|
22
|
+
import { EOL } from 'os';
|
|
23
|
+
|
|
24
|
+
function join(...parts: string[]): string {
|
|
25
|
+
return path.join(...parts).replace(/\\/g, '/');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function resolveModulePath(module: string): string {
|
|
29
|
+
const modulePath = resolvePackagePath(module, process.cwd());
|
|
30
|
+
if (!modulePath) {
|
|
31
|
+
throw new Error('Could not resolve path of module: ' + module);
|
|
32
|
+
}
|
|
33
|
+
return path.resolve(modulePath, '..');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Redirects Monaco's nls module to Theia's localization-aware version.
|
|
38
|
+
*
|
|
39
|
+
* esbuild's `alias` option cannot be used for this because it rejects absolute paths as keys.
|
|
40
|
+
* This plugin catches both package-style imports (`@theia/monaco-editor-core/esm/vs/nls`)
|
|
41
|
+
* and relative imports from within Monaco's source tree (e.g. `../nls.js`), which are
|
|
42
|
+
* identified by the importing file residing inside `monaco-editor-core`.
|
|
43
|
+
*
|
|
44
|
+
* If `@theia/monaco` is not installed the plugin is a no-op.
|
|
45
|
+
*/
|
|
46
|
+
export function monacoNlsPlugin(): Plugin {
|
|
47
|
+
const monacoPackagePath = resolvePackagePath('@theia/monaco', process.cwd());
|
|
48
|
+
const redirectTarget = monacoPackagePath
|
|
49
|
+
? path.join(monacoPackagePath, '..', 'lib', 'browser', 'monaco-nls.js')
|
|
50
|
+
: undefined;
|
|
51
|
+
return {
|
|
52
|
+
name: 'monaco-nls',
|
|
53
|
+
setup(build: PluginBuild): void {
|
|
54
|
+
if (!redirectTarget) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
build.onResolve({ filter: /nls(\.js)?$/ }, args => {
|
|
58
|
+
if (
|
|
59
|
+
args.path.startsWith('@theia/monaco-editor-core') ||
|
|
60
|
+
args.resolveDir.includes('monaco-editor-core')
|
|
61
|
+
) {
|
|
62
|
+
return { path: redirectTarget };
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Expose bundled modules on the `globalThis['theia']` namespace, e.g.
|
|
71
|
+
* `window['theia']['@theia/core/lib/common/uri']`.
|
|
72
|
+
* Such syntax can be used by external code, for instance, for testing.
|
|
73
|
+
*
|
|
74
|
+
* This is the esbuild equivalent of the webpack `expose-loader`.
|
|
75
|
+
* It is opt-in: add it to the `plugins` array in your `esbuild.mjs` to enable it.
|
|
76
|
+
*/
|
|
77
|
+
export function exposeModulePlugin(): Plugin {
|
|
78
|
+
function findPackage(resourcePath: string): { name: string, dir: string } | undefined {
|
|
79
|
+
let dir = path.dirname(resourcePath);
|
|
80
|
+
while (true) {
|
|
81
|
+
try {
|
|
82
|
+
const { name } = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
83
|
+
if (name) {
|
|
84
|
+
return { name, dir };
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
// No package.json at this level — keep walking up.
|
|
88
|
+
}
|
|
89
|
+
const parent = path.dirname(dir);
|
|
90
|
+
if (parent === dir) {
|
|
91
|
+
return undefined; // Reached filesystem root.
|
|
92
|
+
}
|
|
93
|
+
dir = parent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
name: 'expose-module',
|
|
99
|
+
setup(build: PluginBuild): void {
|
|
100
|
+
build.onLoad({ filter: /\.js$/ }, async args => {
|
|
101
|
+
const pkg = findPackage(args.path);
|
|
102
|
+
if (!pkg) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const source = await fs.promises.readFile(args.path, 'utf8');
|
|
106
|
+
const { dir, name } = path.parse(args.path);
|
|
107
|
+
let moduleName = path.join(pkg.name, dir.substring(pkg.dir.length));
|
|
108
|
+
if (name !== 'index') {
|
|
109
|
+
moduleName = path.join(moduleName, name);
|
|
110
|
+
}
|
|
111
|
+
if (path.sep !== '/') {
|
|
112
|
+
moduleName = moduleName.split(path.sep).join('/');
|
|
113
|
+
}
|
|
114
|
+
const exposure = `\n;(globalThis['theia'] = globalThis['theia'] || {})['${moduleName}'] = (typeof module === 'object' && module.exports) || this;\n`;
|
|
115
|
+
return { contents: source + exposure, loader: 'js' };
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function problemMatcherPlugin(watch: boolean, type: string): Plugin {
|
|
122
|
+
const buildType = watch ? 'watch' : 'build';
|
|
123
|
+
const prefix = `[${buildType}/${type}]`;
|
|
124
|
+
let time = Date.now();
|
|
125
|
+
return {
|
|
126
|
+
name: 'esbuild-problem-matcher',
|
|
127
|
+
setup(build: PluginBuild): void {
|
|
128
|
+
build.onStart(() => {
|
|
129
|
+
time = Date.now();
|
|
130
|
+
console.log(prefix + ' Build started');
|
|
131
|
+
});
|
|
132
|
+
build.onEnd(result => {
|
|
133
|
+
console.log(prefix + ' Finished with ' + result.errors.length + ' errors in ' + (Date.now() - time) + 'ms.');
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export interface NativeDependenciesPluginOptions {
|
|
140
|
+
trash: boolean;
|
|
141
|
+
ripgrep: boolean;
|
|
142
|
+
pty: boolean;
|
|
143
|
+
nativeBindings: Record<string, string>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function nativeDependenciesPlugin(options: NativeDependenciesPluginOptions): Plugin {
|
|
147
|
+
const plugin = new PluginImpl(options);
|
|
148
|
+
// create wrapper object over plugin
|
|
149
|
+
// esbuild validates the plugin object and expects no additional properties
|
|
150
|
+
return {
|
|
151
|
+
name: plugin.name,
|
|
152
|
+
setup: plugin.setup.bind(plugin)
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
class PluginImpl implements Plugin {
|
|
157
|
+
|
|
158
|
+
name = '@theia/esbuild-plugin';
|
|
159
|
+
|
|
160
|
+
private bindings: Record<string, string> = {};
|
|
161
|
+
private options: NativeDependenciesPluginOptions;
|
|
162
|
+
|
|
163
|
+
constructor(options: NativeDependenciesPluginOptions) {
|
|
164
|
+
this.options = options;
|
|
165
|
+
for (const [name, value] of Object.entries(options.nativeBindings)) {
|
|
166
|
+
this.nativeBinding(name, value);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
nativeBinding(dependency: string, nodePath: string): void {
|
|
171
|
+
this.bindings[dependency] = nodePath;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
setup(build: PluginBuild): void {
|
|
175
|
+
const outdir = build.initialOptions.outdir;
|
|
176
|
+
if (!outdir) {
|
|
177
|
+
throw new Error('The `outdir` option is required.');
|
|
178
|
+
}
|
|
179
|
+
build.onResolve({ filter: /^@vscode\/windows-ca-certs$/ }, () => {
|
|
180
|
+
const windows = process.platform === 'win32';
|
|
181
|
+
return {
|
|
182
|
+
path: windows
|
|
183
|
+
? join(resolveModulePath('@vscode/windows-ca-certs'), 'build', 'Release', 'crypt32.node')
|
|
184
|
+
: '',
|
|
185
|
+
// Simply mark the dependency as external on non-Windows platforms
|
|
186
|
+
external: !windows
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
build.onResolve({ filter: /\.\/build\/Release\/keymapping$/ }, () => ({
|
|
190
|
+
path: join(resolveModulePath('native-keymap'), 'build', 'Release', 'keymapping.node'),
|
|
191
|
+
namespace: 'node-file'
|
|
192
|
+
}));
|
|
193
|
+
build.onResolve({ filter: /\.\/build\/Release\/watcher\.node$/ }, () => {
|
|
194
|
+
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
|
195
|
+
if (process.platform === 'linux') {
|
|
196
|
+
const { MUSL, family } = require('detect-libc');
|
|
197
|
+
if (family === MUSL) {
|
|
198
|
+
name += '-musl';
|
|
199
|
+
} else {
|
|
200
|
+
name += '-glibc';
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
path: join(resolveModulePath(name), 'watcher.node')
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
build.onLoad({ filter: /bindings[\\\/]bindings\.js$/ }, async () => ({
|
|
208
|
+
contents: bindingsReplacement(this.bindings),
|
|
209
|
+
loader: 'js'
|
|
210
|
+
}));
|
|
211
|
+
build.onLoad({ filter: /@vscode[\\\/]ripgrep[\\\/]lib[\\\/]index\.js$/ }, async () => ({
|
|
212
|
+
contents: 'exports.rgPath = require("path").join(__dirname, `./native/rg${process.platform === "win32" ? ".exe" : ""}`);',
|
|
213
|
+
loader: 'js'
|
|
214
|
+
}));
|
|
215
|
+
build.onLoad({ filter: /node_modules[/\\]node-pty[/\\]lib[/\\]utils\.js$/ }, async args => {
|
|
216
|
+
let contents = await fs.promises.readFile(args.path, 'utf8');
|
|
217
|
+
// node-pty's loadNativeModule() uses dynamic require() calls with paths computed
|
|
218
|
+
// at runtime (e.g. require(dir + "/" + name + ".node")). Routing them through a
|
|
219
|
+
// local alias prevents esbuild from attempting static analysis of those paths,
|
|
220
|
+
// so Node.js resolves them at runtime relative to the bundle's __dirname, where
|
|
221
|
+
// the prebuilt .node files are placed by copyNodePtySpawnHelper().
|
|
222
|
+
contents = 'const __nativePtyRequire = require;\n' + contents.replace(/\brequire\(/g, '__nativePtyRequire(');
|
|
223
|
+
return { contents, loader: 'js' };
|
|
224
|
+
});
|
|
225
|
+
build.onEnd(() => {
|
|
226
|
+
if (this.options.trash) {
|
|
227
|
+
copyTrashHelper(outdir);
|
|
228
|
+
}
|
|
229
|
+
if (this.options.ripgrep) {
|
|
230
|
+
copyRipgrep(outdir);
|
|
231
|
+
}
|
|
232
|
+
if (this.options.pty) {
|
|
233
|
+
copyNodePtySpawnHelper(outdir);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
this.setupNodeRequires(build);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
private setupNodeRequires(build: PluginBuild): void {
|
|
240
|
+
// By default, ESBuild does not handle `.node` files. We need to handle them ourselves.
|
|
241
|
+
// When using the `file` loader directly, the files only get exposed via their paths.
|
|
242
|
+
// However, we want to load them directly as native modules via `require`.
|
|
243
|
+
build.onResolve({ filter: /\.node$/, namespace: 'file' }, args => {
|
|
244
|
+
try {
|
|
245
|
+
// Move the resolved path to the `node-file` namespace to load it as a native module.
|
|
246
|
+
const resolved = require.resolve(args.path, { paths: [args.resolveDir] });
|
|
247
|
+
return {
|
|
248
|
+
path: resolved,
|
|
249
|
+
namespace: 'node-file',
|
|
250
|
+
};
|
|
251
|
+
} catch {
|
|
252
|
+
// If the module cannot be resolved, mark it as external.
|
|
253
|
+
return {
|
|
254
|
+
external: true
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
build.onLoad({ filter: /.*/, namespace: 'node-file' }, args => ({
|
|
259
|
+
// Replace the require statement with a direct require call to the native module.
|
|
260
|
+
contents: `
|
|
261
|
+
import path from ${JSON.stringify(args.path)}
|
|
262
|
+
try { module.exports = require(path) }
|
|
263
|
+
catch { throw new Error('Could not load native module from "${path.basename(args.path)}"') }
|
|
264
|
+
`,
|
|
265
|
+
}));
|
|
266
|
+
build.onResolve({ filter: /\.node$/, namespace: 'node-file' }, args => ({
|
|
267
|
+
// Finally, resolve the `.node` file to the local path.
|
|
268
|
+
path: args.path,
|
|
269
|
+
namespace: 'file',
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function copyRipgrep(outdir: string): Promise<void> {
|
|
275
|
+
const fileName = process.platform === 'win32' ? 'rg.exe' : 'rg';
|
|
276
|
+
const sourceFile = join(resolveModulePath('@vscode/ripgrep'), 'bin', fileName);
|
|
277
|
+
const targetFile = path.join(outdir, 'native', fileName);
|
|
278
|
+
await copyExecutable(sourceFile, targetFile);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
async function copyNodePtySpawnHelper(outdir: string): Promise<void> {
|
|
282
|
+
const dist = `${process.platform}-${process.arch}`;
|
|
283
|
+
const src = `node-pty/prebuilds/${dist}`;
|
|
284
|
+
const targetDirectory = path.resolve(outdir, '..', 'prebuilds', dist);
|
|
285
|
+
|
|
286
|
+
const copyFile = async (source: string): Promise<void> => {
|
|
287
|
+
const file = require.resolve(`${src}/${source}`);
|
|
288
|
+
const targetFile = path.join(targetDirectory, source);
|
|
289
|
+
await copyExecutable(file, targetFile);
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
if (process.platform === 'win32') {
|
|
293
|
+
await copyFile('conpty.node');
|
|
294
|
+
await copyFile('conpty_console_list.node');
|
|
295
|
+
await copyFile('conpty/conpty.dll');
|
|
296
|
+
await copyFile('conpty/OpenConsole.exe');
|
|
297
|
+
} else if (process.platform === 'darwin') {
|
|
298
|
+
await copyFile('spawn-helper');
|
|
299
|
+
}
|
|
300
|
+
// On non-windows platforms
|
|
301
|
+
if (process.platform !== 'win32') {
|
|
302
|
+
await copyFile('pty.node');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
async function copyTrashHelper(outdir: string): Promise<void> {
|
|
307
|
+
const fileName = process.platform === 'win32' ? 'windows-trash.exe' : 'macos-trash';
|
|
308
|
+
if (process.platform === 'win32' || process.platform === 'darwin') {
|
|
309
|
+
const sourceFile = join(resolveModulePath('trash'), 'lib', fileName);
|
|
310
|
+
const targetFile = path.join(outdir, fileName);
|
|
311
|
+
await copyExecutable(sourceFile, targetFile);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
async function copyExecutable(source: string, target: string): Promise<void> {
|
|
316
|
+
const targetDirectory = path.dirname(target);
|
|
317
|
+
await fs.promises.mkdir(targetDirectory, { recursive: true });
|
|
318
|
+
await fs.promises.copyFile(source, target);
|
|
319
|
+
await fs.promises.chmod(target, 0o777);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const bindingsReplacement = (bindings: Record<string, string>) => {
|
|
323
|
+
const cases = [];
|
|
324
|
+
|
|
325
|
+
for (const [module, node] of Object.entries(bindings)) {
|
|
326
|
+
cases.push(`${' '.repeat(8)}case '${module}': return require('${node}');`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return `
|
|
330
|
+
module.exports = function (jsModule) {
|
|
331
|
+
switch (jsModule) {
|
|
332
|
+
${cases.join(EOL)}
|
|
333
|
+
}
|
|
334
|
+
throw new Error(\`unhandled module: "\${jsModule}"\`);
|
|
335
|
+
}`.trim();
|
|
336
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export * from './esbuild-plugin';
|
|
18
|
+
export * from './webpack-plugin';
|
|
19
|
+
export * from './monaco-webpack-plugins';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import * as webpack from 'webpack';
|
|
18
|
+
|
|
19
|
+
export class MonacoWebpackPlugin {
|
|
20
|
+
apply(compiler: webpack.Compiler): void {
|
|
21
|
+
compiler.hooks.contextModuleFactory.tap('MonacoBuildPlugin', cmf => {
|
|
22
|
+
cmf.hooks.contextModuleFiles.tap('MonacoBuildPlugin', files => files.filter(file => !file.endsWith('.d.ts')));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/* note: this bogus test file is required so that
|
|
18
|
+
we are able to run mocha unit tests on this
|
|
19
|
+
package, without having any actual unit tests in it.
|
|
20
|
+
This way a coverage report will be generated,
|
|
21
|
+
showing 0% coverage, instead of no report.
|
|
22
|
+
This file can be removed once we have real unit
|
|
23
|
+
tests in place. */
|
|
24
|
+
|
|
25
|
+
describe('request package', () => {
|
|
26
|
+
|
|
27
|
+
it('should support code coverage statistics', () => true);
|
|
28
|
+
});
|