From 4982505ca5eced0ad032b6089defb701fa3b6d8e Mon Sep 17 00:00:00 2001 From: Edoardo Cavazza Date: Thu, 7 Mar 2024 16:54:45 +0100 Subject: [PATCH] Fix helpers --- packages/esbuild-plugin-html/lib/index.js | 9 ++++++++- packages/esbuild-plugin-html/lib/utils.js | 2 +- packages/esbuild-plugin-meta-url/lib/index.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/esbuild-plugin-html/lib/index.js b/packages/esbuild-plugin-html/lib/index.js index 60afbab2..bfa7fa0a 100644 --- a/packages/esbuild-plugin-html/lib/index.js +++ b/packages/esbuild-plugin-html/lib/index.js @@ -258,7 +258,14 @@ export default function ({ scriptsTarget = 'es2015', modulesTarget = 'es2020', m if (minify) { await import('htmlnano') .then(async ({ default: htmlnano }) => { - resultHtml = (await htmlnano.process(resultHtml, minifyOptions)).html; + resultHtml = ( + await htmlnano.process(resultHtml, { + minifyJs: false, + minifyCss: false, + minifyJson: false, + ...minifyOptions, + }) + ).html; }) .catch(() => { warnings.push({ diff --git a/packages/esbuild-plugin-html/lib/utils.js b/packages/esbuild-plugin-html/lib/utils.js index 283afa5d..63bb857e 100644 --- a/packages/esbuild-plugin-html/lib/utils.js +++ b/packages/esbuild-plugin-html/lib/utils.js @@ -5,7 +5,7 @@ import { isAbsolute } from 'path'; * @param {string | null | undefined} url The source to check. */ export function isRelativeUrl(url) { - if (url == null) { + if (!url) { return false; } if (isAbsolute(url)) { diff --git a/packages/esbuild-plugin-meta-url/lib/index.js b/packages/esbuild-plugin-meta-url/lib/index.js index aa93ab14..9dd26e22 100644 --- a/packages/esbuild-plugin-meta-url/lib/index.js +++ b/packages/esbuild-plugin-meta-url/lib/index.js @@ -24,7 +24,7 @@ function isUrl(url) { * @param {string} source */ export function getHashParam(source) { - return new URL(source).searchParams.get('hash') || null; + return new URLSearchParams(source.split('?').slice(1).join('?')).get('hash') || null; } /**