Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
acorn-dynamic-import
Advanced tools
The acorn-dynamic-import package is a plugin for the Acorn JavaScript parser that adds support for parsing dynamic import() syntax. This allows developers to use the import() function to dynamically load modules in their JavaScript code, which can be useful for code splitting and lazy loading.
Parsing dynamic import() syntax
This feature allows the Acorn parser to understand and parse the dynamic import() syntax. The code sample demonstrates how to extend the Acorn parser with the acorn-dynamic-import plugin and parse a piece of JavaScript code that uses dynamic import().
const acorn = require('acorn');
const dynamicImport = require('acorn-dynamic-import').default;
const Parser = acorn.Parser.extend(dynamicImport);
const code = 'import("./module.js").then(module => { console.log(module); });';
const ast = Parser.parse(code, { ecmaVersion: 2020 });
console.log(ast);
The babel-plugin-syntax-dynamic-import package is a Babel plugin that allows Babel to parse the dynamic import() syntax. Unlike acorn-dynamic-import, which is a plugin for the Acorn parser, babel-plugin-syntax-dynamic-import is used with Babel to enable the parsing of dynamic imports during the transpilation process.
The es-module-lexer package is a fast, minimal lexer for ES module syntax, including dynamic import() statements. It is designed to be used in environments where performance is critical. Compared to acorn-dynamic-import, es-module-lexer is more focused on performance and minimalism, providing a lightweight solution for identifying ES module imports and exports.
This is plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.
For more information, check out the proposal repo.
Importing this module gives you a plugin that can be used to extend an Acorn parser:
import Parser from 'acorn';
import dynamicImport from 'acorn-dynamic-import';
Parser.extend(dynamicImport).parse('import("something");');
To extend the AST walker for dynamic imports, you can injecting the new node type into acorn-walk
like this:
import inject from 'acorn-dynamic-import/lib/walk';
import * as acornWalk from 'acorn-walk';
const walk = inject(acornWalk);
This plugin is issued under the MIT license.
FAQs
Support dynamic imports in acorn
The npm package acorn-dynamic-import receives a total of 161,544 weekly downloads. As such, acorn-dynamic-import popularity was classified as popular.
We found that acorn-dynamic-import 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.