diff --git a/CHANGELOG.md b/CHANGELOG.md index 06394047..82fb563f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # changelog + * tbd + * [normalize package.json url](https://github.com/iambumblehead/esmock/pull/225) and [reduce loc for loader verification](https://github.com/iambumblehead/esmock/pull/226) * 2.3.6 _Aug.07.2023_ * [resolve global mocking issues](https://github.com/iambumblehead/esmock/pull/224) when using mixed esm cjs import trees * 2.3.4 _Jul.30.2023_ diff --git a/src/esmockLoader.js b/src/esmockLoader.js index d506fc9b..63924295 100644 --- a/src/esmockLoader.js +++ b/src/esmockLoader.js @@ -118,10 +118,9 @@ const resolve = async (specifier, context, nextResolve) => { return resolved } -const loaderVerificationQuery = 'esmock-loader=true' -const loaderVerificationURLCreate = url => `${url}?${loaderVerificationQuery}` -const loaderIsVerified = async url => - (await import(loaderVerificationURLCreate(url))).default === true +const loaderVerificationQuery = '?esmock-loader=true' +const loaderIsVerified = async url => import( + url + loaderVerificationQuery).then(m => m.default === true) const load = async (url, context, nextLoad) => { if (url.endsWith(loaderVerificationQuery)) { return {