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

@ -17,49 +17,90 @@ if (dev) require('dotenv').config();
const manifest = entryManifest();
const client = {
input: ['modules/client/main.js', 'modules/client/autoIndex.js'],
output: [
{
// ESM version for modern browsers
format: 'esm',
const client = ['main', 'autoIndex'].map(entryName => {
return {
external: ['react', 'react-dom', '@emotion/core'],
input: `modules/client/${entryName}.js`,
output: {
format: 'iife',
dir: 'public/_client',
entryFileNames: '[name]-[hash].js',
chunkFileNames: '[name]-[hash].js'
},
{
// SystemJS version for older browsers
format: 'system',
dir: 'public/_client',
entryFileNames: '[name]-[hash].system.js',
chunkFileNames: '[name]-[hash].system.js'
}
],
plugins: [
manifest.record({ publicPath: '/_client/' }),
babel({ exclude: /node_modules/ }),
json(),
resolve(),
commonjs({
namedExports: {
'node_modules/react/index.js': [
'createContext',
'createElement',
'forwardRef',
'Component',
'Fragment'
]
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'@emotion/core': 'emotionCore'
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
}),
url({
limit: 5 * 1024,
publicPath: '/_client/'
})
]
};
},
plugins: [
manifest.record({ publicPath: '/_client/' }),
babel({ exclude: /node_modules/ }),
json(),
resolve(),
commonjs({
namedExports: {
'node_modules/react/index.js': [
'createContext',
'createElement',
'forwardRef',
'Component',
'Fragment'
]
}
}),
replace({
'process.env.NODE_ENV': JSON.stringify(env)
}),
url({
limit: 5 * 1024,
publicPath: '/_client/'
})
]
};
});
// const client = {
// input: ['modules/client/main.js', 'modules/client/autoIndex.js'],
// output: [
// {
// // ESM version for modern browsers
// format: 'esm',
// dir: 'public/_client',
// entryFileNames: '[name]-[hash].js',
// chunkFileNames: '[name]-[hash].js'
// },
// {
// // SystemJS version for older browsers
// format: 'system',
// dir: 'public/_client',
// entryFileNames: '[name]-[hash].system.js',
// chunkFileNames: '[name]-[hash].system.js'
// }
// ],
// plugins: [
// manifest.record({ publicPath: '/_client/' }),
// babel({ exclude: /node_modules/ }),
// json(),
// resolve(),
// commonjs({
// namedExports: {
// 'node_modules/react/index.js': [
// 'createContext',
// 'createElement',
// 'forwardRef',
// 'Component',
// 'Fragment'
// ]
// }
// }),
// replace({
// 'process.env.NODE_ENV': JSON.stringify(env)
// }),
// url({
// limit: 5 * 1024,
// publicPath: '/_client/'
// })
// ]
// };
const secretKey = require('./secretKey');
const fnsPkg = require('./functions/package.json');
@ -127,4 +168,4 @@ const functions = [
})
);
module.exports = [client].concat(functions);
module.exports = client.concat(functions);