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

esbuild-loader

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-loader - npm Package Compare versions

Comparing version 2.20.0 to 2.21.0

1

dist/index.d.ts

@@ -6,1 +6,2 @@ import esbuildLoader from './loader';

export { ESBuildPlugin, ESBuildMinifyPlugin };
export * from './interfaces';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -13,1 +27,2 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.default = loader_1.default;
__exportStar(require("./interfaces"), exports);

10

dist/interfaces.d.ts
import { transform, TransformOptions } from 'esbuild';
declare type Filter = string | RegExp;
declare type Implementation = {
type Filter = string | RegExp;
type Implementation = {
transform: typeof transform;
};
declare type Except<ObjectType, Properties> = {
type Except<ObjectType, Properties> = {
[Key in keyof ObjectType as (Key extends Properties ? never : Key)]: ObjectType[Key];
};
declare type LoaderOptions = Except<TransformOptions, 'sourcemap' | 'sourcefile'> & {
type LoaderOptions = Except<TransformOptions, 'sourcemap' | 'sourcefile'> & {
/** Pass a custom esbuild implementation */
implementation?: Implementation;
};
declare type MinifyPluginOptions = Except<TransformOptions, 'sourcefile'> & {
type MinifyPluginOptions = Except<TransformOptions, 'sourcefile'> & {
include?: Filter | Filter[];

@@ -15,0 +15,0 @@ exclude?: Filter | Filter[];

@@ -56,3 +56,9 @@ "use strict";

async transformAssets(compilation) {
const { options: { devtool } } = compilation.compiler;
var _a;
const { compiler } = compilation;
const { options: { devtool } } = compiler;
// @ts-expect-error Only exists on Webpack 5
const sources = (_a = compiler.webpack) === null || _a === void 0 ? void 0 : _a.sources;
const SourceMapSource = (sources ? sources.SourceMapSource : webpack_sources_1.SourceMapSource);
const RawSource = (sources ? sources.RawSource : webpack_sources_1.RawSource);
const sourcemap = (

@@ -74,3 +80,15 @@ // TODO: drop support for esbuild sourcemap in future so it all goes through WP API

const assetIsCss = isCssFile.test(asset.name);
const { source, map } = asset.source.sourceAndMap();
let source;
let map = null;
if (asset.source.sourceAndMap) {
const sourceAndMap = asset.source.sourceAndMap();
source = sourceAndMap.source;
map = sourceAndMap.map;
}
else {
source = asset.source.source();
if (asset.source.map) {
map = asset.source.map();
}
}
const sourceAsString = source.toString();

@@ -85,5 +103,8 @@ const result = await this.transform(sourceAsString, {

});
if (result.legalComments) {
compilation.emitAsset(`${asset.name}.LEGAL.txt`, new RawSource(result.legalComments));
}
compilation.updateAsset(asset.name, (sourcemap
? new webpack_sources_1.SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
: new webpack_sources_1.RawSource(result.code)), {
? new SourceMapSource(result.code, asset.name, result.map, sourceAsString, map, true)
: new RawSource(result.code)), {
...asset.info,

@@ -90,0 +111,0 @@ minimized: true,

{
"name": "esbuild-loader",
"version": "2.20.0",
"version": "2.21.0",
"description": "⚡️ Speed up your Webpack build with esbuild",

@@ -24,7 +24,14 @@ "keywords": [

"types": "./dist/index.d.ts",
"imports": {
"#esbuild-loader": {
"types": "./src/index.ts",
"development": "./src/index.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsc",
"pretest": "npm run build",
"test": "jest --coverage",
"lint": "eslint ."
"test": "tsx tests",
"dev": "tsx watch --conditions=development tests",
"lint": "eslint --cache ."
},

@@ -35,3 +42,3 @@ "peerDependencies": {

"dependencies": {
"esbuild": "^0.15.6",
"esbuild": "^0.16.17",
"joycon": "^3.0.1",

@@ -41,20 +48,20 @@ "json5": "^2.2.0",

"tapable": "^2.2.0",
"webpack-sources": "^2.2.0"
"webpack-sources": "^1.4.3"
},
"devDependencies": {
"@pvtnbr/eslint-config": "^0.26.2",
"@types/jest": "^27.0.3",
"@pvtnbr/eslint-config": "^0.33.0",
"@types/loader-utils": "^2.0.3",
"@types/node": "^18.0.4",
"@types/webpack": "^4.41.32",
"@types/webpack-sources": "^3.2.0",
"css-loader": "^5.2.0",
"eslint": "^8.19.0",
"jest": "^27.4.4",
"memfs": "^3.4.0",
"mini-css-extract-plugin": "^1.4.0",
"typescript": "^4.7.4",
"unionfs": "^4.4.0",
"@types/mini-css-extract-plugin": "^2.5.1",
"@types/node": "^18.11.18",
"@types/webpack": "^4.41.33",
"@types/webpack-sources": "^0.1.9",
"css-loader": "^5.2.7",
"eslint": "^8.31.0",
"manten": "^0.6.0",
"memfs": "^3.4.13",
"mini-css-extract-plugin": "^1.6.2",
"tsx": "^3.12.2",
"typescript": "^4.9.4",
"webpack": "^4.44.2",
"webpack-test-utils": "^1.1.0",
"webpack-test-utils": "^2.1.0",
"webpack5": "npm:webpack@^5.0.0"

@@ -61,0 +68,0 @@ },

@@ -101,2 +101,8 @@ # esbuild-loader <a href="https://npm.im/esbuild-loader"><img src="https://badgen.net/npm/v/esbuild-loader"></a> <a href="https://npm.im/esbuild-loader"><img src="https://badgen.net/npm/dm/esbuild-loader"></a> <a href="https://packagephobia.now.sh/result?p=esbuild-loader"><img src="https://packagephobia.now.sh/badge?p=esbuild-loader"></a>

#### `tsconfig.json` Paths
Use [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin) to add support for `tsconfig.json#paths`.
Since esbuild-loader only uses esbuild to transform code, it cannot help Webpack with resolving [tsconfig.json#paths](https://www.typescriptlang.org/tsconfig/paths.html).
### JS Minification (eg. Terser)

@@ -340,3 +346,3 @@ You can replace JS minifiers like Terser or UglifyJs. Checkout the [benchmarks](https://github.com/privatenumber/minification-benchmarks) to see how much faster esbuild is. The `target` option tells esbuild that it can use newer JS syntax to perform better minification.

#### legalComments
Type: `'none' | 'inline' | 'eof'`
Type: `'none' | 'inline' | 'eof' | 'external'`

@@ -420,9 +426,11 @@ Default: `'inline'`

## 🌱 Other Webpack plugins
## 💞 Related
#### [tsx](https://github.com/esbuild-kit/tsx)
Node.js enhanced with esbuild to run TypeScript and ESM.
#### [instant-mocha](https://github.com/privatenumber/instant-mocha)
Webpack-integrated Mocha test-runner with Webpack 5 support.
#### [webpack-localize-assets-plugin](https://github.com/privatenumber/webpack-localize-assets-plugin)
Localize/i18nalize your Webpack build. Optimized for multiple locales!
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