@babel/helper-module-imports
Advanced tools
Comparing version 7.0.0-beta.49 to 7.0.0-beta.50
{ | ||
"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); | ||
} | ||
}, | ||
}; | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16237
6
20
+ Added@babel/types@7.0.0-beta.50(transitive)
- Removed@babel/types@7.0.0-beta.49(transitive)
Updated@babel/types@7.0.0-beta.50