-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Quick export for react components and new RHL
- Loading branch information
Showing
7 changed files
with
104 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* @flow */ | ||
import resolveToCwd from "./../utils/resolve-to-cwd"; | ||
import { resolveModuleToCwd } from "./../utils/npm"; | ||
|
||
type Aliases = { [string]: string }; | ||
const aliases: Aliases = {}; | ||
|
||
export default function createAliases( | ||
filename: string, | ||
flags: CLIFlags | ||
): Aliases { | ||
if (flags.react) { | ||
return Object.assign(aliases, { | ||
aikReactEntryPoint: resolveToCwd(filename), | ||
react: resolveModuleToCwd("react"), | ||
"react-dom": resolveModuleToCwd("react-dom") | ||
}); | ||
} | ||
|
||
return aliases; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const React = require("react"); | ||
const ReactDOM = require("react-dom"); | ||
|
||
function renderEntry(exported) { | ||
if (exported.default) { | ||
exported = exported.default; | ||
} | ||
|
||
// Assumptions: the entry module either renders the app itself or exports a | ||
// React component (which is either a function or class) or element (which has | ||
// type and props properties). | ||
var element; | ||
if (Object.prototype.toString.call(exported) === "[object Function]") { | ||
element = React.createElement(exported); | ||
} else if (exported.type && exported.props) { | ||
element = exported; | ||
} | ||
if (element) { | ||
// eslint-disable-next-line | ||
ReactDOM.render(element, document.getElementById("app")); | ||
} | ||
} | ||
|
||
renderEntry(require("aikReactEntryPoint")); | ||
|
||
if (module.hot && process.env.NODE_ENV !== "production") { | ||
// eslint-disable-next-line | ||
module.hot.accept("aikReactEntryPoint", function() { | ||
renderEntry(require("aikReactEntryPoint")); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters