Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
babel-plugin-dynamic-import-node
Advanced tools
Babel plugin to transpile import() to a deferred require(), for node
The babel-plugin-dynamic-import-node package is a Babel plugin that transpiles the ECMAScript dynamic import() syntax to a deferred require() call. This transformation allows for code splitting and dynamic module loading in environments that do not natively support the import() syntax. It is particularly useful for server-side applications or tests running in Node.js where dynamic import is not available or practical.
Transpile import() to require()
This feature allows developers to use the dynamic import() syntax in their code, which babel-plugin-dynamic-import-node will transpile into a deferred require() call. This enables dynamic module loading and code splitting in environments that do not support import() natively.
import('path/to/module').then(module => {\n // Use module\n});
This package allows Babel to parse the dynamic import() syntax. However, unlike babel-plugin-dynamic-import-node, it does not transpile import() to require(). It's used in conjunction with other plugins or presets that handle the transformation or in environments that support dynamic imports.
Similar to babel-plugin-dynamic-import-node, this plugin transforms dynamic import() syntax into a require() call. The difference lies in the implementation details and the specific use cases they target. While babel-plugin-dynamic-import-node is focused on Node.js environments, babel-plugin-transform-dynamic-import may offer broader compatibility or different configuration options.
Babel plugin to transpile import()
to a deferred require()
, for node. Matches the proposed spec.
NOTE: Babylon >= v6.12.0 is required to correctly parse dynamic imports.
npm install babel-plugin-dynamic-import-node --save-dev
.babelrc
(Recommended).babelrc
{
"plugins": ["dynamic-import-node"]
}
noInterop
- A boolean value, that if true will not interop the require calls. Useful to avoid using require('module').default
on commonjs modules.{
"plugins": [
["dynamic-import-node", { "noInterop": true }]
]
}
$ babel --plugins dynamic-import-node script.js
require('babel-core').transform('code', {
plugins: ['dynamic-import-node']
});
Promise.all([
import('./lib/import1'),
import('./lib/import2')
]).then(([
Import1,
Import2
]) => {
console.log(Import1);
/* CODE HERE*/
});
v2.3.3
FAQs
Babel plugin to transpile import() to a deferred require(), for node
The npm package babel-plugin-dynamic-import-node receives a total of 3,721,311 weekly downloads. As such, babel-plugin-dynamic-import-node popularity was classified as popular.
We found that babel-plugin-dynamic-import-node demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.