@chialab/esbuild-plugin-meta-url
Advanced tools
Comparing version 0.17.6 to 0.17.7
import path from 'path'; | ||
import mime from 'mime-types'; | ||
import { appendSearchParam, getSearchParam, isUrl } from '@chialab/node-resolve'; | ||
import { getSearchParam, isUrl } from '@chialab/node-resolve'; | ||
import { parse, walk, getIdentifierValue, getBlock, getLocation, TokenType } from '@chialab/estransform'; | ||
@@ -199,14 +199,15 @@ import { Build, useRna } from '@chialab/esbuild-rna'; | ||
const isIIFE = format === 'iife' && bundle; | ||
const searchParams = new URLSearchParams(); | ||
let entryPoint; | ||
let entryPoint = resolvedPath; | ||
if (emit && !isIIFE) { | ||
if (isChunk) { | ||
const chunk = await build.emitChunk({ path: resolvedPath }); | ||
entryPoint = appendSearchParam(chunk.path, 'hash', chunk.id); | ||
searchParams.set('hash', chunk.id); | ||
entryPoint = chunk.path; | ||
} else { | ||
const file = await build.emitFile(resolvedPath); | ||
entryPoint = appendSearchParam(file.path, 'hash', file.id); | ||
searchParams.set('hash', file.id); | ||
entryPoint = file.path; | ||
} | ||
} else { | ||
entryPoint = path.relative(path.dirname(args.path), resolvedPath); | ||
} | ||
@@ -220,3 +221,3 @@ | ||
write: false, | ||
}); | ||
}, false); | ||
if (outputFiles) { | ||
@@ -246,3 +247,5 @@ mimeType = mime.lookup(outputFiles[0].path); | ||
helpers.overwrite(startToken.start, endToken.end, `new URL('./${entryPoint.split(path.sep).join('/')}', ${baseUrl})`); | ||
const outputPath = build.resolveRelativePath(entryPoint); | ||
const searchParamsString = searchParams.toString(); | ||
helpers.overwrite(startToken.start, endToken.end, `new URL('${outputPath}${searchParamsString ? `?${searchParamsString}` : ''}', ${baseUrl})`); | ||
return; | ||
@@ -249,0 +252,0 @@ } |
{ | ||
"name": "@chialab/esbuild-plugin-meta-url", | ||
"type": "module", | ||
"version": "0.17.6", | ||
"version": "0.17.7", | ||
"description": "A file loader plugin for esbuild for constructed URLs using import metadata.", | ||
@@ -33,5 +33,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@chialab/esbuild-rna": "^0.17.6", | ||
"@chialab/estransform": "^0.17.1", | ||
"@chialab/node-resolve": "^0.17.0", | ||
"@chialab/esbuild-rna": "^0.17.8", | ||
"@chialab/estransform": "^0.17.4", | ||
"@chialab/node-resolve": "^0.17.1", | ||
"mime-types": "^2.1.35" | ||
@@ -38,0 +38,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15947
274