Load React + Emotion from CDN URLs, use globals

Remove @emotion/babel-preset-css-prop and import { jsx } from
@emotion/core directly instead so Rollup can preserve imports order when
bundling (instead of @emotion/core automatically inserting itself as the
first import).
This commit is contained in:
Michael Jackson
2019-01-23 21:27:58 -08:00
parent 6228f0de5c
commit bbb092d974
117 changed files with 109774 additions and 1773 deletions

View File

@ -5,9 +5,22 @@ import semver from 'semver';
import MainTemplate from '../client/MainTemplate';
import AutoIndexApp from '../client/autoIndex/App';
import createHTML from '../client/utils/createHTML';
import getEntryPoints from '../utils/getEntryPoints';
import getScripts from '../utils/getScripts';
import renderTemplate from '../utils/renderTemplate';
const globalURLs =
process.env.NODE_ENV === 'production'
? {
'@emotion/core': '/@emotion/core@10.0.6/dist/core.umd.min.js',
react: '/react@16.7.0/umd/react.production.min.js',
'react-dom': '/react-dom@16.7.0/umd/react-dom.production.min.js'
}
: {
'@emotion/core': '/@emotion/core@10.0.6/dist/core.umd.min.js',
react: '/react@16.7.0/umd/react.development.js',
'react-dom': '/react-dom@16.7.0/umd/react-dom.development.js'
};
function byVersion(a, b) {
return semver.lt(a, b) ? -1 : semver.gt(a, b) ? 1 : 0;
}
@ -26,17 +39,14 @@ export default function serveAutoIndexPage(req, res) {
ReactDOMServer.renderToString(React.createElement(AutoIndexApp, data))
);
const entryPoints = getEntryPoints('autoIndex', {
es: 'module',
system: 'nomodule'
});
const scripts = getScripts('autoIndex', globalURLs);
const html = renderTemplate(MainTemplate, {
title: `UNPKG - ${req.packageName}`,
description: `The CDN for ${req.packageName}`,
data,
content,
entryPoints
scripts
});
res