@chialab/esbuild-plugin-alias
v0.17.2
Published
A plugin for esbuild that resolves aliases or empty modules.
Downloads
290
Readme
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.