@theia/native-webpack-plugin 1.56.0 → 1.57.0-next.136
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 +2 -1
- 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/native-webpack-plugin.d.ts +3 -3
- package/lib/native-webpack-plugin.d.ts.map +1 -1
- package/lib/native-webpack-plugin.js +60 -45
- package/lib/native-webpack-plugin.js.map +1 -1
- package/package.json +2 -2
- package/src/monaco-webpack-plugins.ts +26 -0
- package/src/native-webpack-plugin.ts +58 -46
package/README.md
CHANGED
|
@@ -25,5 +25,6 @@ The `@theia/native-webpack-plugin` package contains a webpack plugin that is use
|
|
|
25
25
|
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
26
26
|
|
|
27
27
|
## Trademark
|
|
28
|
+
|
|
28
29
|
"Theia" is a trademark of the Eclipse Foundation
|
|
29
|
-
https://www.eclipse.org/theia
|
|
30
|
+
<https://www.eclipse.org/theia>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-webpack-plugins.d.ts","sourceRoot":"","sources":["../src/monaco-webpack-plugins.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,qBAAa,mBAAmB;IAC5B,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,IAAI;CAM1C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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.MonacoWebpackPlugin = void 0;
|
|
19
|
+
class MonacoWebpackPlugin {
|
|
20
|
+
apply(compiler) {
|
|
21
|
+
compiler.hooks.contextModuleFactory.tap('MonacoBuildPlugin', cmf => {
|
|
22
|
+
cmf.hooks.contextModuleFiles.tap('MonacoBuildPlugin', files => files.filter(file => !file.endsWith('.d.ts')));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.MonacoWebpackPlugin = MonacoWebpackPlugin;
|
|
27
|
+
//# sourceMappingURL=monaco-webpack-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monaco-webpack-plugins.js","sourceRoot":"","sources":["../src/monaco-webpack-plugins.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;;;AAIhF,MAAa,mBAAmB;IAC5B,KAAK,CAAC,QAA0B;QAC5B,QAAQ,CAAC,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAE;YAC/D,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAElH,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAPD,kDAOC"}
|
|
@@ -13,9 +13,9 @@ export declare class NativeWebpackPlugin {
|
|
|
13
13
|
constructor(options: NativeWebpackPluginOptions);
|
|
14
14
|
nativeBinding(dependency: string, nodePath: string): void;
|
|
15
15
|
apply(compiler: Compiler): void;
|
|
16
|
-
protected copyRipgrep(compiler: Compiler): Promise<void>;
|
|
17
|
-
protected copyNodePtySpawnHelper(compiler: Compiler): Promise<void>;
|
|
18
|
-
protected copyTrashHelper(compiler: Compiler): Promise<void>;
|
|
16
|
+
protected copyRipgrep(issuer: string, compiler: Compiler): Promise<void>;
|
|
17
|
+
protected copyNodePtySpawnHelper(issuer: string, compiler: Compiler): Promise<void>;
|
|
18
|
+
protected copyTrashHelper(issuer: string, compiler: Compiler): Promise<void>;
|
|
19
19
|
protected copyExecutable(source: string, target: string): Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=native-webpack-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-webpack-plugin.d.ts","sourceRoot":"","sources":["../src/native-webpack-plugin.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQxC,MAAM,WAAW,0BAA0B;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CA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IAAI,CAAC;cAelE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMhF"}
|
|
@@ -38,91 +38,87 @@ class NativeWebpackPlugin {
|
|
|
38
38
|
}
|
|
39
39
|
apply(compiler) {
|
|
40
40
|
let replacements = {};
|
|
41
|
+
let nodePtyIssuer;
|
|
42
|
+
let trashHelperIssuer;
|
|
43
|
+
let ripgrepIssuer;
|
|
41
44
|
compiler.hooks.initialize.tap(NativeWebpackPlugin.name, async () => {
|
|
42
45
|
var _a;
|
|
43
46
|
const directory = path.resolve(compiler.outputPath, 'native-webpack-plugin');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
await fs.promises.mkdir(directory, {
|
|
51
|
-
recursive: true
|
|
52
|
-
});
|
|
53
|
-
const bindingsFile = await buildFile(directory, 'bindings.js', bindingsReplacement(Array.from(this.bindings.entries())));
|
|
54
|
-
const ripgrepFile = await buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
55
|
-
const keymappingFile = './build/Release/keymapping.node';
|
|
56
|
-
const windowsCaCertsFile = '@vscode/windows-ca-certs/build/Release/crypt32.node';
|
|
47
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
48
|
+
const bindingsFile = (issuer) => buildFile(directory, 'bindings.js', bindingsReplacement(issuer, Array.from(this.bindings.entries())));
|
|
49
|
+
const ripgrepFile = () => buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
50
|
+
const keymappingFile = () => Promise.resolve('./build/Release/keymapping.node');
|
|
51
|
+
const windowsCaCertsFile = () => Promise.resolve('@vscode/windows-ca-certs/build/Release/crypt32.node');
|
|
57
52
|
replacements = {
|
|
58
53
|
...((_a = this.options.replacements) !== null && _a !== void 0 ? _a : {}),
|
|
59
54
|
[REQUIRE_RIPGREP]: ripgrepFile,
|
|
60
55
|
[REQUIRE_BINDINGS]: bindingsFile,
|
|
61
56
|
[REQUIRE_KEYMAPPING]: keymappingFile,
|
|
62
57
|
[REQUIRE_VSCODE_WINDOWS_CA_CERTS]: windowsCaCertsFile,
|
|
63
|
-
[REQUIRE_PARCEL_WATCHER]: findNativeWatcherFile()
|
|
58
|
+
[REQUIRE_PARCEL_WATCHER]: issuer => Promise.resolve(findNativeWatcherFile(issuer))
|
|
64
59
|
};
|
|
65
60
|
});
|
|
66
61
|
compiler.hooks.normalModuleFactory.tap(NativeWebpackPlugin.name, nmf => {
|
|
67
|
-
nmf.hooks.beforeResolve.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
nmf.hooks.beforeResolve.tapPromise(NativeWebpackPlugin.name, async (result) => {
|
|
63
|
+
if (result.request === REQUIRE_RIPGREP) {
|
|
64
|
+
ripgrepIssuer = result.contextInfo.issuer;
|
|
65
|
+
}
|
|
66
|
+
else if (result.request === 'node-pty') {
|
|
67
|
+
nodePtyIssuer = result.contextInfo.issuer;
|
|
68
|
+
}
|
|
69
|
+
else if (result.request === 'trash') {
|
|
70
|
+
trashHelperIssuer = result.contextInfo.issuer;
|
|
72
71
|
}
|
|
73
|
-
});
|
|
74
|
-
nmf.hooks.afterResolve.tap(NativeWebpackPlugin.name, result => {
|
|
75
|
-
const createData = result.createData;
|
|
76
72
|
for (const [file, replacement] of Object.entries(replacements)) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
73
|
+
if (result.request === file) {
|
|
74
|
+
result.request = await replacement(result.contextInfo.issuer);
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
77
|
});
|
|
82
78
|
});
|
|
83
79
|
compiler.hooks.afterEmit.tapPromise(NativeWebpackPlugin.name, async () => {
|
|
84
|
-
if (this.options.trash) {
|
|
85
|
-
await this.copyTrashHelper(compiler);
|
|
80
|
+
if (this.options.trash && trashHelperIssuer) {
|
|
81
|
+
await this.copyTrashHelper(trashHelperIssuer, compiler);
|
|
86
82
|
}
|
|
87
|
-
if (this.options.ripgrep) {
|
|
88
|
-
await this.copyRipgrep(compiler);
|
|
83
|
+
if (this.options.ripgrep && ripgrepIssuer) {
|
|
84
|
+
await this.copyRipgrep(ripgrepIssuer, compiler);
|
|
89
85
|
}
|
|
90
|
-
if (this.options.pty) {
|
|
91
|
-
await this.copyNodePtySpawnHelper(compiler);
|
|
86
|
+
if (this.options.pty && nodePtyIssuer) {
|
|
87
|
+
await this.copyNodePtySpawnHelper(nodePtyIssuer, compiler);
|
|
92
88
|
}
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
|
-
async copyRipgrep(compiler) {
|
|
91
|
+
async copyRipgrep(issuer, compiler) {
|
|
96
92
|
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
97
|
-
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}
|
|
93
|
+
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}`, { paths: [issuer] });
|
|
98
94
|
const targetFile = path.join(compiler.outputPath, this.options.out, `rg${suffix}`);
|
|
99
95
|
await this.copyExecutable(sourceFile, targetFile);
|
|
100
96
|
}
|
|
101
|
-
async copyNodePtySpawnHelper(compiler) {
|
|
97
|
+
async copyNodePtySpawnHelper(issuer, compiler) {
|
|
102
98
|
const targetDirectory = path.resolve(compiler.outputPath, '..', 'build', 'Release');
|
|
103
99
|
if (process.platform === 'win32') {
|
|
104
|
-
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe');
|
|
100
|
+
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe', { paths: [issuer] });
|
|
105
101
|
const targetAgentFile = path.join(targetDirectory, 'winpty-agent.exe');
|
|
106
102
|
await this.copyExecutable(agentFile, targetAgentFile);
|
|
107
|
-
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
|
|
103
|
+
const dllFile = require.resolve('node-pty/build/Release/winpty.dll', { paths: [issuer] });
|
|
108
104
|
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
|
|
109
105
|
await this.copyExecutable(dllFile, targetDllFile);
|
|
110
106
|
}
|
|
111
|
-
else {
|
|
112
|
-
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
|
|
107
|
+
else if (process.platform === 'darwin') {
|
|
108
|
+
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper', { paths: [issuer] });
|
|
113
109
|
const targetFile = path.join(targetDirectory, 'spawn-helper');
|
|
114
110
|
await this.copyExecutable(sourceFile, targetFile);
|
|
115
111
|
}
|
|
116
112
|
}
|
|
117
|
-
async copyTrashHelper(compiler) {
|
|
113
|
+
async copyTrashHelper(issuer, compiler) {
|
|
118
114
|
let sourceFile;
|
|
119
115
|
let targetFile;
|
|
120
116
|
if (process.platform === 'win32') {
|
|
121
|
-
sourceFile = require.resolve('trash/lib/windows-trash.exe');
|
|
117
|
+
sourceFile = require.resolve('trash/lib/windows-trash.exe', { paths: [issuer] });
|
|
122
118
|
targetFile = path.join(compiler.outputPath, 'windows-trash.exe');
|
|
123
119
|
}
|
|
124
120
|
else if (process.platform === 'darwin') {
|
|
125
|
-
sourceFile = require.resolve('trash/lib/macos-trash');
|
|
121
|
+
sourceFile = require.resolve('trash/lib/macos-trash', { paths: [issuer] });
|
|
126
122
|
targetFile = path.join(compiler.outputPath, 'macos-trash');
|
|
127
123
|
}
|
|
128
124
|
if (sourceFile && targetFile) {
|
|
@@ -137,7 +133,7 @@ class NativeWebpackPlugin {
|
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
exports.NativeWebpackPlugin = NativeWebpackPlugin;
|
|
140
|
-
function findNativeWatcherFile() {
|
|
136
|
+
function findNativeWatcherFile(issuer) {
|
|
141
137
|
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
|
142
138
|
if (process.platform === 'linux') {
|
|
143
139
|
const { MUSL, family } = require('detect-libc');
|
|
@@ -148,11 +144,27 @@ function findNativeWatcherFile() {
|
|
|
148
144
|
name += '-glibc';
|
|
149
145
|
}
|
|
150
146
|
}
|
|
151
|
-
return require.resolve(name
|
|
147
|
+
return require.resolve(name, {
|
|
148
|
+
paths: [issuer]
|
|
149
|
+
});
|
|
152
150
|
}
|
|
153
151
|
async function buildFile(root, name, content) {
|
|
154
152
|
const tmpFile = path.join(root, name);
|
|
155
|
-
|
|
153
|
+
let write = true;
|
|
154
|
+
try {
|
|
155
|
+
const existing = await fs.promises.readFile(tmpFile, 'utf8');
|
|
156
|
+
if (existing === content) {
|
|
157
|
+
// prevent writing the same content again
|
|
158
|
+
// this would trigger the watch mode repeatedly
|
|
159
|
+
write = false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
// ignore
|
|
164
|
+
}
|
|
165
|
+
if (write) {
|
|
166
|
+
await fs.promises.writeFile(tmpFile, content);
|
|
167
|
+
}
|
|
156
168
|
return tmpFile;
|
|
157
169
|
}
|
|
158
170
|
const ripgrepReplacement = (nativePath = '.') => `
|
|
@@ -160,10 +172,13 @@ const path = require('path');
|
|
|
160
172
|
|
|
161
173
|
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
162
174
|
`;
|
|
163
|
-
const bindingsReplacement = (entries) => {
|
|
175
|
+
const bindingsReplacement = (issuer, entries) => {
|
|
164
176
|
const cases = [];
|
|
165
177
|
for (const [module, node] of entries) {
|
|
166
|
-
|
|
178
|
+
const modulePath = require.resolve(node, {
|
|
179
|
+
paths: [issuer]
|
|
180
|
+
});
|
|
181
|
+
cases.push(`${' '.repeat(8)}case '${module}': return require('${modulePath.replace(/\\/g, '/')}');`);
|
|
167
182
|
}
|
|
168
183
|
return `
|
|
169
184
|
module.exports = function (jsModule) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-webpack-plugin.js","sourceRoot":"","sources":["../src/native-webpack-plugin.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AAC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C,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,kBAAkB,GAAG,CAAC,aAAqB,GAAG,EAAU,EAAE,CAAC;;;4CAGrB,UAAU;CACrD,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,MAAc,EAAE,OAA2B,EAAU,EAAE;IAChF,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE;YACrC,KAAK,EAAE,CAAC,MAAM,CAAC;SAClB,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,MAAM,sBAAsB,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IACzG,CAAC;IAED,OAAO;;;EAGT,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;;;EAGlB,CAAC,IAAI,EAAE,CAAC;AACV,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/native-webpack-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0-next.136+9a2072774",
|
|
4
4
|
"description": "Webpack Plugin for native dependencies of Theia.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"tslib": "^2.6.2",
|
|
34
34
|
"webpack": "^5.76.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "9a20727743172a4efa46334f4136a1242b160848"
|
|
37
37
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
26
|
+
}
|
|
@@ -52,95 +52,89 @@ export class NativeWebpackPlugin {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
apply(compiler: Compiler): void {
|
|
55
|
-
let replacements: Record<string, string
|
|
55
|
+
let replacements: Record<string, (issuer: string) => Promise<string>> = {};
|
|
56
|
+
let nodePtyIssuer: string | undefined;
|
|
57
|
+
let trashHelperIssuer: string | undefined;
|
|
58
|
+
let ripgrepIssuer: string | undefined;
|
|
56
59
|
compiler.hooks.initialize.tap(NativeWebpackPlugin.name, async () => {
|
|
57
60
|
const directory = path.resolve(compiler.outputPath, 'native-webpack-plugin');
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
await fs.promises.mkdir(directory, {
|
|
65
|
-
recursive: true
|
|
66
|
-
});
|
|
67
|
-
const bindingsFile = await buildFile(directory, 'bindings.js', bindingsReplacement(Array.from(this.bindings.entries())));
|
|
68
|
-
const ripgrepFile = await buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
69
|
-
const keymappingFile = './build/Release/keymapping.node';
|
|
70
|
-
const windowsCaCertsFile = '@vscode/windows-ca-certs/build/Release/crypt32.node';
|
|
61
|
+
await fs.promises.mkdir(directory, { recursive: true });
|
|
62
|
+
const bindingsFile = (issuer: string) => buildFile(directory, 'bindings.js', bindingsReplacement(issuer, Array.from(this.bindings.entries())));
|
|
63
|
+
const ripgrepFile = () => buildFile(directory, 'ripgrep.js', ripgrepReplacement(this.options.out));
|
|
64
|
+
const keymappingFile = () => Promise.resolve('./build/Release/keymapping.node');
|
|
65
|
+
const windowsCaCertsFile = () => Promise.resolve('@vscode/windows-ca-certs/build/Release/crypt32.node');
|
|
71
66
|
replacements = {
|
|
72
67
|
...(this.options.replacements ?? {}),
|
|
73
68
|
[REQUIRE_RIPGREP]: ripgrepFile,
|
|
74
69
|
[REQUIRE_BINDINGS]: bindingsFile,
|
|
75
70
|
[REQUIRE_KEYMAPPING]: keymappingFile,
|
|
76
71
|
[REQUIRE_VSCODE_WINDOWS_CA_CERTS]: windowsCaCertsFile,
|
|
77
|
-
[REQUIRE_PARCEL_WATCHER]: findNativeWatcherFile()
|
|
72
|
+
[REQUIRE_PARCEL_WATCHER]: issuer => Promise.resolve(findNativeWatcherFile(issuer))
|
|
78
73
|
};
|
|
79
74
|
});
|
|
80
75
|
compiler.hooks.normalModuleFactory.tap(
|
|
81
76
|
NativeWebpackPlugin.name,
|
|
82
77
|
nmf => {
|
|
83
|
-
nmf.hooks.beforeResolve.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
nmf.hooks.beforeResolve.tapPromise(NativeWebpackPlugin.name, async result => {
|
|
79
|
+
if (result.request === REQUIRE_RIPGREP) {
|
|
80
|
+
ripgrepIssuer = result.contextInfo.issuer;
|
|
81
|
+
} else if (result.request === 'node-pty') {
|
|
82
|
+
nodePtyIssuer = result.contextInfo.issuer;
|
|
83
|
+
} else if (result.request === 'trash') {
|
|
84
|
+
trashHelperIssuer = result.contextInfo.issuer;
|
|
88
85
|
}
|
|
89
|
-
});
|
|
90
|
-
nmf.hooks.afterResolve.tap(NativeWebpackPlugin.name, result => {
|
|
91
|
-
const createData = result.createData;
|
|
92
86
|
for (const [file, replacement] of Object.entries(replacements)) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
87
|
+
if (result.request === file) {
|
|
88
|
+
result.request = await replacement(result.contextInfo.issuer);
|
|
95
89
|
}
|
|
96
90
|
}
|
|
97
91
|
});
|
|
98
92
|
}
|
|
99
93
|
);
|
|
100
94
|
compiler.hooks.afterEmit.tapPromise(NativeWebpackPlugin.name, async () => {
|
|
101
|
-
if (this.options.trash) {
|
|
102
|
-
await this.copyTrashHelper(compiler);
|
|
95
|
+
if (this.options.trash && trashHelperIssuer) {
|
|
96
|
+
await this.copyTrashHelper(trashHelperIssuer, compiler);
|
|
103
97
|
}
|
|
104
|
-
if (this.options.ripgrep) {
|
|
105
|
-
await this.copyRipgrep(compiler);
|
|
98
|
+
if (this.options.ripgrep && ripgrepIssuer) {
|
|
99
|
+
await this.copyRipgrep(ripgrepIssuer, compiler);
|
|
106
100
|
}
|
|
107
|
-
if (this.options.pty) {
|
|
108
|
-
await this.copyNodePtySpawnHelper(compiler);
|
|
101
|
+
if (this.options.pty && nodePtyIssuer) {
|
|
102
|
+
await this.copyNodePtySpawnHelper(nodePtyIssuer, compiler);
|
|
109
103
|
}
|
|
110
104
|
});
|
|
111
105
|
}
|
|
112
106
|
|
|
113
|
-
protected async copyRipgrep(compiler: Compiler): Promise<void> {
|
|
107
|
+
protected async copyRipgrep(issuer: string, compiler: Compiler): Promise<void> {
|
|
114
108
|
const suffix = process.platform === 'win32' ? '.exe' : '';
|
|
115
|
-
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}
|
|
109
|
+
const sourceFile = require.resolve(`@vscode/ripgrep/bin/rg${suffix}`, { paths: [issuer] });
|
|
116
110
|
const targetFile = path.join(compiler.outputPath, this.options.out, `rg${suffix}`);
|
|
117
111
|
await this.copyExecutable(sourceFile, targetFile);
|
|
118
112
|
}
|
|
119
113
|
|
|
120
|
-
protected async copyNodePtySpawnHelper(compiler: Compiler): Promise<void> {
|
|
114
|
+
protected async copyNodePtySpawnHelper(issuer: string, compiler: Compiler): Promise<void> {
|
|
121
115
|
const targetDirectory = path.resolve(compiler.outputPath, '..', 'build', 'Release');
|
|
122
116
|
if (process.platform === 'win32') {
|
|
123
|
-
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe');
|
|
117
|
+
const agentFile = require.resolve('node-pty/build/Release/winpty-agent.exe', { paths: [issuer] });
|
|
124
118
|
const targetAgentFile = path.join(targetDirectory, 'winpty-agent.exe');
|
|
125
119
|
await this.copyExecutable(agentFile, targetAgentFile);
|
|
126
|
-
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
|
|
120
|
+
const dllFile = require.resolve('node-pty/build/Release/winpty.dll', { paths: [issuer] });
|
|
127
121
|
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
|
|
128
122
|
await this.copyExecutable(dllFile, targetDllFile);
|
|
129
|
-
} else {
|
|
130
|
-
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
|
|
123
|
+
} else if (process.platform === 'darwin') {
|
|
124
|
+
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper', { paths: [issuer] });
|
|
131
125
|
const targetFile = path.join(targetDirectory, 'spawn-helper');
|
|
132
126
|
await this.copyExecutable(sourceFile, targetFile);
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
protected async copyTrashHelper(compiler: Compiler): Promise<void> {
|
|
130
|
+
protected async copyTrashHelper(issuer: string, compiler: Compiler): Promise<void> {
|
|
137
131
|
let sourceFile: string | undefined;
|
|
138
132
|
let targetFile: string | undefined;
|
|
139
133
|
if (process.platform === 'win32') {
|
|
140
|
-
sourceFile = require.resolve('trash/lib/windows-trash.exe');
|
|
134
|
+
sourceFile = require.resolve('trash/lib/windows-trash.exe', { paths: [issuer] });
|
|
141
135
|
targetFile = path.join(compiler.outputPath, 'windows-trash.exe');
|
|
142
136
|
} else if (process.platform === 'darwin') {
|
|
143
|
-
sourceFile = require.resolve('trash/lib/macos-trash');
|
|
137
|
+
sourceFile = require.resolve('trash/lib/macos-trash', { paths: [issuer] });
|
|
144
138
|
targetFile = path.join(compiler.outputPath, 'macos-trash');
|
|
145
139
|
}
|
|
146
140
|
if (sourceFile && targetFile) {
|
|
@@ -156,7 +150,7 @@ export class NativeWebpackPlugin {
|
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
152
|
|
|
159
|
-
function findNativeWatcherFile(): string {
|
|
153
|
+
function findNativeWatcherFile(issuer: string): string {
|
|
160
154
|
let name = `@parcel/watcher-${process.platform}-${process.arch}`;
|
|
161
155
|
if (process.platform === 'linux') {
|
|
162
156
|
const { MUSL, family } = require('detect-libc');
|
|
@@ -166,12 +160,27 @@ function findNativeWatcherFile(): string {
|
|
|
166
160
|
name += '-glibc';
|
|
167
161
|
}
|
|
168
162
|
}
|
|
169
|
-
return require.resolve(name
|
|
163
|
+
return require.resolve(name, {
|
|
164
|
+
paths: [issuer]
|
|
165
|
+
});
|
|
170
166
|
}
|
|
171
167
|
|
|
172
168
|
async function buildFile(root: string, name: string, content: string): Promise<string> {
|
|
173
169
|
const tmpFile = path.join(root, name);
|
|
174
|
-
|
|
170
|
+
let write = true;
|
|
171
|
+
try {
|
|
172
|
+
const existing = await fs.promises.readFile(tmpFile, 'utf8');
|
|
173
|
+
if (existing === content) {
|
|
174
|
+
// prevent writing the same content again
|
|
175
|
+
// this would trigger the watch mode repeatedly
|
|
176
|
+
write = false;
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
// ignore
|
|
180
|
+
}
|
|
181
|
+
if (write) {
|
|
182
|
+
await fs.promises.writeFile(tmpFile, content);
|
|
183
|
+
}
|
|
175
184
|
return tmpFile;
|
|
176
185
|
}
|
|
177
186
|
|
|
@@ -181,11 +190,14 @@ const path = require('path');
|
|
|
181
190
|
exports.rgPath = path.join(__dirname, \`./${nativePath}/rg\${process.platform === 'win32' ? '.exe' : ''}\`);
|
|
182
191
|
`;
|
|
183
192
|
|
|
184
|
-
const bindingsReplacement = (entries: [string, string][]): string => {
|
|
193
|
+
const bindingsReplacement = (issuer: string, entries: [string, string][]): string => {
|
|
185
194
|
const cases: string[] = [];
|
|
186
195
|
|
|
187
196
|
for (const [module, node] of entries) {
|
|
188
|
-
|
|
197
|
+
const modulePath = require.resolve(node, {
|
|
198
|
+
paths: [issuer]
|
|
199
|
+
});
|
|
200
|
+
cases.push(`${' '.repeat(8)}case '${module}': return require('${modulePath.replace(/\\/g, '/')}');`);
|
|
189
201
|
}
|
|
190
202
|
|
|
191
203
|
return `
|