chore: properly specify dependencies

This commit is contained in:
Miralem Drek
2019-05-10 13:47:33 +02:00
parent c48668087d
commit 182ad112d4
3 changed files with 31 additions and 9 deletions

View File

@@ -19,7 +19,17 @@
"lint": "eslint --ext .js,.jsx src",
"prepublishOnly": "rm -rf dist && npm run build"
},
"peerDependencies": {
"@material-ui/styles": "^4.0.0-beta.1",
"@material-ui/icons": "^4.0.0-beta.0",
"@material-ui/core": "^4.0.0-beta.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"@material-ui/styles": "^4.0.0-beta.1",
"@material-ui/icons": "^4.0.0-beta.0",
"@material-ui/core": "^4.0.0-beta.1",
"@nebula.js/supernova": "0.1.0-alpha.10",
"@nebula.js/ui": "0.1.0-alpha.10",
"node-event-emitter": "^0.0.1",

View File

@@ -7,6 +7,13 @@
"author": "QlikTech International AB",
"keywords": [],
"scripts": {},
"peerDependencies": {
"@material-ui/core": "^4.0.0-beta.1",
"@material-ui/icons": "^4.0.0-beta.0",
"@material-ui/styles": "^4.0.0-beta.1",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"@material-ui/core": "^4.0.0-beta.1",
"@material-ui/icons": "^4.0.0-beta.0",

View File

@@ -33,13 +33,6 @@ const GLOBALS = {
'react-dom': 'ReactDOM',
};
const EXTERNALS = [
'react',
'react-dom',
'@material-ui/core',
'@material-ui/styles',
];
const propTypes = [
'array',
'bool',
@@ -68,7 +61,19 @@ const config = (isEsm) => {
const dir = path.dirname(outputFile);
const umdName = basename.replace(/-([a-z])/g, (m, p1) => p1.toUpperCase()).split('.js').join('');
const external = isEsm ? [...EXTERNALS, ...Object.keys(pkg.dependencies || {})] : [];
if (Object.keys(pkg.dependencies || {}).length) {
throw new Error('Dependencies for a web javascript library makes no sense');
}
const peers = Object.keys(pkg.peerDependencies || {});
// all peers should be externals for esm bundle
const esmExternals = peers;
// peers that are not devDeps should be externals for full bundle
const bundleExternals = peers.filter(p => typeof (pkg.devDependencies || {})[p] === 'undefined');
const external = isEsm ? esmExternals : bundleExternals;
const globals = {};
external.forEach((e) => {
if ([GLOBALS[e]]) {
@@ -139,7 +144,7 @@ const config = (isEsm) => {
],
};
if (process.env.NODE_ENV === 'production' && !isEsm) {
if (process.env.NODE_ENV === 'production') {
cfg.plugins.push(terser({
output: {
preamble: banner,