Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
babel-esm-plugin
Advanced tools
Add this plugin to generate mirrored esm modules for your existing bundles
Add this plugin to generate mirrored esm modules for your existing bundles. You may use these bundles in module/nomodule
in your web-app and ship less transpiled code to your users.
Works with Webpack4 and Babel7
npm i -D babel-esm-plugin
This plugin only works when you're already using babel-preset-env
.
Also, there is an expectation that your babel-preset-env
is configured in the shape:
{
use: {
loader: 'babel-loader',
options: {
"presets": [["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
....
}]]
},
},
}
new BabelEsmPlugin({
filename: '[name].es6.js',
chunkFilename: '[id].es6.js',
excludedPlugins: [...],
additionalPlugins: [...],
beforeStartExecution: function(plugins, babelConfig) {}
});
filename
: Output name of es6 bundles. (default: '[name].es6.js')chunkFilename
: Output name of es6 chunks. (default: '[id].es6.js')excludedPlugins
: List of plugins you want to exclude from generating es6 bundles.additionalPlugins
: List of plugins you want to add while generating es6 bundles.beforeStartExecution
: A callback function which passes all plugins and the new babel config, to a function where the user can modify them before starting the ESM
build.A usual output from webpack output looks like this:
With this plugin added, you will be generating es6 outputs:
const BabelEsmPlugin = require('babel-esm-plugin');
module.exports = {
entry: {
index: './index.js',
home: './index2.js'
},
output: {
filename: "[name].js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
"presets": [["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}]]
},
},
}
]
},
plugins: [
new BabelEsmPlugin()
]
}
FAQs
Add this plugin to generate mirrored esm modules for your existing bundles
We found that babel-esm-plugin 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.