Skip to content

Commit 093fe75

Browse files
committed
feat(JSX asset_path) document asset_path config
1 parent 2f5955c commit 093fe75

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ You can use JSX `--harmony` or `--strip-types` options by adding a configuration
8080
config.react.jsx_transform_options = {
8181
harmony: true,
8282
strip_types: true, # for removing Flow type annotations
83+
asset_path: "path/to/JSXTransformer.js", # if your JSXTransformer is somewhere else
8384
}
8485
```
8586

lib/react/jsx/transformer.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ class Transformer
44
DEFAULT_ASSET_PATH = 'JSXTransformer.js'
55

66
def initialize(options)
7-
@strip_types = options.fetch(:strip_types, false)
8-
@harmony = options.fetch(:harmony, false)
9-
@asset_path = options.fetch(:asset_path, DEFAULT_ASSET_PATH)
7+
@transform_options = {
8+
stripTypes: options.fetch(:strip_types, false),
9+
harmony: options.fetch(:harmony, false),
10+
}
11+
12+
@asset_path = options.fetch(:asset_path, DEFAULT_ASSET_PATH)
1013

1114
# If execjs uses therubyracer, there is no 'global'. Make sure
1215
# we have it so JSX script can work properly.
@@ -16,7 +19,7 @@ def initialize(options)
1619

1720

1821
def transform(code)
19-
result = @context.call('JSXTransformer.transform', code, {stripTypes: @strip_types, harmony: @harmony})
22+
result = @context.call('JSXTransformer.transform', code, @transform_options)
2023
result["code"]
2124
end
2225

0 commit comments

Comments
 (0)