
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
babel-plugin-system-import-transformer
Advanced tools
Babel plugin that replaces System.import with the equivalent UMD pattern
Babel plugin that replaces import() & System.import() with the equivalent UMD pattern
import('./utils/serializer').then(function(module){
console.log(module);
});
// AND
System.import('./utils/serializer').then(function(module){
console.log(module);
});
to
new Promise(function (resolve, reject) {
var global = window;
if (typeof global.define === 'function' && global.define.amd) {
global.require(['utilsSerializer'], resolve, reject);
} else if (typeof module !== 'undefined' && (module.exports && typeof require !== 'undefined') ||
typeof module !== 'undefined' && (module.component && (global.require && global.require.loader === 'component'))) {
resolve(require('./utils/serializer'));
} else {
resolve(global['utilsSerializer']);
}
}).then(function(module){
console.log(module);
});
Notes:
npm install babel-plugin-system-import-transformer
Add "system-import-transformer" to your plugins
argument or inside the plugins
options of your Gruntfile
.
// in .babelrc
{
"plugins": [
"system-import-transformer"
]
}
// in grunt.js
babel: {
options: {
plugins: ["system-import-transformer"]
}
}
The babel's getModuleId option (if defined) is used for the AMD and Global Module import.
babel: {
options: {
moduleIds: true,
getModuleId: function(moduleName) {
var files = {
'src/utils/serializer': 'utilsSerializer'
};
return files[moduleName] || moduleName.replace('src/', '');
},
plugins: ['system-import-transformer']
}
}
CommonJS specific options.
Type: Boolean
Values: [false
/true
]
When set to true
, all CommonJS import statements will use Webpack's require.ensure()
syntax. This enables dynamic module loading in CommonJS (Webpack) and works both for the UMD
and (of course) CommonJS
module target types.
{
"plugins": [
["system-import-transformer", { "commonJS": { "useRequireEnsure": true } }]
]
}
// the CommonJS code part will look like:
new Promise(function (resolve) {
require.ensure([], function (require) {
resolve(require('./utils/serializer'));
});
}).then(function(module){ console.log(module); });
Type: String
Values: [UMD
/amd
/common
]
Example
Specifies the target compilation module system. When set configured to an option other than UMD
then system-import-transformer
will omit the module type detection code and just insert the appropriate require statement wrapped with a Promise
.
// targeting AMD
{
"plugins": [
["system-import-transformer", { "modules": "amd" }]
]
}
// will emit an AMD specific code like:
new Promise(function (resolve, reject) {
var global = window;
global.require(['utilsSerializer'], resolve, reject);
}).then(function(module){ console.log(module); });
// targeting CommonJS
{
"plugins": [
["system-import-transformer", { "modules": "common" }]
]
}
// will emit a CommonJS specific code like:
new Promise(function (resolve, reject) {
resolve(require('./utils/serializer'));
}).then(function(module){ console.log(module); });
Syntax specific options.
Type: Boolean
Values: [true
/false
]
Example
When set to false
, babel will not transpile import()
statements.
Type: Boolean
Values: [true
/false
]
Example
When set to false
, babel will not transpile System.import()
statements.
FAQs
Babel plugin that replaces System.import with the equivalent UMD pattern
The npm package babel-plugin-system-import-transformer receives a total of 21,118 weekly downloads. As such, babel-plugin-system-import-transformer popularity was classified as popular.
We found that babel-plugin-system-import-transformer 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.