@astropub/assert
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -25,3 +25,7 @@ import acornImportAssertionsPlugin from './acorn-plugin.js' | ||
resolveId(sourceId, importerId, options) { | ||
return this.resolve(sourceId, importerId, { skipSelf: true, ...options }).then( | ||
if (!sourceId || !sourceId.includes('assert=')) return | ||
const [ resolveId, assert ] = withModuleAssertions(sourceId) | ||
return this.resolve(resolveId, importerId, { skipSelf: true, ...options }).then( | ||
resolution => { | ||
@@ -31,19 +35,7 @@ // skip null resolutions | ||
const [ resolveId, search ] = resolution.id.split(/(?<=^[^?]+)\?/) | ||
const params = new URLSearchParams(search) | ||
if (params.has('assert')) { | ||
const assertionJSON = params.get('assert') | ||
setModuleAssertions(sourceId, resolution.id, assert) | ||
/** @type {AssertionData} */ | ||
const assertionData = JSON.parse(assertionJSON) | ||
params.delete('assert') | ||
const searchParams = [ ...params ].length ? `?${params}` : '' | ||
resolution.id = sourceId | ||
setModuleAssertions(resolution.id, resolveId + searchParams, assertionData) | ||
return resolution | ||
} | ||
return resolution | ||
} | ||
@@ -83,2 +75,22 @@ ) | ||
const withModuleAssertions = ( | ||
/** @type {string} */ id | ||
) => { | ||
const [ resolveId, search ] = id.split(/(?<=^[^?]+)\?/) | ||
const params = new URLSearchParams(search) | ||
if (!params.has('assert')) return [ resolveId, null ] | ||
const assertionJSON = params.get('assert') | ||
/** @type {AssertionData} */ | ||
const assertionData = JSON.parse(assertionJSON) | ||
params.delete('assert') | ||
const searchParams = [ ...params ].length ? `?${params}` : '' | ||
return [ resolveId + searchParams, assertionData ] | ||
} | ||
/** @type {AssertionMap} */ | ||
@@ -85,0 +97,0 @@ const moduleAssertions = Object.create(null) |
{ | ||
"name": "@astropub/assert", | ||
"type": "module", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"exports": { | ||
@@ -24,3 +24,8 @@ ".": "./index.js", | ||
"vite" | ||
] | ||
], | ||
"license": "CC0-1.0", | ||
"repository": "astro-community/assert", | ||
"author": "Jonathan Neal <jonathantneal@hotmail.com>", | ||
"bugs": "https://github.com/astro-community/assert/issues", | ||
"homepage": "https://github.com/astro-community/assert#readme" | ||
} |
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
15802
1
445
1