untitled notebook

node v10.23.3
version: 1.0.0
endpointsharetweet
const BASE_URL = process.env.base; const ASSET_PATH = process.env.asset_path; const css = new Map(); function remove(app_name) { removeChild(css.get(app_name)) css.delete(app_name); }; const make_url = (app_name) => `${BASE_URL}/${app_name}/${asset_path}/css.css`; function get_css(app_name) { return fetch(make_url('navigation')).then(css => { const link = createElement('link'); link.src = `${app_name}/css.css`; css.add(app_name, link); head.appendChild(link) }) } function get_module(app_name) { const parts = await Promise.all([ import(`${app_name}/main.js`), get_css(app_name) ]); return parts[0]; } React.lazy(() => get_module('navigation'))
Loading…

no comments

    sign in to comment