Socket
Book a DemoInstallSign in
Socket

@hyrious/esbuild-plugin-external

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hyrious/esbuild-plugin-external

Compute and mark external modules

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

@hyrious/esbuild-plugin-external

An esbuild plugin to help you compute and mark external modules manually.

Features

  • Excludes dependencies and peerDependencies from package.json.
  • Adds custom loader with { external: "./replacement.js" }.
  • Automatically externalizes imports with pattern matching.

Usage

import external from '@hyrious/esbuild-plugin-external'

await esbuild.build({
  entryPoints: ['src/index.ts', 'src/cli.ts'],
  bundle: true,
  format: 'esm',
  platform: 'node',
  packages: 'bundle',
  plugins: [external()]
}).catch(() => process.exit(1))

Options

external({
  package: true,
  filter: /\.ts$/,
  auto: [{ filter: /\.js$/ }],
})
  • package: Automatically mark dependencies and peer dependencies from package.json. This is enabled by default.

  • filter: Filter in files to be enhanced to use import attribute with { external: "replace" }. This is disabled by default, you need to pass in a regex to make it work. Example:

    import * as mod from '../foo' with { external: "./foo.js" }
    // will be bundled into =>
    import * as mod from './foo.js'
    
  • auto: Filter in paths to be externalized and perform a simple replacement to strip leading '../'s. This is disabled by default, you need to pass in a config to make it work. Example:

    // auto: [{ filter: /\.js$/ }]
    import * as mod from './index.js' // will be marked external
    import * as mod from '../foo.js' // will be externalized as './foo.js'
    

License

MIT @ hyrious

Keywords

esbuild

FAQs

Package last updated on 22 Aug 2024

Did you know?

Socket

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