@hpcc-js/bundle
Advanced tools
Comparing version 0.0.14 to 0.0.15
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const rollup = require("rollup"); | ||
const alias = require("rollup-plugin-alias"); | ||
const commonjs = require("rollup-plugin-commonjs"); | ||
const resolve = require("rollup-plugin-node-resolve"); | ||
const postcss = require("rollup-plugin-postcss"); | ||
const sourcemaps = require("rollup-plugin-sourcemaps"); | ||
const uglify = require("rollup-plugin-uglify"); | ||
const program = require("commander"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const process = require("process"); | ||
program | ||
.version("0.0.1") | ||
.option("-m, --min", "Minimize") | ||
.parse(process.argv); | ||
const aliases = {}; | ||
const externals = []; | ||
const globals = {}; | ||
const deps = {}; | ||
const webpackShims = ["@hpcc-js/dgrid-shim", "@hpcc-js/ddl-shim", "@hpcc-js/c3-shim"]; | ||
function walkDependencies(folder, depth = 0) { | ||
const pkg = require(path.join(folder, "package.json")); | ||
pkg.__folder = folder; | ||
for (const key in pkg.dependencies) { | ||
if (webpackShims.indexOf(key) >= 0 || (key !== "@hpcc-js/d3-bullet" && key.indexOf("@hpcc-js") === 0 && key.indexOf("-shim") < 0)) { | ||
const depPkg = walkDependencies(path.join(folder, "node_modules", key), depth + 1); | ||
deps[key] = depPkg; | ||
if (depth === 0) { | ||
console.log("Excluding: " + key); | ||
externals.push(key); | ||
globals[key] = key; | ||
} | ||
} | ||
} | ||
return pkg; | ||
} | ||
const myPackage = walkDependencies(process.cwd()); | ||
const leafID = myPackage.name.split("/")[1]; | ||
for (const key in myPackage.dependencies) { | ||
if (key.indexOf("@hpcc-js") !== 0) { | ||
for (const depKey in deps) { | ||
if (deps[depKey].dependencies[key]) { | ||
const depPckg = deps[depKey]; | ||
console.log(`Optimized: ${key} in ${depPckg.name}`); | ||
aliases[key] = depKey; | ||
const indexSrc = fs.readFileSync(path.join(depPckg.__folder, "src", "index.ts"), "utf8"); | ||
if (indexSrc.indexOf(key) < 0) { | ||
console.log(`Error: ${key} not exported by ${depPckg.name}`); | ||
} | ||
const mySrc = fs.readFileSync(path.join(myPackage.__folder, "src", "index.ts"), "utf8"); | ||
if (mySrc.indexOf(key) >= 0) { | ||
console.log(`Error: ${key} shoud not be exported by ${myPackage.name}`); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
function bundle(min = false) { | ||
const plugins = [ | ||
alias(aliases), | ||
resolve({ | ||
preferBuiltins: true, | ||
jsnext: true, | ||
main: true | ||
}), | ||
commonjs({ | ||
namedExports: {} | ||
}), | ||
postcss({ | ||
extensions: [".css"] | ||
}), | ||
sourcemaps() | ||
]; | ||
if (min) { | ||
plugins.push(uglify({})); | ||
} | ||
return rollup.rollup({ | ||
input: "lib-es6/index.js", | ||
external: externals, | ||
plugins | ||
}).then(function (bundle) { | ||
return bundle.write({ | ||
file: `dist/${leafID}${min ? ".min" : ""}.js`, | ||
format: "umd", | ||
name: myPackage.name, | ||
globals, | ||
sourcemap: true | ||
}); | ||
}); | ||
} | ||
exports.default = bundle; | ||
const bundle_1 = require("./bundle"); | ||
Promise.all([ | ||
bundle(), | ||
bundle(true) | ||
bundle_1.bundle(), | ||
bundle_1.bundle(true) | ||
]).catch(console.log); |
{ | ||
"name": "@hpcc-js/bundle", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "hpcc-js - bundle", | ||
@@ -32,3 +32,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/node": "8.0.10", | ||
"@types/node": "6.0.90", | ||
"rimraf": "2.6.1", | ||
@@ -35,0 +35,0 @@ "typescript": "2.5.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6230
7
141
1