Merge pull request #14236 from cgatian/feat/lazy-compilation-backend-https-support

feat: add lazyCompilationBackend options
This commit is contained in:
Tobias Koppers 2021-10-25 18:12:25 +02:00 committed by GitHub
commit c55dbcb5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 427 additions and 61 deletions

View File

@ -2938,23 +2938,52 @@ export interface JavascriptParserOptions {
[k: string]: any;
}
/**
* Options for compiling entrypoints and import()s only when they are accessed.
* Options for the default backend.
*/
export interface LazyCompilationOptions {
/**
* A custom backend.
*/
backend?:
| ((
compiler: import("../lib/Compiler"),
client: string,
callback: (err?: Error, api?: any) => void
) => void)
| ((compiler: import("../lib/Compiler"), client: string) => Promise<any>);
export interface LazyCompilationDefaultBackendOptions {
/**
* A custom client.
*/
client?: string;
/**
* Specifies where to listen to from the server.
*/
listen?:
| number
| import("net").ListenOptions
| ((server: import("net").Server) => void);
/**
* Specifies the protocol the client should use to connect to the server.
*/
protocol?: "http" | "https";
/**
* Specifies how to create the server handling the EventSource requests.
*/
server?:
| (import("https").ServerOptions | import("http").ServerOptions)
| (() => import("net").Server);
}
/**
* Options for compiling entrypoints and import()s only when they are accessed.
*/
export interface LazyCompilationOptions {
/**
* Specifies the backend that should be used for handling client keep alive.
*/
backend?:
| (
| ((
compiler: import("../lib/Compiler"),
callback: (
err?: Error,
api?: import("../lib/hmr/LazyCompilationPlugin").BackendApi
) => void
) => void)
| ((
compiler: import("../lib/Compiler")
) => Promise<import("../lib/hmr/LazyCompilationPlugin").BackendApi>)
)
| LazyCompilationDefaultBackendOptions;
/**
* Enable/disable lazy compilation for entries.
*/

View File

@ -9,7 +9,9 @@ exports.keepAlive = function (options) {
var active = options.active;
var module = options.module;
var response;
var request = require("http").request(
var request = (
urlBase.startsWith("https") ? require("https") : require("http")
).request(
urlBase + data,
{
agent: false,

View File

@ -261,15 +261,18 @@ class WebpackOptionsApply extends OptionsApply {
: null;
new LazyCompilationPlugin({
backend:
(lazyOptions && lazyOptions.backend) ||
require("./hmr/lazyCompilationBackend"),
client:
(lazyOptions && lazyOptions.client) ||
require.resolve(
`../hot/lazy-compilation-${
options.externalsPresets.node ? "node" : "web"
}.js`
),
typeof lazyOptions.backend === "function"
? lazyOptions.backend
: require("./hmr/lazyCompilationBackend")({
...lazyOptions.backend,
client:
(lazyOptions.backend && lazyOptions.backend.client) ||
require.resolve(
`../hot/lazy-compilation-${
options.externalsPresets.node ? "node" : "web"
}.js`
)
}),
entries: !lazyOptions || lazyOptions.entries !== false,
imports: !lazyOptions || lazyOptions.imports !== false,
test: (lazyOptions && lazyOptions.test) || undefined

View File

@ -32,6 +32,12 @@ const { registerNotSerializable } = require("../util/serialization");
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
/**
* @typedef {Object} BackendApi
* @property {function(Error=): void} dispose
* @property {function(Module): { client: string, data: string, active: boolean }} module
*/
const IGNORED_DEPENDENCY_TYPES = new Set([
"import.meta.webpackHot.accept",
"import.meta.webpackHot.decline",
@ -303,15 +309,13 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
class LazyCompilationPlugin {
/**
* @param {Object} options options
* @param {(function(Compiler, string, function(Error?, any?): void): void) | function(Compiler, string): Promise<any>} options.backend the backend
* @param {string} options.client the client reference
* @param {(function(Compiler, function(Error?, BackendApi?): void): void) | function(Compiler): Promise<BackendApi>} options.backend the backend
* @param {boolean} options.entries true, when entries are lazy compiled
* @param {boolean} options.imports true, when import() modules are lazy compiled
* @param {RegExp | string | (function(Module): boolean)} options.test additional filter for lazy compiled entrypoint modules
*/
constructor({ backend, client, entries, imports, test }) {
constructor({ backend, entries, imports, test }) {
this.backend = backend;
this.client = client;
this.entries = entries;
this.imports = imports;
this.test = test;
@ -327,7 +331,7 @@ class LazyCompilationPlugin {
"LazyCompilationPlugin",
(params, callback) => {
if (backend !== undefined) return callback();
const promise = this.backend(compiler, this.client, (err, result) => {
const promise = this.backend(compiler, (err, result) => {
if (err) return callback(err);
backend = result;
callback();

View File

@ -5,21 +5,46 @@
"use strict";
const http = require("http");
/** @typedef {import("http").ServerOptions} HttpServerOptions */
/** @typedef {import("https").ServerOptions} HttpsServerOptions */
/** @typedef {import("../../declarations/WebpackOptions").LazyCompilationDefaultBackendOptions} LazyCompilationDefaultBackendOptions */
/** @typedef {import("../Compiler")} Compiler */
/**
* @callback BackendHandler
* @param {Compiler} compiler compiler
* @param {string} client client reference
* @param {function(Error?, any?): void} callback callback
* @returns {void}
*/
module.exports = (compiler, client, callback) => {
/**
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
* @returns {BackendHandler} backend
*/
module.exports = options => (compiler, callback) => {
const logger = compiler.getInfrastructureLogger("LazyCompilationBackend");
const activeModules = new Map();
const prefix = "/lazy-compilation-using-";
const isHttps =
options.protocol === "https" ||
(typeof options.server === "object" &&
("key" in options.server || "pfx" in options.server));
const createServer =
typeof options.server === "function"
? options.server
: (() => {
const http = isHttps ? require("https") : require("http");
return http.createServer.bind(http, options.server);
})();
const listen =
typeof options.listen === "function"
? options.listen
: server => server.listen(options.listen);
const protocol = options.protocol || (isHttps ? "https" : "http");
const requestListener = (req, res) => {
const keys = req.url.slice(prefix.length).split("@");
req.socket.on("close", () => {
@ -52,7 +77,10 @@ module.exports = (compiler, client, callback) => {
}
if (moduleActivated && compiler.watching) compiler.watching.invalidate();
};
const server = http.createServer(requestListener);
const server = /** @type {import("net").Server} */ (createServer());
server.on("request", requestListener);
let isClosing = false;
/** @type {Set<import("net").Socket>} */
const sockets = new Set();
@ -63,16 +91,19 @@ module.exports = (compiler, client, callback) => {
});
if (isClosing) socket.destroy();
});
server.listen(err => {
server.on("clientError", e => {
if (e.message !== "Server is disposing") logger.warn(e);
});
server.on("listening", err => {
if (err) return callback(err);
const addr = server.address();
if (typeof addr === "string") throw new Error("addr must not be a string");
const urlBase =
addr.address === "::" || addr.address === "0.0.0.0"
? `http://localhost:${addr.port}`
? `${protocol}://localhost:${addr.port}`
: addr.family === "IPv6"
? `http://[${addr.address}]:${addr.port}`
: `http://${addr.address}:${addr.port}`;
? `${protocol}://[${addr.address}]:${addr.port}`
: `${protocol}://${addr.address}:${addr.port}`;
logger.log(
`Server-Sent-Events server for lazy compilation open at ${urlBase}.`
);
@ -94,11 +125,12 @@ module.exports = (compiler, client, callback) => {
).replace(/%(2F|3A|24|26|2B|2C|3B|3D|3A)/g, decodeURIComponent)}`;
const active = activeModules.get(key) > 0;
return {
client: `${client}?${encodeURIComponent(urlBase + prefix)}`,
client: `${options.client}?${encodeURIComponent(urlBase + prefix)}`,
data: key,
active
};
}
});
});
listen(server);
};

File diff suppressed because one or more lines are too long

View File

@ -1615,19 +1615,85 @@
}
]
},
"LazyCompilationDefaultBackendOptions": {
"description": "Options for the default backend.",
"type": "object",
"additionalProperties": false,
"properties": {
"client": {
"description": "A custom client.",
"type": "string"
},
"listen": {
"description": "Specifies where to listen to from the server.",
"anyOf": [
{
"description": "A port.",
"type": "number"
},
{
"description": "Listen options.",
"type": "object",
"additionalProperties": true,
"properties": {
"host": {
"description": "A host.",
"type": "number"
},
"port": {
"description": "A port.",
"type": "number"
}
},
"tsType": "import(\"net\").ListenOptions"
},
{
"description": "A custom listen function.",
"instanceof": "Function",
"tsType": "((server: import(\"net\").Server) => void)"
}
]
},
"protocol": {
"description": "Specifies the protocol the client should use to connect to the server.",
"enum": ["http", "https"]
},
"server": {
"description": "Specifies how to create the server handling the EventSource requests.",
"anyOf": [
{
"description": "ServerOptions for the http or https createServer call.",
"type": "object",
"additionalProperties": true,
"properties": {},
"tsType": "(import(\"https\").ServerOptions | import(\"http\").ServerOptions)"
},
{
"description": "A custom create server function.",
"instanceof": "Function",
"tsType": "(() => import(\"net\").Server)"
}
]
}
}
},
"LazyCompilationOptions": {
"description": "Options for compiling entrypoints and import()s only when they are accessed.",
"type": "object",
"additionalProperties": false,
"properties": {
"backend": {
"description": "A custom backend.",
"instanceof": "Function",
"tsType": "(((compiler: import('../lib/Compiler'), client: string, callback: (err?: Error, api?: any) => void) => void) | ((compiler: import('../lib/Compiler'), client: string) => Promise<any>))"
},
"client": {
"description": "A custom client.",
"type": "string"
"description": "Specifies the backend that should be used for handling client keep alive.",
"anyOf": [
{
"description": "A custom backend.",
"instanceof": "Function",
"tsType": "(((compiler: import('../lib/Compiler'), callback: (err?: Error, api?: import(\"../lib/hmr/LazyCompilationPlugin\").BackendApi) => void) => void) | ((compiler: import('../lib/Compiler')) => Promise<import(\"../lib/hmr/LazyCompilationPlugin\").BackendApi>))"
},
{
"$ref": "#/definitions/LazyCompilationDefaultBackendOptions"
}
]
},
"entries": {
"description": "Enable/disable lazy compilation for entries.",

View File

@ -633,12 +633,12 @@ Object {
"multiple": false,
"simpleType": "boolean",
},
"experiments-lazy-compilation-client": Object {
"experiments-lazy-compilation-backend-client": Object {
"configs": Array [
Object {
"description": "A custom client.",
"multiple": false,
"path": "experiments.lazyCompilation.client",
"path": "experiments.lazyCompilation.backend.client",
"type": "string",
},
],
@ -646,6 +646,62 @@ Object {
"multiple": false,
"simpleType": "string",
},
"experiments-lazy-compilation-backend-listen": Object {
"configs": Array [
Object {
"description": "A port.",
"multiple": false,
"path": "experiments.lazyCompilation.backend.listen",
"type": "number",
},
],
"description": "A port.",
"multiple": false,
"simpleType": "number",
},
"experiments-lazy-compilation-backend-listen-host": Object {
"configs": Array [
Object {
"description": "A host.",
"multiple": false,
"path": "experiments.lazyCompilation.backend.listen.host",
"type": "number",
},
],
"description": "A host.",
"multiple": false,
"simpleType": "number",
},
"experiments-lazy-compilation-backend-listen-port": Object {
"configs": Array [
Object {
"description": "A port.",
"multiple": false,
"path": "experiments.lazyCompilation.backend.listen.port",
"type": "number",
},
],
"description": "A port.",
"multiple": false,
"simpleType": "number",
},
"experiments-lazy-compilation-backend-protocol": Object {
"configs": Array [
Object {
"description": "Specifies the protocol the client should use to connect to the server.",
"multiple": false,
"path": "experiments.lazyCompilation.backend.protocol",
"type": "enum",
"values": Array [
"http",
"https",
],
},
],
"description": "Specifies the protocol the client should use to connect to the server.",
"multiple": false,
"simpleType": "string",
},
"experiments-lazy-compilation-entries": Object {
"configs": Array [
Object {

View File

@ -8,7 +8,9 @@
module.exports = class EventSource {
constructor(url) {
this.response = undefined;
const request = require("http").request(
const request = (
url.startsWith("https:") ? require("https") : require("http")
).request(
url,
{
agent: false,

View File

@ -0,0 +1,30 @@
-----BEGIN CERTIFICATE-----
MIIFLzCCAxegAwIBAgIUMiqUWfKzylbMlsLgBHwuNRlTIw0wDQYJKoZIhvcNAQEL
BQAwJjEQMA4GA1UECgwHd2VicGFjazESMBAGA1UEAwwJbG9jYWxob3N0MCAXDTIx
MTAyNTEwMDkzMVoYDzIyOTUwODA5MTAwOTMxWjAmMRAwDgYDVQQKDAd3ZWJwYWNr
MRIwEAYDVQQDDAlsb2NhbGhvc3QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK
AoICAQDcb/zeGyPgXWUQnxpaawe9VfgxCgYDPrJ6hk3t6pALZk5P28szQfBYTIv4
MC7eicagYwNFEAJOHx7M1j7ZGdlE+E+qW03nt+wxAG38Nyp5nVjssqEKifSFekIJ
RHpUS1CKhVkZdjHuJWu2NhZEpstMNhJFsqixSXNA1h0Qrg2eFmeQU/Cxzi+SPBU6
ByTf/83mcGcTEXQOCEmIdH6UzUVfY4MuRSab+X3eL5DHByZ0/sMqV7SZdTy3DRoO
Cnk/swHKINSFMdSO7OdpoyRLPuOiGRuuyekg7ygTRHwhtgwusVyGl1FY0zqY5hkX
TOjVRrLEKYypY+6soWc+gwfREfXLeLoUBIkS8PbfXPTtslYLl93KSFrVuZfVhqSM
8GNPpKcA0ZMleMhL8Yy8SknYa5vRp3rdlhmoO4OnlrecmapfJx+OSslje1LKvAbt
pXpaeS0u8prabWoDeLYzLOWyHdCZv+tg0Qysks2A44Sivk/hDLunibLqGaN/3/Wt
v6F4yW+ImYMhY8PwWl6WL7dEnlsun8B7W4cevaxN9/p8r9VX3Tn6cDky1ExriiAR
ZH46PfPgFJpB/qmYvDsZDhlM9qyj9nOEn8n4iDI1bLx+xcNCnLgpgITazUZ1bWDs
JICnJ/7/pWus7b08SHLcqss85Sf1JP60K3bbtQE4dHQEeyrHvwIDAQABo1MwUTAd
BgNVHQ4EFgQUiX//tMNp8PHMF90BqT4hmASz6D8wHwYDVR0jBBgwFoAUiX//tMNp
8PHMF90BqT4hmASz6D8wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC
AgEA0vtA2k9VPphfPU7svcjyEkOqt4zDyvQNjpuZesGpAjmM0cPG+/4jvL2rOTek
ClOKtwjYrm+WxmAcwOGz9bI6zeAjD1RPVr1pmQ5l+AXVCDNSKHNwGgfC69u4Pr4a
xOElBjNSh+nahZa1CYvHgfqddn/REiO6b+GUdk540d+DIR9g3WHaSofjQ541skqV
44iveDCLFzEQsJ8wh5ESHNvdp6VHKQEaTyXZep3heStjvUk9LKm7/wK8R6K4riVb
OLsgd/Edx6AEJEUHs5iHcqnn6PSWDsAbqCSSYUxTv8gPERAofMg/Gy1W20T3+Xsf
fLJm4nGhjy3IIIf8L+A95onSkArdyrejHIzNvpmxrWVGVXoc5GEqFd9jPhnAIy6o
mm9clKFbRSTI/NdqpSnVvWzDucqukACU8Tjl+cnWNEhEx/qTMITMJ0Pdih+/2I3S
3z4WmUlPoBb2Xj9TFZ63SFTk/W7o2vtR7k7YkROAiYudnsyyofmJNNqx7m6fbEEi
gzbOSvMrwT1F66HitmO6vm1WwH9ig0sMpGXRq+S2/5tf2OPEuvJiChJ126Ocqr5X
BbeSicG0avgXcIMYv6YaG1MIkV2XJ8vIIaLX1ZrevFaVW0/Jq9/HDeNxuVZaKAFm
s/OsWVidX2wVDFzxBflyCG2ITbx87IsBpE/7juG+PSARjqg=
-----END CERTIFICATE-----

View File

@ -0,0 +1,36 @@
// Avoid errors because of self-signed certificate
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
it("should compile to lazy imported module", done => {
let resolved;
const promise = import("./module").then(r => (resolved = r));
let generation = 0;
import.meta.webpackHot.accept("./module", () => {
generation++;
});
expect(resolved).toBe(undefined);
setTimeout(() => {
expect(resolved).toBe(undefined);
expect(generation).toBe(0);
NEXT(
require("../../update")(done, true, () => {
promise.then(result => {
expect(result).toHaveProperty("default", 42);
expect(generation).toBe(0);
NEXT(
require("../../update")(done, true, () => {
expect(result).toHaveProperty("default", 42);
expect(generation).toBe(1);
import("./module").then(result => {
expect(result).toHaveProperty("default", 43);
setTimeout(() => {
done();
}, 1000);
}, done);
})
);
}, done);
})
);
}, 1000);
});

View File

@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQDcb/zeGyPgXWUQ
nxpaawe9VfgxCgYDPrJ6hk3t6pALZk5P28szQfBYTIv4MC7eicagYwNFEAJOHx7M
1j7ZGdlE+E+qW03nt+wxAG38Nyp5nVjssqEKifSFekIJRHpUS1CKhVkZdjHuJWu2
NhZEpstMNhJFsqixSXNA1h0Qrg2eFmeQU/Cxzi+SPBU6ByTf/83mcGcTEXQOCEmI
dH6UzUVfY4MuRSab+X3eL5DHByZ0/sMqV7SZdTy3DRoOCnk/swHKINSFMdSO7Odp
oyRLPuOiGRuuyekg7ygTRHwhtgwusVyGl1FY0zqY5hkXTOjVRrLEKYypY+6soWc+
gwfREfXLeLoUBIkS8PbfXPTtslYLl93KSFrVuZfVhqSM8GNPpKcA0ZMleMhL8Yy8
SknYa5vRp3rdlhmoO4OnlrecmapfJx+OSslje1LKvAbtpXpaeS0u8prabWoDeLYz
LOWyHdCZv+tg0Qysks2A44Sivk/hDLunibLqGaN/3/Wtv6F4yW+ImYMhY8PwWl6W
L7dEnlsun8B7W4cevaxN9/p8r9VX3Tn6cDky1ExriiARZH46PfPgFJpB/qmYvDsZ
DhlM9qyj9nOEn8n4iDI1bLx+xcNCnLgpgITazUZ1bWDsJICnJ/7/pWus7b08SHLc
qss85S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pT0MYIjuT+sc09IECECSNk4eWEjFUuqcb
4FKPdlsYP+NUnHHTwaLyPkCI3YYEX/tQpymnjoM75IwDa/zycNJu7/49SYS9kTQS
pSOwzmM64pTxlBEbaKbsLzTk6Kh7Rx029cMe2wKYMKSpZ4psm+q287qBP4TcTYWR
Ol7T8PYSoHaHUNvzYtXhyiwx/wMWjTweLl56ItCS3QQ6KHEAcHRFJF1qiWMmOJBA
00mSIlsCHoG0u3dn3UU4CuibO8z/y8tX8/WlgwcWTvnc+eR+mtkDTxAV6o8LvKxR
j23uAFMMHV6/+WMYg9tmoSEnn0Mp
-----END PRIVATE KEY-----

View File

@ -0,0 +1,5 @@
export default 42;
---
export default 42;
---
export default 43;

View File

@ -0,0 +1,19 @@
"use strict";
const fs = require("fs");
const path = require("path");
/** @type {import("../../../../").Configuration} */
module.exports = {
experiments: {
lazyCompilation: {
entries: false,
backend: {
server: {
key: fs.readFileSync(path.join(__dirname, "key.pem")),
cert: fs.readFileSync(path.join(__dirname, "cert.pem"))
}
}
}
}
};

56
types.d.ts vendored
View File

@ -80,6 +80,8 @@ import {
WithStatement,
YieldExpression
} from "estree";
import { ServerOptions as ServerOptionsImport } from "http";
import { ListenOptions, Server } from "net";
import { validate as validateFunction } from "schema-utils";
import { default as ValidationError } from "schema-utils/declarations/ValidationError";
import { ValidationErrorConfiguration } from "schema-utils/declarations/validate";
@ -95,6 +97,7 @@ import {
SyncHook,
SyncWaterfallHook
} from "tapable";
import { SecureContextOptions, TlsOptions } from "tls";
declare class AbstractLibraryPlugin<T> {
constructor(__0: {
@ -383,6 +386,10 @@ declare class AutomaticPrefetchPlugin {
apply(compiler: Compiler): void;
}
type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
declare interface BackendApi {
dispose: (arg0?: Error) => void;
module: (arg0: Module) => { client: string; data: string; active: boolean };
}
declare class BannerPlugin {
constructor(options: BannerPluginArgument);
options: BannerPluginOptions;
@ -5795,25 +5802,45 @@ declare interface KnownStatsProfile {
}
/**
* Options for compiling entrypoints and import()s only when they are accessed.
* Options for the default backend.
*/
declare interface LazyCompilationOptions {
/**
* A custom backend.
*/
backend?:
| ((
compiler: Compiler,
client: string,
callback: (err?: Error, api?: any) => void
) => void)
| ((compiler: Compiler, client: string) => Promise<any>);
declare interface LazyCompilationDefaultBackendOptions {
/**
* A custom client.
*/
client?: string;
/**
* Specifies where to listen to from the server.
*/
listen?: number | ListenOptions | ((server: typeof Server) => void);
/**
* Specifies the protocol the client should use to connect to the server.
*/
protocol?: "http" | "https";
/**
* Specifies how to create the server handling the EventSource requests.
*/
server?: ServerOptionsImport | ServerOptionsHttps | (() => typeof Server);
}
/**
* Options for compiling entrypoints and import()s only when they are accessed.
*/
declare interface LazyCompilationOptions {
/**
* Specifies the backend that should be used for handling client keep alive.
*/
backend?:
| ((
compiler: Compiler,
callback: (err?: Error, api?: BackendApi) => void
) => void)
| ((compiler: Compiler) => Promise<BackendApi>)
| LazyCompilationDefaultBackendOptions;
/**
* Enable/disable lazy compilation for entries.
*/
@ -10369,6 +10396,9 @@ declare abstract class Serializer {
serialize(obj?: any, context?: any): any;
deserialize(value?: any, context?: any): any;
}
type ServerOptionsHttps = SecureContextOptions &
TlsOptions &
ServerOptionsImport;
declare class SharePlugin {
constructor(options: SharePluginOptions);