This file contains hidden or 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
| import React, { lazy, Suspense } from 'react' | |
| import { render } from 'react-dom' | |
| import { initRequestConfiguration } from 'utils/request' | |
| import { | |
| createShadowDom, | |
| initializeTagManager, | |
| setLocales, | |
| setToken | |
| } from 'startup/utils' |
This file contains hidden or 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
| type FederatedAppRender = (props?: any) => void | |
| export interface FederatedAppList { | |
| [key: string]: () => Promise<FederatedAppRender> | |
| } | |
| export interface FederatedApp { | |
| render?: FederatedAppRender | |
| root: HTMLElement | |
| } |
This file contains hidden or 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
| import React, { lazy, Suspense, useEffect } from 'react' | |
| import { render } from 'react-dom' | |
| import { initRequestConfiguration } from 'utils/request' | |
| import { | |
| initializeTagManager, | |
| setLocales, | |
| setToken | |
| } from 'startup/utils' | |
| import { initRequestConfiguration } from 'utils/request' |
This file contains hidden or 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 is imported as the entrypoint for the Module Federation or UMD bundle. | |
| * Exporting an async function as the project's entrypoint enables Module Federation Plugin to resolve the dependency tree | |
| * before the dependencies are actually used, which enables dependency sharing between modules | |
| */ | |
| export default props => { | |
| import('./bootstrap').then(({ default: bootstrap }) => bootstrap(props)) | |
| } |
This file contains hidden or 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
| /* | |
| * Webpack bundle configuration that enables project export as UMD library and Module Federated container | |
| * | |
| * Custom styleTagTransform script is defined at https://gist.github.com/marcosmapf/904986dde911148e39a17a59dc3dd132 | |
| * The 'from' option attribute is used inside styleTagTransform as a reference to the project's root element | |
| */ | |
| const { join } = require('path') | |
| const { container, EnvironmentPlugin } = require('webpack') |
This file contains hidden or 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
| /* | |
| * Alternative version of StyleTagTransform option of Webpack's style-loader module bundler that enables | |
| * bundled project to insert imported styles on different container elements conditionally. | |
| * This enables usage of Module Federation Apps inside ShadowDom containers. | |
| * | |
| * Users should provide an "attributes" option on the project's Webpack style-loader configuration that contains | |
| * the element's reference on the window object | |
| */ |
This file contains hidden or 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
| /* | |
| Receives an iterable structure containing { target, options } objects and calls fetch on each | |
| Returns a Generator of Promises | |
| */ | |
| export default function* fetchFromIterable(data) { | |
| for (const { target, options = {} } of data) { | |
| yield fetch(target, options) | |
| } | |
| } |
This file contains hidden or 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
| export default const reduce = (iterable, reducer, initial) => { | |
| let acc = initial | |
| for (item of iterable) { | |
| acc = reducer(acc, item) | |
| } | |
| return acc | |
| } |
This file contains hidden or 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
| import React, { useState, useEffect } from 'react'; | |
| const UserCardExample = props => { | |
| const [user, setUser] = useState(""); | |
| const [fetching, setFetching] = useState(true); | |
| const fetchRandomUser = async _ => | |
| await fetch("https://randomuser.me/api") | |
| .then(response => response.json()) | |
| .then(object => object.results[0]); |
This file contains hidden or 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
| const Pusher = require("pusher"); | |
| const Encryptor = require("simple-encryptor"); | |
| const secrets = require("./secrets"); | |
| const pipe = require("./utils/pipe"); | |
| /* | |
| Example of setup and usage of Pusher. Original code made by @mpjme | |
| pipe.js is a vanilla javascript implementation of the pipe function: | |
| const pipe = (...funcList) => input => funcList.reduce((acc, func) => func(acc), input); | |
| module.exports = pipe; |
NewerOlder