Socket
Socket
Sign inDemoInstall

@chialab/esbuild-plugin-alias

Package Overview
Dependencies
5
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @chialab/esbuild-plugin-alias

A plugin for esbuild that resolves aliases or empty modules.


Version published
Weekly downloads
72
decreased by-1.37%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

Esbuild Plugin Alias • A plugin for esbuild that resolves aliases or empty modules.

NPM


Install

$ npm i @chialab/esbuild-plugin-alias -D
$ yarn add @chialab/esbuild-plugin-alias -D

Usage

Load path-browser.js instead of the node's path module:

import esbuild from 'esbuild';
import aliasPlugin from '@chialab/esbuild-plugin-alias';

await esbuild.build({
    plugins: [
        aliasPlugin({
            'node-fetch': false,
            'path': '../path-browser.js'
        }),
    ],
});

Load node-fetch module as an empty module:

import esbuild from 'esbuild';
import aliasPlugin from '@chialab/esbuild-plugin-alias';

await esbuild.build({
    plugins: [
        aliasPlugin({
            'node-fetch': false,
        }),
    ],
});

Load aliases from browser field in package.json:

package.json

{
    "name": "webapp",
    "version": "0.0.0",
    "browser": {
        "path": "./browser-path.js",
        "node-fetch": false,
    }
}
import esbuild from 'esbuild';
import aliasPlugin from '@chialab/esbuild-plugin-alias';

await esbuild.build({
    platform: 'browser',
    plugins: [
        aliasPlugin(),
    ],
});

License

Esbuild Plugin alias is released under the MIT license.

Keywords

FAQs

Last updated on 13 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc