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.16.2 to 0.16.3

84

lib/Build.js

@@ -180,2 +180,14 @@ import path from 'path';

/**
* The current plugin instance.
* @type {Plugin}
*/
plugin = { name: 'unknown', setup() {} };
/**
* The current plugin name.
* @type {string}
*/
pluginName = '';
/**
* Manager instance.

@@ -424,4 +436,8 @@ * @type {import('./BuildManager.js').BuildManager}

'.js': 'js',
'.mjs': 'js',
'.cjs': 'js',
'.jsx': 'jsx',
'.ts': 'ts',
'.mts': 'ts',
'.cts': 'ts',
'.tsx': 'tsx',

@@ -683,3 +699,11 @@ ...(this.getOption('loader') || {}),

const maps = [];
/**
* @type {Message[]}
*/
const warnings = [];
/**
* @type {Message[]}
*/
const errors = [];

@@ -696,23 +720,40 @@ for (const { options, callback } of this.onTransformRules) {

const result = await callback({
...args,
code: typeof code !== 'string' ? code.toString() : code,
loader,
});
if (result) {
if (result.code) {
code = result.code;
try {
const result = await callback({
...args,
code: typeof code !== 'string' ? code.toString() : code,
loader,
});
if (result) {
if (result.code) {
code = result.code;
}
if (result.warnings) {
warnings.push(...result.warnings);
}
if (result.errors) {
errors.push(...result.errors);
}
if (result.map) {
maps.push(result.map);
}
if (result.resolveDir) {
resolveDir = result.resolveDir;
}
}
if (result.warnings) {
warnings.push(...result.warnings);
} catch (error) {
if (error instanceof Error) {
const pluginName = this.pluginName;
errors.push({
id: 'transform-error',
pluginName,
text: error.message,
location: null,
notes: [],
detail: error,
});
} else {
throw error;
}
if (result.errors) {
errors.push(...result.errors);
}
if (result.map) {
maps.push(result.map);
}
if (result.resolveDir) {
resolveDir = result.resolveDir;
}
break;
}

@@ -880,3 +921,2 @@ }

* Insert dependency plugins in the build plugins list.
* @param {Plugin} plugin The current plugin.
* @param {Plugin[]} plugins A list of required plugins .

@@ -886,3 +926,3 @@ * @param {'before'|'after'} [mode] Where insert the missing plugin.

*/
async setupPlugin(plugin, plugins, mode = 'before') {
async setupPlugin(plugins, mode = 'before') {
if (this.isChunk()) {

@@ -900,3 +940,3 @@ return [];

let last = plugin;
let last = this.plugin;
for (let i = 0; i < plugins.length; i++) {

@@ -903,0 +943,0 @@ const dependency = plugins[i];

@@ -12,6 +12,11 @@ import { BuildManager } from './BuildManager.js';

/**
* @typedef {import('./Build').Build & { pluginName: string }} PluginBuild
*/
/**
* Enrich the esbuild build with a transformation pipeline and emit methods.
* @param {import('esbuild').Plugin} pluginInstance The esbuild plugin instance.
* @param {import('esbuild').PluginBuild} pluginBuild The esbuild build.
*/
export function useRna(pluginBuild) {
export function useRna(pluginInstance, pluginBuild) {
const build = manager.getBuild(pluginBuild);

@@ -30,3 +35,7 @@ const stdin = build.getOption('stdin');

}
return build;
const extendedBuild = /** @type {import('./Build.js').Build} */ (Object.create(build));
extendedBuild.plugin = pluginInstance;
extendedBuild.pluginName = pluginInstance.name;
return extendedBuild;
}

@@ -38,8 +47,13 @@

export function rnaPlugin() {
return {
/**
* @type {import('esbuild').Plugin}
*/
const plugin = {
name: 'rna',
setup(build) {
useRna(build);
useRna(plugin, build);
},
};
return plugin;
}
{
"name": "@chialab/esbuild-rna",
"type": "module",
"version": "0.16.2",
"version": "0.16.3",
"description": "A framework for esbuild plugins with transform and emit capabilities.",

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

@@ -146,2 +146,12 @@ /// <reference types="node" />

/**
* The current plugin instance.
* @type {Plugin}
*/
plugin: Plugin;
/**
* The current plugin name.
* @type {string}
*/
pluginName: string;
/**
* Manager instance.

@@ -442,3 +452,2 @@ * @type {import('./BuildManager.js').BuildManager}

* Insert dependency plugins in the build plugins list.
* @param {Plugin} plugin The current plugin.
* @param {Plugin[]} plugins A list of required plugins .

@@ -448,3 +457,3 @@ * @param {'before'|'after'} [mode] Where insert the missing plugin.

*/
setupPlugin(plugin: Plugin, plugins: Plugin[], mode?: "before" | "after" | undefined): Promise<string[]>;
setupPlugin(plugins: Plugin[], mode?: "before" | "after" | undefined): Promise<string[]>;
/**

@@ -451,0 +460,0 @@ * Add dependencies to the build.

/**
* @typedef {import('./Build').Build & { pluginName: string }} PluginBuild
*/
/**
* Enrich the esbuild build with a transformation pipeline and emit methods.
* @param {import('esbuild').Plugin} pluginInstance The esbuild plugin instance.
* @param {import('esbuild').PluginBuild} pluginBuild The esbuild build.
*/
export function useRna(pluginBuild: import('esbuild').PluginBuild): import("./Build.js").Build;
export function useRna(pluginInstance: import('esbuild').Plugin, pluginBuild: import('esbuild').PluginBuild): import("./Build.js").Build;
/**

@@ -12,1 +16,4 @@ * @returns {import('esbuild').Plugin}

export * from "./helpers.js";
export type PluginBuild = import('./Build').Build & {
pluginName: string;
};
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