baset-reader-babel
Advanced tools
Comparing version 0.14.4 to 0.14.5
@@ -6,2 +6,15 @@ # Change Log | ||
<a name="0.14.5"></a> | ||
## [0.14.5](https://github.com/Igmat/baset/compare/v0.14.4...v0.14.5) (2018-10-09) | ||
### Bug Fixes | ||
* **reader-babel:** option to include node modules in transpilation ([6b8a186](https://github.com/Igmat/baset/commit/6b8a186)) | ||
* **reader-babel:** proper work with possibly undefined options ([393f284](https://github.com/Igmat/baset/commit/393f284)) | ||
<a name="0.14.4"></a> | ||
@@ -8,0 +21,0 @@ ## [0.14.4](https://github.com/Igmat/baset/compare/v0.14.3...v0.14.4) (2018-10-07) |
import { AbstractReader, AddFileResolver, AddHook } from 'baset-core'; | ||
export interface IBabelReaderOptions { | ||
config: any; | ||
includeNodeModules?: boolean; | ||
} | ||
export default class BabelReader extends AbstractReader { | ||
pluginsOptions: IBabelReaderOptions; | ||
options: IBabelReaderOptions; | ||
private exts; | ||
private config; | ||
constructor(pluginsOptions: IBabelReaderOptions); | ||
constructor(options?: IBabelReaderOptions); | ||
read: (filePath: string, spec: Promise<string | string[]>) => Promise<string | string[]>; | ||
@@ -11,0 +12,0 @@ registerHook: (addHook: AddHook, addFileResolver: AddFileResolver) => void; |
@@ -18,5 +18,5 @@ "use strict"; | ||
class BabelReader extends baset_core_1.AbstractReader { | ||
constructor(pluginsOptions) { | ||
super(pluginsOptions); | ||
this.pluginsOptions = pluginsOptions; | ||
constructor(options = { config: {} }) { | ||
super(options); | ||
this.options = options; | ||
this.exts = [...babel_core_1.util.canCompile.EXTENSIONS]; | ||
@@ -31,3 +31,7 @@ this.read = (filePath, spec) => __awaiter(this, void 0, void 0, function* () { | ||
this.registerHook = (addHook, addFileResolver) => { | ||
addHook(this.compile, { exts: this.exts, matcher: filename => !filename.includes('node_modules') }); | ||
addHook(this.compile, { | ||
exts: this.exts, | ||
matcher: filename => (this.options && this.options.includeNodeModules) || | ||
!filename.includes('node_modules'), | ||
}); | ||
}; | ||
@@ -41,3 +45,3 @@ this.compile = (code, filename) => { | ||
}; | ||
this.config = pluginsOptions && pluginsOptions.config || {}; | ||
this.config = options.config; | ||
} | ||
@@ -44,0 +48,0 @@ } |
{ | ||
"name": "baset-reader-babel", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"description": "Babel reader plugin for BaseT project.", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "2779da77d49a8f18590a0209f76e6d131200365f" | ||
"gitHead": "7a70e502e77bb51273f1f45914639909b8c3d496" | ||
} |
@@ -23,2 +23,16 @@ [![Known Vulnerabilities](https://snyk.io/test/npm/baset-reader-babel/badge.svg)](https://snyk.io/test/npm/baset-reader-babel) | ||
``` | ||
No additional options available for this plugin for now. | ||
You may also specify additional options for this plugin under `baset.options` section in your `package.json` or `options` section in your `.basetrc`/`.basetrc.json`: | ||
```JavaScript | ||
"baset-reader-babel": { | ||
// by default this reader uses the same strategy for resolving configuration | ||
// as babel, but you may want to specify some additional settings only for tests | ||
// this options gives you such an opportunity | ||
"config": { | ||
// your additional configuration for babel | ||
}, | ||
// by default any files inside node_modules are explicitly ignored | ||
// but in some cases you may want to transpile them as well, | ||
// in order to do so, just set this option to true | ||
"includeNodeModules": true | ||
} | ||
``` |
Sorry, the diff of this file is not supported yet
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
12269
60
38