🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@bazel/esbuild

Package Overview
Dependencies
Maintainers
6
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bazel/esbuild - npm Package Compare versions

Comparing version

to
4.0.0-rc.0

esbuild_config.bzl

107

launcher.js
const {readFileSync, writeFileSync} = require('fs');
const {pathToFileURL} = require('url');
const {join} = require('path');
const esbuild = require('esbuild');

@@ -25,2 +27,65 @@

async function processConfigFile(configFilePath, existingArgs = {}) {
const fullConfigFileUrl = pathToFileURL(join(process.cwd(), configFilePath));
let config;
try {
config = await import(fullConfigFileUrl);
} catch (e) {
console.error(`Error while loading configuration '${fullConfigFileUrl}':\n`, e);
process.exit(1);
}
if (!config.default) {
console.error(`Config file '${configFilePath}' was loaded, but did not export a configuration object as default`);
process.exit(1);
}
config = config.default;
// These keys of the config can not be overriden
const IGNORED_CONFIG_KEYS = [
'bundle',
'entryPoints',
'external',
'metafile',
'outdir',
'outfile',
'preserveSymlinks',
'sourcemap',
'splitting',
'tsconfig',
];
const MERGE_CONFIG_KEYS = [
'define',
];
return Object.entries(config).reduce((prev, [key, value]) => {
if (value === null || value === void 0) {
return prev;
}
if (IGNORED_CONFIG_KEYS.includes(key)) {
console.error(`[WARNING] esbuild configuration property '${key}' from '${configFilePath}' will be ignored and overriden`);
} else if (MERGE_CONFIG_KEYS.includes(key) && existingArgs.hasOwnProperty(key)) {
// values from the rule override the config file
// perform a naive merge
if (Array.isArray(value)) {
prev[key] = [...value, ...existingArgs[key]];
} else if (typeof value === 'object') {
prev[key] = {
...value,
...existingArgs[key],
}
} else {
// can't merge
console.error(`[WARNING] esbuild configuration property '${key}' from '${configFilePath}' could not be merged`);
}
} else {
prev[key] = value;
}
return prev;
}, {});
}
if (!process.env.ESBUILD_BINARY_PATH) {

@@ -31,15 +96,33 @@ console.error('Expected enviournment variable ESBUILD_BINARY_PATH to be set', e);

let args = getEsbuildArgs(getFlag('--esbuild_args'));
const userArgsFile = getFlag("--user_args", false);
if (userArgsFile) {
args = {
...args,
...getEsbuildArgs(userArgsFile)
};
async function runOneBuild(args, userArgsFilePath, configFilePath) {
if (userArgsFilePath) {
args = {
...args,
...getEsbuildArgs(userArgsFilePath)
}
}
if (configFilePath) {
const config = await processConfigFile(configFilePath, args);
args = {
...args,
...config
};
}
const metafile = getFlag('--metafile');
try {
const result = await esbuild.build(args);
writeFileSync(metafile, JSON.stringify(result.metafile));
} catch (e) {
console.error(e);
process.exit(1);
}
}
const metafile = getFlag('--metafile');
const result = esbuild.buildSync(args);
writeFileSync(metafile, JSON.stringify(result.metafile));
runOneBuild(
getEsbuildArgs(getFlag("--esbuild_args")),
getFlag("--user_args", false),
getFlag("--config_file", false)
);

2

package.json

@@ -5,3 +5,3 @@ {

"license": "Apache-2.0",
"version": "4.0.0-beta.1",
"version": "4.0.0-rc.0",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -102,5 +102,5 @@ <!-- *********************

<pre>
esbuild(<a href="#esbuild-name">name</a>, <a href="#esbuild-args">args</a>, <a href="#esbuild-args_file">args_file</a>, <a href="#esbuild-define">define</a>, <a href="#esbuild-deps">deps</a>, <a href="#esbuild-entry_point">entry_point</a>, <a href="#esbuild-entry_points">entry_points</a>, <a href="#esbuild-external">external</a>, <a href="#esbuild-format">format</a>, <a href="#esbuild-launcher">launcher</a>,
<a href="#esbuild-link_workspace_root">link_workspace_root</a>, <a href="#esbuild-max_threads">max_threads</a>, <a href="#esbuild-minify">minify</a>, <a href="#esbuild-output">output</a>, <a href="#esbuild-output_css">output_css</a>, <a href="#esbuild-output_dir">output_dir</a>, <a href="#esbuild-output_map">output_map</a>,
<a href="#esbuild-platform">platform</a>, <a href="#esbuild-sourcemap">sourcemap</a>, <a href="#esbuild-sources_content">sources_content</a>, <a href="#esbuild-splitting">splitting</a>, <a href="#esbuild-srcs">srcs</a>, <a href="#esbuild-target">target</a>)
esbuild(<a href="#esbuild-name">name</a>, <a href="#esbuild-args">args</a>, <a href="#esbuild-args_file">args_file</a>, <a href="#esbuild-config">config</a>, <a href="#esbuild-define">define</a>, <a href="#esbuild-deps">deps</a>, <a href="#esbuild-entry_point">entry_point</a>, <a href="#esbuild-entry_points">entry_points</a>, <a href="#esbuild-external">external</a>, <a href="#esbuild-format">format</a>,
<a href="#esbuild-launcher">launcher</a>, <a href="#esbuild-link_workspace_root">link_workspace_root</a>, <a href="#esbuild-max_threads">max_threads</a>, <a href="#esbuild-minify">minify</a>, <a href="#esbuild-node_context_data">node_context_data</a>, <a href="#esbuild-output">output</a>, <a href="#esbuild-output_css">output_css</a>,
<a href="#esbuild-output_dir">output_dir</a>, <a href="#esbuild-output_map">output_map</a>, <a href="#esbuild-platform">platform</a>, <a href="#esbuild-sourcemap">sourcemap</a>, <a href="#esbuild-sources_content">sources_content</a>, <a href="#esbuild-splitting">splitting</a>, <a href="#esbuild-srcs">srcs</a>, <a href="#esbuild-target">target</a>)
</pre>

@@ -130,6 +130,14 @@

(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): A JSON file containing additional arguments that are passed to esbuild. Note: only one of args or args_file may be set
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Internal use only
Defaults to `None`
<h4 id="esbuild-config">config</h4>
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Configuration file used for esbuild, from the esbuild_config macro. Note that options set in this file may get overwritten.
See https://github.com/bazelbuild/rules_nodejs/tree/stable/packages/esbuild/test/plugins/BUILD.bazel for examples of using esbuild_config and plugins. The dependencies of this attribute must provide: Unknown Provider
Defaults to `None`
<h4 id="esbuild-define">define</h4>

@@ -223,2 +231,14 @@

<h4 id="esbuild-node_context_data">node_context_data</h4>
(*<a href="https://bazel.build/docs/build-ref.html#labels">Label</a>*): Provides info about the build context, such as stamping.
By default it reads from the bazel command line, such as the `--stamp` argument.
Use this to override values for this target, such as enabling or disabling stamping.
You can use the `node_context_data` rule in `@build_bazel_rules_nodejs//internal/node:context.bzl`
to create a NodeContextInfo. The dependencies of this attribute must provide: NodeContextInfo
Defaults to `@build_bazel_rules_nodejs//internal:node_context_data`
<h4 id="esbuild-output">output</h4>

@@ -329,2 +349,46 @@

## esbuild_config
**USAGE**
<pre>
esbuild_config(<a href="#esbuild_config-name">name</a>, <a href="#esbuild_config-config_file">config_file</a>, <a href="#esbuild_config-srcs">srcs</a>, <a href="#esbuild_config-deps">deps</a>, <a href="#esbuild_config-kwargs">kwargs</a>)
</pre>
Macro for an esbuild configuration file and its assoicated dependencies
**PARAMETERS**
<h4 id="esbuild_config-name">name</h4>
Unique name for this rule
<h4 id="esbuild_config-config_file">config_file</h4>
The configuration file / entrypoint
<h4 id="esbuild_config-srcs">srcs</h4>
List of source files referenced by the configuration
Defaults to `[]`
<h4 id="esbuild_config-deps">deps</h4>
List of dependencies required for this configuration
Defaults to `[]`
<h4 id="esbuild_config-kwargs">kwargs</h4>
Any other common attributes
## esbuild_repositories

@@ -331,0 +395,0 @@

{
"version": "4.0.0-beta.1",
"version": "4.0.0-rc.0",
"lockfileVersion": 1,

@@ -7,7 +7,7 @@ "requires": true,

"esbuild": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.12.5.tgz",
"integrity": "sha512-vcuP53pA5XiwUU4FnlXM+2PnVjTfHGthM7uP1gtp+9yfheGvFFbq/KyuESThmtoHPUrfZH5JpxGVJIFDVD1Egw=="
"version": "0.12.19",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.12.19.tgz",
"integrity": "sha512-5NuT1G6THW7l3fsSCDkcPepn24R0XtyPjKoqKHD8LfhqMXzCdz0mrS9HgO6hIhzVT7zt0T+JGbzCqF5AH8hS9w=="
}
}
}
{
"version": "4.0.0-beta.1",
"version": "4.0.0-rc.0",
"private": true,

@@ -16,4 +16,4 @@ "repository": {

"dependencies": {
"esbuild": "0.12.5"
"esbuild": "0.12.19"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet