You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

acorn-dynamic-import

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acorn-dynamic-import

Support dynamic imports in acorn


Version published
Weekly downloads
1M
decreased by-8.49%
Maintainers
1
Install size
10.8 kB
Created
Weekly downloads
 

Package description

What is acorn-dynamic-import?

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.

What are acorn-dynamic-import's main functionalities?

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);

Other packages similar to acorn-dynamic-import

Readme

Source

Dynamic import support in acorn

This is plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.

For more information, check out the proposal repo.

Usage

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);

License

This plugin is issued under the MIT license.

FAQs

Package last updated on 01 Oct 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc