Socket
Socket
Sign inDemoInstall

@babel/helper-module-imports

Package Overview
Dependencies
4
Maintainers
5
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-beta.49 to 7.0.0-beta.50

6

package.json
{
"name": "@babel/helper-module-imports",
"version": "7.0.0-beta.49",
"version": "7.0.0-beta.50",
"description": "Babel helper functions for inserting module loads",

@@ -11,8 +11,8 @@ "author": "Logan Smyth <loganfsmyth@gmail.com>",

"dependencies": {
"@babel/types": "7.0.0-beta.49",
"@babel/types": "7.0.0-beta.50",
"lodash": "^4.17.5"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.49"
"@babel/core": "7.0.0-beta.50"
}
}
# @babel/helper-module-imports
## Installation
> Babel helper functions for inserting module loads
```sh
npm install @babel/helper-module-imports --save
```
See our website [@babel/helper-module-imports](https://new.babeljs.io/docs/en/next/babel-helper-module-imports.html) for more information.
## Usage
## Install
### `import "source"`
Using npm:
```js
import { addSideEffect } from "@babel/helper-module-imports";
addSideEffect(path, 'source');
```sh
npm install --save @babel/helper-module-imports
```
### `import { named } from "source"`
or using yarn:
```js
import { addNamed } from "@babel/helper-module-imports";
addNamed(path, 'named', 'source');
```sh
yarn add --save @babel/helper-module-imports
```
### `import { named as _hintedName } from "source"`
```js
import { addNamed } from "@babel/helper-module-imports";
addNamed(path, 'named', 'source', { nameHint: "hintedName" });
```
### `import _default from "source"`
```js
import { addDefault } from "@babel/helper-module-imports";
addDefault(path, 'source');
```
### `import hintedName from "source"`
```js
import { addDefault } from "@babel/helper-module-imports";
addDefault(path, 'source', { nameHint: "hintedName" })
```
### `import * as _namespace from "source"`
```js
import { addNamespace } from "@babel/helper-module-imports";
addNamespace(path, 'source');
```
## Examples
### Adding a named import
```js
import { addNamed } from "@babel/helper-module-imports";
export default function({ types: t }) {
return {
visitor: {
ReferencedIdentifier(path) {
let importName = this.importName;
if (importName) {
importName = t.cloneDeep(importName);
} else {
// require('bluebird').coroutine
importName = this.importName = addNamed(path, 'coroutine', 'bluebird');
}
path.replaceWith(importName);
}
},
};
}
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc