Comparing version 1.0.3 to 1.0.4
// ------------------------------------------------------------------------------------------ | ||
// formats | ||
// ------------------------------------------------------------------------------------------ | ||
// cjs – CommonJS, suitable for Node and Browserify/Webpack | ||
// es – Keep the bundle as an ES module file | ||
// iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this, because it leads to smaller file sizes.) | ||
// umd – Universal Module Definition, works as amd, cjs and iife all in one | ||
// ------------------------------------------------------------------------------------------ | ||
// setup | ||
@@ -7,34 +15,40 @@ // ------------------------------------------------------------------------------------------ | ||
import { uglify } from 'rollup-plugin-uglify' | ||
import { terser } from "rollup-plugin-terser"; | ||
const pkg = require('../package.json') | ||
const name = 'index' | ||
const name = pkg.name | ||
const className = name.replace(/(^\w|-\w)/g, c => c.replace('-', '').toUpperCase()) | ||
const external = Object.keys(pkg.dependencies || []) | ||
function output (ext, format = 'umd') { | ||
function output (ext, format) { | ||
return { | ||
name: className, | ||
file: `dist/${name}.${ext}`, | ||
format: format, | ||
sourcemap: true, | ||
exports: 'named' | ||
exports: 'named', | ||
file: `dist/index.${ext}`, | ||
format | ||
} | ||
} | ||
function buildTemplate (format, minified = false) { | ||
const plugins = (minified) | ||
? [babel(), commonjs(), terser()] | ||
: [babel(), commonjs()] | ||
const ext = (minified) | ||
? `${format}.min.js` | ||
: `${format}.js` | ||
return { | ||
input: `src/index.js`, | ||
output: output(ext, format), | ||
plugins, | ||
external | ||
} | ||
} | ||
// ------------------------------------------------------------------------------------------ | ||
// build | ||
// builds | ||
// ------------------------------------------------------------------------------------------ | ||
const umd = { | ||
input: 'src/index.js', | ||
output: output('js'), | ||
plugins: [ | ||
babel(), | ||
commonjs() | ||
] | ||
} | ||
const formats = ['umd', 'cjs', 'es', 'iife'] | ||
const regBuilds = formats.map(format => buildTemplate(format)) | ||
const minBuilds = formats.map(format => buildTemplate(format, true)) | ||
const result = regBuilds.concat(minBuilds) | ||
const min = Object.assign({}, umd, { | ||
output: output('min.js'), | ||
plugins: [...umd.plugins, uglify()] | ||
}) | ||
export default [umd, min] | ||
export default result |
{ | ||
"name": "is-what", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Very simple & small JS type check function", | ||
"main": "dist/index.min.js", | ||
"main": "dist/index.cjs.min.js", | ||
"module": "dist/index.es.min.js", | ||
"scripts": { | ||
@@ -32,4 +33,5 @@ "test": "echo \"Error: no test specified\" && exit 1", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"rollup-plugin-terser": "^1.0.1", | ||
"rollup-plugin-uglify": "^4.0.0" | ||
} | ||
} |
@@ -33,3 +33,3 @@ | ||
module.exports = { | ||
export { | ||
getType, | ||
@@ -44,3 +44,3 @@ isUndefined, | ||
isRegExp, | ||
isDate, | ||
isDate | ||
} |
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
26390
21
276
8
1