Add additional replace rules for node:* modules
In that particular issue the compiled nuxt files end up importing the http module as node:http rather than http only. This bypasses unit's custom loader implementation which only check for the http or unit-http modules, and their websocket counterparts. This changeset adds replace sources for both the node:http and node:websocket import signatures. Closes: https://github.com/nginx/unit/issues/1013 Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
committed by
Dan Callahan
parent
53648ed564
commit
d24ae5a9a4
@@ -11,10 +11,12 @@ if (module.parent && module.parent.id === "internal/preload") {
|
|||||||
Module.prototype.require = function (id) {
|
Module.prototype.require = function (id) {
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case "http":
|
case "http":
|
||||||
|
case "node:http":
|
||||||
case "unit-http":
|
case "unit-http":
|
||||||
return http
|
return http
|
||||||
|
|
||||||
case "websocket":
|
case "websocket":
|
||||||
|
case "node:websocket":
|
||||||
case "unit-http/websocket":
|
case "unit-http/websocket":
|
||||||
return websocket
|
return websocket
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
export async function resolve(specifier, context, defaultResolver) {
|
export async function resolve(specifier, context, defaultResolver) {
|
||||||
switch (specifier) {
|
switch (specifier) {
|
||||||
case "websocket":
|
case "websocket":
|
||||||
|
case "node:websocket":
|
||||||
return {
|
return {
|
||||||
url: new URL("./websocket.js", import.meta.url).href,
|
url: new URL("./websocket.js", import.meta.url).href,
|
||||||
format: "commonjs",
|
format: "commonjs",
|
||||||
@@ -9,6 +10,7 @@ export async function resolve(specifier, context, defaultResolver) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "http":
|
case "http":
|
||||||
|
case "node:http":
|
||||||
return {
|
return {
|
||||||
url: new URL("./http.js", import.meta.url).href,
|
url: new URL("./http.js", import.meta.url).href,
|
||||||
format: "commonjs",
|
format: "commonjs",
|
||||||
|
|||||||
Reference in New Issue
Block a user