
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
babel-plugin-amd-checker
Advanced tools
Module format checking plugin for Babel usable in both Node.js the web browser environments.
A Babel plugin to check the format of your modules when compiling your code using Babel. This plugin allows you to abort the module transformation, if the module source complies with AMD and let the transformation apply only on ESM modules. transform the path of each source module using a custom JavaScript function.
This plugin is supposed to be used with requirejs-babel7, where the target environment is a web browser using @babel/standalone. If if detects an AMD module, it will throw an error of the class AmdDetected
and abort the module transformation. The error can be caught and ignored in the build pipeline.
This module can be installed in your project using NPM, PNPM or Yarn. Make sure, that you use Node.js version 6 or newer.
npm i -D babel-plugin-amd-checker
pnpm i -D babel-plugin-amd-checker
yarn add babel-plugin-amd-checker
Prevent the transpiler to wrap source files that are already wrapped by define
or require
as AMD modules:
{
plugins: ['amd-checker']
}
A typical configuration combined with babel-plugin-module-resolver-standalone and set within requirejs-babel7 by default:
{
plugins: [
'amd-checker',
'transform-modules-amd',
[
'module-resolver',
{
resolvePath: function (sourcePath, currentFile, opts) {
// Avoid prefixing modules handled by other plugins.
if (sourcePath.indexOf('!') < 0) {
return 'es6!' + sourcePath;
}
}
}
]
]
}
Error handling during the transpilation in a RequireJS plugin:
var amdChecker = require('babel-plugin-amd-checker')
babel.registerPlugin('amd-checker', amdChecker);
var code;
try {
code = babel.transform(text, options).code;
} catch (error) {
if (!(error instanceof amdChecker.AmdDetected)) {
return onload.error(error);
}
code = text;
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Lint and test your code.
Copyright (c) 2022 Ferdinand Prantl
Licensed under the MIT license.
FAQs
Module format checking plugin for Babel usable in both Node.js the web browser environments.
The npm package babel-plugin-amd-checker receives a total of 0 weekly downloads. As such, babel-plugin-amd-checker popularity was classified as not popular.
We found that babel-plugin-amd-checker 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
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.