Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
babel-plugin-transform-dynamic-imports-to-static-imports
Advanced tools
transform dynamic import to static imports
Weekly downloads
Readme
A transform to translate dynamic imports to static imports
npm install babel-plugin-transform-dynamic-imports-to-static-imports
with configuration file:
{
"plugins": ["babel-plugin-transform-dynamic-imports-to-static-imports"]
}
Via CLI
babel --plugins babel-plugin-transform-dynamic-imports-to-static-imports script.js
via node API
require("@babel/core").transform("code", {
plugins: ["babel-plugin-transform-dynamic-imports-to-static-imports"],
});
input:
import * as zero from "./zero";
import "./one";
async function test() {
import("./two");
await import("./three");
import("./four")
.then((test) => {
/* do something */
})
.then();
await import("./five").then((test) => {
/* do something */
});
}
output:
import * as $$1 from "./five";
import * as $$0 from "./four";
import "./three";
import "./two";
import * as zero from "./zero";
import "./one";
async function test() {
Promise.resolve($$0)
.then((test) => {
/* do something */
})
.then();
await Promise.resolve($$1).then((test) => {
/* do something */
});
}
for more examples see test.js
dynamic imports with dynamic paths do not have a static equivalent.
async function test() {
import(`dynamic${test}`);
await import(`dynamic${test}`);
import(`dynamic${test}`)
.then((test) => {
/* do something */
})
.then();
await import(`dynamic${test}`).then((test) => {
/* do something */
});
}
will output:
async function test() {
import(`dynamic${test}`);
await import(`dynamic${test}`);
import(`dynamic${test}`)
.then((test) => {
/* do something */
})
.then();
await import(`dynamic${test}`).then((test) => {
/* do something */
});
}
for more examples see test.js
FAQs
transform dynamic import to static imports
The npm package babel-plugin-transform-dynamic-imports-to-static-imports receives a total of 666 weekly downloads. As such, babel-plugin-transform-dynamic-imports-to-static-imports popularity was classified as not popular.
We found that babel-plugin-transform-dynamic-imports-to-static-imports demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.