Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fewer loc for verification #226

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
7 changes: 3 additions & 4 deletions src/esmockLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
iambumblehead marked this conversation as resolved.
Show resolved Hide resolved
url + loaderVerificationQuery).then(m => m.default === true)
const load = async (url, context, nextLoad) => {
if (url.endsWith(loaderVerificationQuery)) {
return {
Expand Down