Inline scripts in HTML files

This commit is contained in:
Michael Jackson
2019-01-24 15:49:21 -08:00
parent e6134b0969
commit ea85062ff6
16 changed files with 350 additions and 136 deletions

View File

@ -1,17 +0,0 @@
// Virtual module id; see rollup.config.js
import entryManifest from 'entry-manifest';
export default function getEntryPoint(name, format) {
let entryPoints;
entryManifest.forEach(manifest => {
if (name in manifest) {
entryPoints = manifest[name];
}
});
if (entryPoints) {
return entryPoints.find(e => e.format === format);
}
return null;
}

View File

@ -1,16 +0,0 @@
import invariant from 'invariant';
import getEntryPoint from './getEntryPoint';
export default function getScripts(entryName, globalURLs) {
const entryPoint = getEntryPoint(entryName, 'iife');
invariant(entryPoint, 'Invalid entry name "%s"', entryName);
const globalScripts = entryPoint.globalImports.map(id => {
invariant(globalURLs[id], 'Missing global URL for id "%s"', id);
return globalURLs[id];
});
return globalScripts.concat(entryPoint.url);
}

View File

@ -1,11 +0,0 @@
import React from 'react';
import ReactDOMServer from 'react-dom/server';
const doctype = '<!DOCTYPE html>';
export default function renderTemplate(component, props) {
return (
doctype +
ReactDOMServer.renderToStaticMarkup(React.createElement(component, props))
);
}