diff --git a/dist/jsenv_core.js b/dist/jsenv_core.js index c6b7da9e05..d52c1c5f2a 100644 --- a/dist/jsenv_core.js +++ b/dist/jsenv_core.js @@ -11530,7 +11530,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => { if (!returnValueAssertion.appliesTo.includes(hook.name)) { continue; } - const assertionResult = returnValueAssertion.assertion(returnValue, info); + const assertionResult = returnValueAssertion.assertion(returnValue, info, { + hook, + }); if (assertionResult !== undefined) { // normalization returnValue = assertionResult; @@ -11544,7 +11546,7 @@ const returnValueAssertions = [ { name: "url_assertion", appliesTo: ["resolveReference", "redirectReference"], - assertion: (valueReturned) => { + assertion: (valueReturned, urlInfo, { hook }) => { if (valueReturned instanceof URL) { return valueReturned.href; } @@ -11552,7 +11554,7 @@ const returnValueAssertions = [ return undefined; } throw new Error( - `Unexpected value returned by plugin: it must be a string; got ${valueReturned}`, + `Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`, ); }, }, @@ -11564,7 +11566,7 @@ const returnValueAssertions = [ "finalizeUrlContent", "optimizeUrlContent", ], - assertion: (valueReturned, urlInfo) => { + assertion: (valueReturned, urlInfo, { hook }) => { if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) { return { content: valueReturned }; } @@ -11575,13 +11577,13 @@ const returnValueAssertions = [ } if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) { throw new Error( - `Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`, + `Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`, ); } return undefined; } throw new Error( - `Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`, + `Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`, ); }, }, diff --git a/package.json b/package.json index 212bb9cc0a..10cfdf6c24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/core", - "version": "39.5.22", + "version": "39.5.23", "description": "Tool to develop, test and build js projects", "license": "MIT", "author": { diff --git a/packages/related/cli/package.json b/packages/related/cli/package.json index 0f4fb280d8..81b2106986 100644 --- a/packages/related/cli/package.json +++ b/packages/related/cli/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/cli", - "version": "0.2.6", + "version": "0.2.7", "description": "Command Line Interface for jsenv", "license": "MIT", "repository": { diff --git a/packages/related/cli/template-node-package/package.json b/packages/related/cli/template-node-package/package.json index 2b0b5981b6..82b3407373 100644 --- a/packages/related/cli/template-node-package/package.json +++ b/packages/related/cli/template-node-package/package.json @@ -12,7 +12,7 @@ }, "devDependencies": { "@jsenv/assert": "4.4.2", - "@jsenv/core": "39.5.22", + "@jsenv/core": "39.5.23", "@jsenv/eslint-config-relax": "1.2.12", "@jsenv/test": "3.5.25", "eslint": "9.14.0", diff --git a/packages/related/cli/template-web-components/package.json b/packages/related/cli/template-web-components/package.json index cedab02a13..ca7b27478c 100644 --- a/packages/related/cli/template-web-components/package.json +++ b/packages/related/cli/template-web-components/package.json @@ -18,7 +18,7 @@ "@babel/plugin-syntax-import-attributes": "7.26.0", "@jsenv/custom-elements-redefine": "0.0.1", "@jsenv/assert": "4.4.2", - "@jsenv/core": "39.5.22", + "@jsenv/core": "39.5.23", "@jsenv/plugin-bundling": "2.7.16", "@jsenv/plugin-minification": "1.5.10", "@jsenv/eslint-config-relax": "1.2.12", diff --git a/packages/related/cli/template-web-preact/package.json b/packages/related/cli/template-web-preact/package.json index 7c7abfb3f2..ad0bd0c257 100644 --- a/packages/related/cli/template-web-preact/package.json +++ b/packages/related/cli/template-web-preact/package.json @@ -21,8 +21,8 @@ "@babel/plugin-syntax-import-attributes": "7.26.0", "@babel/plugin-transform-react-jsx": "7.25.9", "@jsenv/assert": "4.4.2", - "@jsenv/core": "39.5.22", - "@jsenv/plugin-preact": "1.6.25", + "@jsenv/core": "39.5.23", + "@jsenv/plugin-preact": "1.6.26", "@jsenv/plugin-bundling": "2.7.16", "@jsenv/plugin-minification": "1.5.10", "@jsenv/eslint-config-relax": "1.2.12", diff --git a/packages/related/cli/template-web-react/package.json b/packages/related/cli/template-web-react/package.json index a3dbb6f21c..445f8c5377 100644 --- a/packages/related/cli/template-web-react/package.json +++ b/packages/related/cli/template-web-react/package.json @@ -22,7 +22,7 @@ "@babel/plugin-syntax-import-attributes": "7.26.0", "@babel/plugin-transform-react-jsx": "7.25.9", "@jsenv/assert": "4.4.2", - "@jsenv/core": "39.5.22", + "@jsenv/core": "39.5.23", "@jsenv/plugin-react": "1.5.44", "@jsenv/plugin-bundling": "2.7.16", "@jsenv/plugin-minification": "1.5.10", diff --git a/packages/related/cli/template-web/package.json b/packages/related/cli/template-web/package.json index deab011b1e..8ac79d967c 100644 --- a/packages/related/cli/template-web/package.json +++ b/packages/related/cli/template-web/package.json @@ -16,7 +16,7 @@ "devDependencies": { "@babel/plugin-syntax-import-attributes": "7.26.0", "@jsenv/assert": "4.4.2", - "@jsenv/core": "39.5.22", + "@jsenv/core": "39.5.23", "@jsenv/eslint-config-relax": "1.2.12", "@jsenv/plugin-bundling": "2.7.16", "@jsenv/plugin-minification": "1.5.10", diff --git a/packages/related/plugin-preact/package.json b/packages/related/plugin-preact/package.json index 6d81b10538..3dbf211139 100644 --- a/packages/related/plugin-preact/package.json +++ b/packages/related/plugin-preact/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/plugin-preact", - "version": "1.6.25", + "version": "1.6.26", "license": "MIT", "repository": { "type": "git", diff --git a/packages/related/plugin-preact/src/jsenv_plugin_preact.js b/packages/related/plugin-preact/src/jsenv_plugin_preact.js index 5b62297bc0..b00c3342fe 100644 --- a/packages/related/plugin-preact/src/jsenv_plugin_preact.js +++ b/packages/related/plugin-preact/src/jsenv_plugin_preact.js @@ -171,7 +171,7 @@ export const jsenvPluginPreact = ({ const afterJsxReplace = magicSource.toContentAndSourcemap({ source: "jsenv_preact", }); - code = afterJsxReplace.code; + code = afterJsxReplace.content; map = await composeTwoSourcemaps(map, afterJsxReplace.sourcemap); } if (refreshEnabled) { diff --git a/src/plugins/plugin_controller.js b/src/plugins/plugin_controller.js index 8e0c46e51a..83ec39a84c 100644 --- a/src/plugins/plugin_controller.js +++ b/src/plugins/plugin_controller.js @@ -324,7 +324,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => { if (!returnValueAssertion.appliesTo.includes(hook.name)) { continue; } - const assertionResult = returnValueAssertion.assertion(returnValue, info); + const assertionResult = returnValueAssertion.assertion(returnValue, info, { + hook, + }); if (assertionResult !== undefined) { // normalization returnValue = assertionResult; @@ -338,7 +340,7 @@ const returnValueAssertions = [ { name: "url_assertion", appliesTo: ["resolveReference", "redirectReference"], - assertion: (valueReturned) => { + assertion: (valueReturned, urlInfo, { hook }) => { if (valueReturned instanceof URL) { return valueReturned.href; } @@ -346,7 +348,7 @@ const returnValueAssertions = [ return undefined; } throw new Error( - `Unexpected value returned by plugin: it must be a string; got ${valueReturned}`, + `Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`, ); }, }, @@ -358,7 +360,7 @@ const returnValueAssertions = [ "finalizeUrlContent", "optimizeUrlContent", ], - assertion: (valueReturned, urlInfo) => { + assertion: (valueReturned, urlInfo, { hook }) => { if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) { return { content: valueReturned }; } @@ -369,13 +371,13 @@ const returnValueAssertions = [ } if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) { throw new Error( - `Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`, + `Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`, ); } return undefined; } throw new Error( - `Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`, + `Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`, ); }, },