@chialab/esbuild-plugin-meta-url
Advanced tools
Comparing version 0.12.31 to 0.12.34
@@ -124,3 +124,3 @@ import path from 'path'; | ||
sourcesContent, | ||
}, async ({ magicCode, code, ast }) => { | ||
}, async (data) => { | ||
/** | ||
@@ -136,3 +136,3 @@ * @type {{ [key: string]: string }} | ||
walk(ast, { | ||
walk(data.ast, { | ||
/** | ||
@@ -142,3 +142,3 @@ * @param {*} node | ||
NewExpression(node) { | ||
const value = getMetaUrl(node, ast); | ||
const value = getMetaUrl(node, data.ast); | ||
if (typeof value !== 'string' || isUrl(value)) { | ||
@@ -150,11 +150,11 @@ return; | ||
const resolvedPath = await resolve(value, args.path); | ||
const startOffset = getOffsetFromLocation(code, node.loc.start); | ||
const endOffset = getOffsetFromLocation(code, node.loc.end); | ||
const startOffset = getOffsetFromLocation(data.code, node.loc.start); | ||
const endOffset = getOffsetFromLocation(data.code, node.loc.end); | ||
if (!ids[resolvedPath]) { | ||
const entryPoint = emitFileOrChunk(build, resolvedPath); | ||
const { identifier } = prependImportStatement({ ast, magicCode, code }, entryPoint, value); | ||
const { identifier } = prependImportStatement(data, entryPoint, value); | ||
ids[resolvedPath] = identifier; | ||
} | ||
magicCode.overwrite(startOffset, endOffset, `new URL(${ids[resolvedPath]}, ${getBaseUrl(build)})`); | ||
data.magicCode.overwrite(startOffset, endOffset, `new URL(${ids[resolvedPath]}, ${getBaseUrl(build)})`); | ||
})()); | ||
@@ -161,0 +161,0 @@ }, |
{ | ||
"name": "@chialab/esbuild-plugin-meta-url", | ||
"type": "module", | ||
"version": "0.12.31", | ||
"version": "0.12.34", | ||
"description": "A file loader plugin for esbuild for constructed URLs using import metadata.", | ||
@@ -47,3 +47,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "f04714a9a45a079d611e07e20c12ff2380f473e6" | ||
"gitHead": "6b332aab5614a4d081f931451c04471bff3e3147" | ||
} |
10719