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:
17
modules/utils/getEntryPoint.js
Normal file
17
modules/utils/getEntryPoint.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
import invariant from 'invariant';
|
||||
|
||||
// Virtual module id; see rollup.config.js
|
||||
import entryManifest from 'entry-manifest';
|
||||
|
||||
export default function getEntryPoints(entryName, formatKeys) {
|
||||
const manifest = entryManifest[entryName];
|
||||
|
||||
invariant(manifest, 'Invalid entry name: %s', entryName);
|
||||
|
||||
return manifest.reduce((memo, entryPoint) => {
|
||||
if (entryPoint.format in formatKeys) {
|
||||
const key = formatKeys[entryPoint.format];
|
||||
memo[key] = entryPoint.url;
|
||||
}
|
||||
|
||||
return memo;
|
||||
}, {});
|
||||
}
|
16
modules/utils/getScripts.js
Normal file
16
modules/utils/getScripts.js
Normal file
@ -0,0 +1,16 @@
|
||||
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);
|
||||
}
|
Reference in New Issue
Block a user