Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chialab/esbuild-plugin-meta-url

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chialab/esbuild-plugin-meta-url - npm Package Compare versions

Comparing version 0.7.6 to 0.8.0

26

lib/index.js

@@ -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"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc