Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.

Commit 46403e0

Browse files
committed
Rename target to transform
1 parent 0d02bad commit 46403e0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,24 @@ It must be an array of the transforms you want to use:
5151
"react-transform": {
5252
"transforms": [{
5353
// can be an NPM module name or a local path
54-
"target": "react-transform-webpack-hmr",
54+
"transform": "react-transform-webpack-hmr",
5555
// see specific transform's docs for "imports" and "locals" it needs
5656
"imports": ["react"],
5757
"locals": ["module"]
5858
}, {
5959
// you can have many transforms, not just one
60-
"target": "react-transform-catch-errors",
60+
"transform": "react-transform-catch-errors",
6161
"imports": ["react", "redbox-react"]
6262
}, {
6363
// can be an NPM module name or a local path
64-
"target": "./src/my-custom-transform"
64+
"transform": "./src/my-custom-transform"
6565
}]
6666
}
6767
}
6868
}
6969
```
7070

71-
As you can see each transform, apart from the `target` field where you write it name, also has `imports` and `locals` fields. You should consult the docs of each individual transform to learn which `imports` and `locals` it might need, and how it uses them. You probably already guessed that this is just a way to inject local variables (like `module`) or dependencies (like `react`) into the transforms that need them.
71+
As you can see each transform, apart from the `transform` field where you write it name, also has `imports` and `locals` fields. You should consult the docs of each individual transform to learn which `imports` and `locals` it might need, and how it uses them. You probably already guessed that this is just a way to inject local variables (like `module`) or dependencies (like `react`) into the transforms that need them.
7272

7373
## Writing a Transform
7474

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default function ({ Plugin, types: t }) {
176176
*/
177177
function defineInitTransformCall(scope, file, recordsId, targetOptions) {
178178
const id = scope.generateUidIdentifier('reactComponentWrapper');
179-
const { target, imports = [], locals = [] } = targetOptions;
179+
const { transform, imports = [], locals = [] } = targetOptions;
180180
const { filename } = file.opts;
181181

182182
function isSameAsFileBeingProcessed(importPath) {
@@ -190,7 +190,7 @@ export default function ({ Plugin, types: t }) {
190190

191191
return [id, t.variableDeclaration('var', [
192192
t.variableDeclarator(id,
193-
t.callExpression(file.addImport(resolvePath(target, filename)), [
193+
t.callExpression(file.addImport(resolvePath(transform, filename)), [
194194
t.objectExpression([
195195
t.property('init', t.identifier('filename'), t.literal(filename)),
196196
t.property('init', t.identifier('components'), recordsId),

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ describe('finds React components', () => {
1919
extra: {
2020
'react-transform': {
2121
transforms: [{
22-
target: 'my-custom-module/wrap',
22+
transform: 'my-custom-module/wrap',
2323
locals: ['module'],
2424
imports: ['react']
2525
}, {
26-
target: 'my-other-custom-module/wrap'
26+
transform: 'my-other-custom-module/wrap'
2727
}]
2828
}
2929
}

0 commit comments

Comments
 (0)