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

@chialab/esbuild-rna

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chialab/esbuild-rna - npm Package Compare versions

Comparing version 0.15.20 to 0.15.23

43

lib/index.js
import path from 'path';
import crypto from 'crypto';
import { mkdir, readFile, writeFile } from 'fs/promises';
import commondir from 'commondir';
import { appendSearchParam, escapeRegexBody } from '@chialab/node-resolve';

@@ -114,12 +113,27 @@ import { loadSourcemap, inlineSourcemap, mergeSourcemaps } from '@chialab/estransform';

* Get the base out path.
* @param {string} cwd The current working directory.
* @param {string[] | Record<string, string>} entryPoints The entry points.
* @param {string} basePath The current working directory.
* @return {string}
*/
function getOutBase(cwd, entryPoints) {
const files = (Array.isArray(entryPoints) ? entryPoints : Object.values(entryPoints))
.map((entry) => (path.isAbsolute(entry) ? entry : path.resolve(cwd, entry)))
.map((entry) => path.dirname(entry));
function getOutBase(entryPoints, basePath) {
if (!entryPoints.length) {
return basePath;
}
return commondir(files);
const separator = /\/+|\\+/;
return (Array.isArray(entryPoints) ? entryPoints : Object.values(entryPoints))
.map((entry) => (path.isAbsolute(entry) ? entry : path.resolve(basePath, entry)))
.map((entry) => path.dirname(entry))
.map((entry) => entry.split(separator))
.reduce((result, chunk) => {
const len = Math.min(chunk.length, result.length);
for (let i = 0; i < len; i++) {
if (chunk[i] !== result[i]) {
return result.splice(0, i);
}
}
return result.splice(0, len);
})
.join(path.sep) || path.sep;
}

@@ -157,5 +171,6 @@

const rootDir = sourceRoot || workingDir;
const outDir = /** @type {string} */(outdir || (outfile && path.dirname(outfile)));
const fullOutDir = /** @type {string} */(outDir && path.resolve(workingDir, outDir));
const outBase = outbase || (entryPoints.length ? getOutBase(workingDir, entryPoints) : workingDir);
const outDir = outdir || (outfile && path.dirname(outfile));
const fullOutDir = outDir && path.resolve(workingDir, outDir);
const virtualOutDir = fullOutDir || workingDir;
const outBase = outbase || getOutBase(entryPoints, workingDir);

@@ -367,3 +382,3 @@ const rnaBuild = {

const computedName = rnaBuild.computeName(assetNames, source, buffer);
const outputFile = path.join(fullOutDir, computedName);
const outputFile = path.resolve(virtualOutDir, computedName);
const bytes = buffer.length;

@@ -406,3 +421,3 @@ if (write) {

...result,
path: appendSearchParam(`./${path.relative(fullOutDir, outputFile)}`, 'emit', 'file'),
path: appendSearchParam(`./${path.relative(virtualOutDir, outputFile)}`, 'emit', 'file'),
};

@@ -425,3 +440,3 @@ rnaBuild.files.set(source, chunkResult);

format,
outdir: options.outdir ? path.resolve(fullOutDir, `./${options.outdir}`) : fullOutDir,
outdir: options.outdir ? path.resolve(virtualOutDir, `./${options.outdir}`) : fullOutDir,
bundle: options.bundle ?? build.initialOptions.bundle,

@@ -481,3 +496,3 @@ splitting: format === 'esm' ? (options.splitting ?? build.initialOptions.splitting) : false,

...result,
path: appendSearchParam(`./${path.relative(fullOutDir, resolvedOutputFile)}`, 'emit', 'chunk'),
path: appendSearchParam(`./${path.relative(virtualOutDir, resolvedOutputFile)}`, 'emit', 'chunk'),
};

@@ -484,0 +499,0 @@ state.chunks.set(options.entryPoint, chunkResult);

{
"name": "@chialab/esbuild-rna",
"type": "module",
"version": "0.15.20",
"version": "0.15.23",
"description": "A framework for esbuild plugins with transform and emit capabilities.",

@@ -32,11 +32,9 @@ "main": "lib/index.js",

"@chialab/estransform": "^0.15.17",
"@chialab/node-resolve": "^0.15.9",
"commondir": "^1.0.1"
"@chialab/node-resolve": "^0.15.9"
},
"devDependencies": {
"@types/commondir": "^1.0.0",
"esbuild": "^0.14.8",
"typescript": "^4.3.0"
},
"gitHead": "9a2ea6a2189ccdc4b900d27e607378d56c774024"
"gitHead": "e7f2116569b07b6f81cddd17e489ffd8790b441a"
}

@@ -34,3 +34,3 @@ /// <reference types="node" />

*/
outDir: string;
outDir: string | undefined;
/**

@@ -37,0 +37,0 @@ * Compute loaders.

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