@chialab/esbuild-plugin-meta-url
Advanced tools
Comparing version 0.7.6 to 0.8.0
@@ -54,5 +54,11 @@ import { promises } from 'fs'; | ||
const loaders = options.loader || {}; | ||
const magicCode = new MagicString(entry.code); | ||
const code = entry.code; | ||
const magicCode = new MagicString(code); | ||
let match = URL_REGEX.exec(entry.code); | ||
/** | ||
* @type {{ [key: string]: string }} | ||
*/ | ||
const ids = {}; | ||
let match = URL_REGEX.exec(code); | ||
while (match) { | ||
@@ -90,12 +96,14 @@ const len = match[0].length; | ||
} else { | ||
let identifier = `_${value.replace(/[^a-zA-Z0-9]/g, '_')}`; | ||
if (entry.code.startsWith('#!')) { | ||
magicCode.appendRight(entry.code.indexOf('\n') + 1, `import ${identifier} from '${entryPoint}.urlfile';\n`); | ||
} else { | ||
magicCode.prepend(`import ${identifier} from '${entryPoint}.urlfile';\n`); | ||
if (!ids[entryPoint]) { | ||
let identifier = ids[entryPoint] = `_${value.replace(/[^a-zA-Z0-9]/g, '_')}`; | ||
if (code.startsWith('#!')) { | ||
magicCode.appendRight(code.indexOf('\n') + 1, `import ${identifier} from '${entryPoint}.urlfile';\n`); | ||
} else { | ||
magicCode.prepend(`import ${identifier} from '${entryPoint}.urlfile';\n`); | ||
} | ||
} | ||
magicCode.overwrite(match.index, match.index + len, `${match[1]}${identifier}, ${baseUrl}${match[3]}`); | ||
magicCode.overwrite(match.index, match.index + len, `${match[1]}${ids[entryPoint]}, ${baseUrl}${match[3]}`); | ||
} | ||
match = URL_REGEX.exec(entry.code); | ||
match = URL_REGEX.exec(code); | ||
} | ||
@@ -102,0 +110,0 @@ |
{ | ||
"name": "@chialab/esbuild-plugin-meta-url", | ||
"type": "module", | ||
"version": "0.7.6", | ||
"version": "0.8.0", | ||
"description": "A file loader plugin for esbuild for constructed URLs using import metadata.", | ||
@@ -37,4 +37,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@chialab/esbuild-plugin-transform": "^0.7.6", | ||
"esbuild": "^0.11.16", | ||
"@chialab/esbuild-plugin-transform": "^0.8.0", | ||
"esbuild": "^0.12.0", | ||
"magic-string": "^0.25.7", | ||
@@ -46,3 +46,3 @@ "resolve": "^1.20.0" | ||
}, | ||
"gitHead": "1d6324b23f9d85143e210ac84ff6a2f360aba6c6" | ||
"gitHead": "c1da574f3edfc925ea37436df10c919d48cd637f" | ||
} |
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
8977
119
+ Added@chialab/esbuild-plugin-transform@0.8.4(transitive)
+ Addedesbuild@0.12.29(transitive)
- Removed@chialab/esbuild-plugin-transform@0.7.6(transitive)
- Removedesbuild@0.11.23(transitive)
Updatedesbuild@^0.12.0