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.17.3 to 0.17.4

45

lib/index.js
import path from 'path';
import { readFile } from 'fs/promises';
import mime from 'mime-types';

@@ -198,4 +199,6 @@ import { appendSearchParam, getSearchParam, isUrl } from '@chialab/node-resolve';

const isChunk = entryLoader !== 'file' && entryLoader !== 'json';
const isIIFE = format === 'iife' && bundle;
let entryPoint;
if (emit) {
if (emit && !isIIFE) {
if (isChunk) {

@@ -212,16 +215,34 @@ const chunk = await build.emitChunk({ path: resolvedPath });

if (format === 'iife' && bundle) {
const { outputFiles } = await build.emitChunk({
path: `./${entryPoint}`,
write: false,
});
if (outputFiles) {
const mimeType = mime.lookup(outputFiles[0].path);
const base64 = Buffer.from(outputFiles[0].contents).toString('base64');
helpers.overwrite(startToken.start, endToken.end, `new URL('data:${mimeType};base64,${base64}')`);
if (isIIFE) {
let buffer, mimeType;
if (isChunk) {
const { outputFiles } = await build.emitChunk({
path: `./${entryPoint}`,
write: false,
});
if (outputFiles) {
mimeType = mime.lookup(outputFiles[0].path);
buffer = Buffer.from(outputFiles[0].contents);
}
} else {
const result = await build.load({
pluginData: null,
namespace: 'file',
suffix: '',
path: resolvedPath,
});
if (result && result.contents) {
mimeType = mime.lookup(resolvedPath);
buffer = Buffer.from(result.contents);
}
}
} else {
helpers.overwrite(startToken.start, endToken.end, `new URL('./${entryPoint}', ${baseUrl})`);
if (buffer) {
helpers.overwrite(startToken.start, endToken.end, `new URL('data:${mimeType};base64,${buffer.toString('base64')}')`);
return;
}
}
helpers.overwrite(startToken.start, endToken.end, `new URL('./${entryPoint}', ${baseUrl})`);
return;

@@ -228,0 +249,0 @@ }

{
"name": "@chialab/esbuild-plugin-meta-url",
"type": "module",
"version": "0.17.3",
"version": "0.17.4",
"description": "A file loader plugin for esbuild for constructed URLs using import metadata.",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

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