babel-plugin-transform-inline-imports-commonjs
Advanced tools
Comparing version 1.1.0 to 1.2.0
# Changelog | ||
## v1.2.0 (2016-10-19) | ||
* Added `excludeModules` option. | ||
## v1.1.0 (2016-10-17) | ||
* Added `excludeNodeBuiltins` option. |
{ | ||
"name": "babel-plugin-transform-inline-imports-commonjs", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A Babel transform that turns imports into lazily loaded commonjs requires", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -77,4 +77,12 @@ # babel-plugin-transform-inline-imports-commonjs | ||
* `excludeModules`: | ||
- An array of strings that correspond to module IDs that should not be "inline-import"'ed. For the config `"excludeModules": ["atom"]`: | ||
```js | ||
import {TextEditor} from 'atom'; // transforms to plain `require` with interop | ||
import foo from 'bar'; // transforms to inline import | ||
``` | ||
* `excludeNodeBuiltins` (default: `false`) | ||
- Do not apply "inline-imports" to[Node builtin modules](https://github.com/sindresorhus/builtin-modules/blob/v1.1.1/builtin-modules.json). These modules are usually already in the module cache, so there may be no need to lazily load them. | ||
- Do not apply "inline-imports" to [Node builtin modules](https://github.com/sindresorhus/builtin-modules/blob/v1.1.1/builtin-modules.json). These modules are usually already in the module cache, so there may be no need to lazily load them. | ||
@@ -81,0 +89,0 @@ ```js |
@@ -185,2 +185,9 @@ 'use strict'; | ||
const excludeNodeBuiltins = this.opts.excludeNodeBuiltins | ||
? builtinModules | ||
: null; | ||
const excludeModules = Array.isArray(this.opts.excludeModules) | ||
? new Set(this.opts.excludeModules) | ||
: null; | ||
const addRequire = (source, blockHoist, interop) => { | ||
@@ -200,3 +207,6 @@ const cacheKey = JSON.stringify({source, interop}); | ||
if (this.opts.excludeNodeBuiltins && builtinModules.has(source)) { | ||
if ( | ||
(excludeNodeBuiltins && excludeNodeBuiltins.has(source)) || | ||
(excludeModules && excludeModules.has(source)) | ||
) { | ||
// var memoizedID; | ||
@@ -203,0 +213,0 @@ const declID = path.scope.generateUidIdentifier(source); |
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
23387
455
92