From cc80031a809f867cffac31c91f2b68ef1cc997c8 Mon Sep 17 00:00:00 2001 From: dmail Date: Wed, 27 Nov 2024 17:07:30 +0100 Subject: [PATCH] introduce jsenv-type attribute on scripts --- package.json | 2 +- .../0_js_module/build/main.html | 3 +- .../1_js_module_fallback/build/main.html | 3 +- .../0_chromium/.jsenv/chrome@131.00/main.html | 13 ++--- .../0_chromium/0_chromium.md | 2 +- .../tests/script_module_jsx/client/main.html | 19 ++++---- .../script_module_jsx.test_manual.js | 13 +++++ .../script_module_jsx_dev.test.mjs | 6 ++- .../jsenv_plugin_html_reference_analysis.js | 48 +++++++++++-------- 9 files changed, 68 insertions(+), 41 deletions(-) create mode 100644 packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx.test_manual.js diff --git a/package.json b/package.json index b0dabbfa28..69cb96e377 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jsenv/core", - "version": "39.6.0", + "version": "39.7.0", "description": "Tool to develop, test and build js projects", "license": "MIT", "author": { diff --git a/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_build.test.mjs/0_js_module/build/main.html b/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_build.test.mjs/0_js_module/build/main.html index eedd344ef7..2d5c601a6a 100644 --- a/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_build.test.mjs/0_js_module/build/main.html +++ b/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_build.test.mjs/0_js_module/build/main.html @@ -3,6 +3,7 @@ Title + - - - \ No newline at end of file diff --git a/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_dev.test.mjs/0_chromium/0_chromium.md b/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_dev.test.mjs/0_chromium/0_chromium.md index 4b01674660..4b7a1c8e7c 100644 --- a/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_dev.test.mjs/0_chromium/0_chromium.md +++ b/packages/related/plugin-preact/tests/script_module_jsx/_script_module_jsx_dev.test.mjs/0_chromium/0_chromium.md @@ -1,4 +1,4 @@ -# [0_chromium](../../script_module_jsx_dev.test.mjs#L20) +# [0_chromium](../../script_module_jsx_dev.test.mjs#L24) ```js run({ browserLauncher: chromium }) diff --git a/packages/related/plugin-preact/tests/script_module_jsx/client/main.html b/packages/related/plugin-preact/tests/script_module_jsx/client/main.html index ac97101dfd..3d450a9b96 100644 --- a/packages/related/plugin-preact/tests/script_module_jsx/client/main.html +++ b/packages/related/plugin-preact/tests/script_module_jsx/client/main.html @@ -3,6 +3,7 @@ Title + @@ -12,28 +13,28 @@ window.resolveResultPromise = resolve; }); - diff --git a/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx.test_manual.js b/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx.test_manual.js new file mode 100644 index 0000000000..bcd20d3262 --- /dev/null +++ b/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx.test_manual.js @@ -0,0 +1,13 @@ +import { startDevServer } from "@jsenv/core"; +import { jsenvPluginPreact } from "@jsenv/plugin-preact"; + +await startDevServer({ + sourceDirectoryUrl: new URL("./client/", import.meta.url), + port: 3457, + ribbon: false, + plugins: [ + jsenvPluginPreact({ + refreshInstrumentation: true, + }), + ], +}); diff --git a/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx_dev.test.mjs b/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx_dev.test.mjs index 240925337f..a2a3f02dae 100644 --- a/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx_dev.test.mjs +++ b/packages/related/plugin-preact/tests/script_module_jsx/script_module_jsx_dev.test.mjs @@ -9,7 +9,11 @@ const run = async ({ browserLauncher }) => { sourceDirectoryUrl: new URL("./client/", import.meta.url), keepProcessAlive: false, port: 0, - plugins: [jsenvPluginPreact()], + plugins: [ + jsenvPluginPreact({ + refreshInstrumentation: true, + }), + ], }); return executeHtml(`${devServer.origin}/main.html`, { browserLauncher, diff --git a/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js b/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js index 9d706a02b9..eb5ab2f9b4 100644 --- a/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js +++ b/src/plugins/reference_analysis/html/jsenv_plugin_html_reference_analysis.js @@ -280,6 +280,31 @@ export const jsenvPluginHtmlReferenceAnalysis = ({ actions.push(async () => { const inlineUrlInfo = inlineReference.urlInfo; await inlineUrlInfo.cook(); + const typeAttribute = getHtmlNodeAttribute(node, "type"); + if (expectedType === "js_classic") { + if ( + typeAttribute !== undefined && + typeAttribute !== "text/javascript" + ) { + // 1. @@ -483,31 +508,12 @@ export const jsenvPluginHtmlReferenceAnalysis = ({ ) { return; } - - const inlineRef = visitTextContent(scriptNode, { + visitTextContent(scriptNode, { type: "script", subtype, expectedType: type, contentType, }); - if (inlineRef) { - // 1.