Skip to content

Commit

Permalink
add a symbol to toggle whether to use React with or without addons
Browse files Browse the repository at this point in the history
(fixes #4), prepare for release
  • Loading branch information
jochenberger committed Nov 23, 2016
1 parent 1b19f7e commit bade81b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ respositories {
}
dependencies {
runtime 'de.eddyson:tapestry-react:0.17.0'
runtime 'de.eddyson:tapestry-react:0.17.1'
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
description = "Use React together with Tapestry"

group = "de.eddyson"
version = "0.17.0"
version = "0.17.1"

apply plugin: 'groovy'
apply plugin: 'maven'
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/de/eddyson/tapestry/react/ReactModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ public final class ReactModule {
@Contribute(ModuleManager.class)
public static void setupJSModules(final MappedConfiguration<String, JavaScriptModuleConfiguration> configuration,
final AssetSource assetSource, @Symbol(SymbolConstants.PRODUCTION_MODE) final boolean productionMode,
@Symbol(ReactSymbols.USE_REACT_WITH_ADDONS) final boolean useReactWithAddons,
@Symbol(ReactSymbols.REACT_ASSET_PATH) final String reactAssetPath,
@Symbol(ReactSymbols.REACT_ASSET_PATH_PRODUCTION) final String reactAssetPathProduction,
@Symbol(ReactSymbols.REACT_WITH_ADDONS_ASSET_PATH) final String reactWithAddonsAssetPath,
@Symbol(ReactSymbols.REACT_WITH_ADDONS_ASSET_PATH_PRODUCTION) final String reactWithAddonsAssetPathProduction,
@Symbol(ReactSymbols.REACT_DOM_ASSET_PATH) final String reactDomAssetPath,
@Symbol(ReactSymbols.REACT_DOM_ASSET_PATH_PRODUCTION) final String reactDomAssetPathProduction) {

configuration.add("react", new JavaScriptModuleConfiguration(
assetSource.resourceForPath(productionMode ? reactAssetPathProduction : reactAssetPath)));
String reactAssetPathToUse = useReactWithAddons
? (productionMode ? reactWithAddonsAssetPathProduction : reactWithAddonsAssetPath)
: (productionMode ? reactAssetPathProduction : reactAssetPath);

configuration.add("react", new JavaScriptModuleConfiguration(assetSource.resourceForPath(reactAssetPathToUse)));
configuration.add("react-dom", new JavaScriptModuleConfiguration(
assetSource.resourceForPath(productionMode ? reactDomAssetPathProduction : reactDomAssetPath)));
}
Expand Down Expand Up @@ -114,8 +120,12 @@ public static void addLibraryMapping(final Configuration<LibraryMapping> configu
public static void setupDefaultConfiguration(final MappedConfiguration<String, Object> configuration) {
configuration.add(ReactSymbols.USE_COLORED_BABEL_OUTPUT, true);
configuration.add(ReactSymbols.USE_NODE_IF_AVAILABLE, true);
configuration.add(ReactSymbols.USE_REACT_WITH_ADDONS, false);
configuration.add(ReactSymbols.REACT_ASSET_PATH, "webjars:react:$version/react.js");
configuration.add(ReactSymbols.REACT_ASSET_PATH_PRODUCTION, "webjars:react:$version/react.min.js");
configuration.add(ReactSymbols.REACT_WITH_ADDONS_ASSET_PATH, "webjars:react:$version/react-with-addons.js");
configuration.add(ReactSymbols.REACT_WITH_ADDONS_ASSET_PATH_PRODUCTION,
"webjars:react:$version/react-with-addons.min.js");
configuration.add(ReactSymbols.REACT_DOM_ASSET_PATH, "webjars:react:$version/react-dom.js");
configuration.add(ReactSymbols.REACT_DOM_ASSET_PATH_PRODUCTION, "webjars:react:$version/react-dom.min.js");
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/de/eddyson/tapestry/react/ReactSymbols.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ public final class ReactSymbols {

public static final String REACT_ASSET_PATH_PRODUCTION = "tapestry.react.react_asset_path_production";

public static final String REACT_WITH_ADDONS_ASSET_PATH = "tapestry.react.react_with_addons_asset_path";

public static final String REACT_WITH_ADDONS_ASSET_PATH_PRODUCTION = "tapestry.react.react_with_addons_asset_path_production";

public static final String REACT_DOM_ASSET_PATH = "tapestry.react.react_dom_asset_path";

public static final String REACT_DOM_ASSET_PATH_PRODUCTION = "tapestry.react.react_dom_asset_path_production";

public static final String USE_REACT_WITH_ADDONS = "tapestry.react.use_react_with_addons";


private ReactSymbols() {
}
}

0 comments on commit bade81b

Please sign in to comment.