![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
esbuild-plugin-alias
Advanced tools
The esbuild-plugin-alias package is a plugin for esbuild, a fast JavaScript bundler and minifier. This plugin allows users to configure custom path aliases for modules in their project, which can simplify imports and make them more readable. It can also be used to mock modules or bind to specific versions of a module.
Path Aliasing
This feature allows you to replace module paths with aliases. In the code sample, 'react' and 'react-dom' are aliased to 'preact/compat', which means that anywhere 'react' or 'react-dom' are imported, 'preact/compat' will be used instead.
require('esbuild').build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
plugins: [
require('esbuild-plugin-alias')({
react: require.resolve('preact/compat'),
'react-dom': require.resolve('preact/compat')
})
]
});
Directory Aliasing
This feature allows you to create aliases for directories. In the code sample, 'components' and 'utils' are aliases for the './src/components' and './src/utils' directories, respectively. This makes importing from these directories shorter and cleaner.
require('esbuild').build({
entryPoints: ['app.js'],
bundle: true,
outfile: 'out.js',
plugins: [
require('esbuild-plugin-alias')({
components: './src/components',
utils: './src/utils'
})
]
});
This Babel plugin allows you to add new 'root' directories that contain your modules. It also allows you to alias directories and specific files, similar to esbuild-plugin-alias. However, it is used within the Babel ecosystem and not directly with esbuild.
rollup-plugin-alias is a plugin for Rollup, yet another module bundler. It offers similar aliasing capabilities as esbuild-plugin-alias, allowing you to define aliases for modules in your Rollup configuration. It is specific to Rollup and is an alternative to esbuild-plugin-alias for projects using Rollup as their bundler.
esbuild plugin for path aliases.
Sometimes it's useful to have dynamic imports that resolves into different files depending on some conditions (e.g. env variables).
npm install --save-dev esbuild-plugin-alias
Define plugin in the plugins
section of esbuild config like this:
const esbuild = require('esbuild');
const alias = require('esbuild-plugin-alias');
esbuild.build({
// ...
plugins: [
alias({
'imported-path': '/home/user/lib/src/resolved-path',
}),
],
})
Note: esbuild requires resolved paths to be absolute. So, make sure that values in plugin's config object are absolute paths.
If you need to find a path to an installed dep, you may use require.resolve
. E.g.:
alias({
'react-dom': process.env.NODE_ENV === 'dev'
? require.resolve('@hot-loader/react-dom')
: require.resolve('react-dom'),
}),
Having this input file:
// src/app.js
import settings from 'settings.env';
console.log(settings);
And esbuild config like this:
// config/build.js
const path = require('path');
const esbuild = require('esbuild');
const alias = require('esbuild-plugin-alias');
esbuild.build({
entryPoints: ['in.js'],
bundle: true,
outfile: 'out.js',
plugins: [
alias({
'settings.env': path.resolve(__dirname, `../src/settings.${process.env.NODE_ENV}.js`),
}),
],
}).catch(err => process.exit(1));
You will get src/settings.dev.js
loaded instead of settings.env
when NODE_ENV
equals dev
.
Check test/ for more detailed example.
FAQs
esbuild plugin for path aliases
The npm package esbuild-plugin-alias receives a total of 697,815 weekly downloads. As such, esbuild-plugin-alias popularity was classified as popular.
We found that esbuild-plugin-alias demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.