Comparing version 2.0.2 to 2.1.0
/* eslint-disable */ | ||
/* Required packages: */ | ||
// npm i -D \ | ||
// @babel/core \ | ||
// @babel/plugin-proposal-object-rest-spread \ | ||
// @babel/preset-env \ | ||
// rollup \ | ||
// rollup-plugin-babel@latest \ | ||
// rollup-plugin-commonjs \ | ||
// rollup-plugin-node-resolve \ | ||
// rollup-plugin-terser \ | ||
// is-what | ||
/* Required .babelrc setup: */ | ||
// { | ||
// "presets": [ | ||
// ["@babel/preset-env", { | ||
// "modules": false | ||
// }] | ||
// ], | ||
// "plugins": [ | ||
// "@babel/plugin-proposal-object-rest-spread" | ||
// ] | ||
// } | ||
import babel from 'rollup-plugin-babel' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import { terser } from 'rollup-plugin-terser' | ||
import { isArray } from 'is-what' | ||
// npm install rollup-plugin-typescript2 typescript --save-dev | ||
import typescript from 'rollup-plugin-typescript2' | ||
// import { terser } from 'rollup-plugin-terser' | ||
// import resolve from 'rollup-plugin-node-resolve' | ||
@@ -36,6 +11,8 @@ | ||
// ------------------------------------------------------------------------------------------ | ||
// amd – Asynchronous Module Definition, used with module loaders like RequireJS | ||
// cjs – CommonJS, suitable for Node and Browserify/Webpack | ||
// es – Keep the bundle as an ES module file | ||
// esm – 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 | ||
// system – Native format of the SystemJS loader | ||
@@ -45,14 +22,2 @@ // ------------------------------------------------------------------------------------------ | ||
// ------------------------------------------------------------------------------------------ | ||
const files = [ | ||
{in: 'src/index.js', out: 'dist', formats: ['cjs', 'es', 'iife', 'umd']}, | ||
] | ||
const minify = true | ||
const sourcemap = true | ||
const plugins = [ | ||
babel({ | ||
exclude: 'node_modules/**' // only transpile our source code | ||
}), | ||
commonjs() | ||
] | ||
// ------------------------------------------------------------------------------------------ | ||
const pkg = require('../package.json') | ||
@@ -62,2 +27,5 @@ const name = pkg.name | ||
const external = Object.keys(pkg.dependencies || []) | ||
const plugins = [ | ||
typescript({useTsconfigDeclarationDir: true}), | ||
] | ||
@@ -67,56 +35,27 @@ // ------------------------------------------------------------------------------------------ | ||
// ------------------------------------------------------------------------------------------ | ||
const nsNameExt = new RegExp('(.+)\/([^\/]+)\.([^\.]+$)', 'g') | ||
function getNS (name) { | ||
if (!name.includes('/')) return '' | ||
return name.replace(nsNameExt, '$1') | ||
} | ||
function getName (name) { | ||
if (!name.includes('/')) name = 'a/' + name | ||
name = name.replace(nsNameExt, '$2') | ||
if (name.endsWith('.')) name = name.slice(0, -1) | ||
return name | ||
} | ||
function getExt (name) { | ||
return name.split('.').pop() | ||
} | ||
function getFileInfo (file) { | ||
return { | ||
ns: getNS(file.in), | ||
name: getName(file.in), | ||
ext: getExt(file.in), | ||
out: file.out, | ||
formats: !isArray(file.formats) ? [file.formats] : file.formats, | ||
plugins: (file.plugins === undefined) ? plugins : file.plugins, | ||
min: (file.minify === undefined) ? minify : file.minify, | ||
map: (file.sourcemap === undefined) ? sourcemap : file.sourcemap, | ||
external: external, | ||
function defaults (config) { | ||
// defaults | ||
const defaults = { | ||
plugins, | ||
external | ||
} | ||
} | ||
function getRollupObject (info, format) { | ||
return { | ||
input: `${info.ns}/${info.name}.${info.ext}`, | ||
output: { | ||
// defaults.output | ||
config.output = config.output.map(output => { | ||
return Object.assign({ | ||
sourcemap: false, | ||
name: className, | ||
sourcemap: info.map, | ||
exports: 'named', | ||
file: (!info.min) | ||
? `${info.out}/${info.name}.${format}.${info.ext}` | ||
: `${info.out}/${info.name}.${format}.min.${info.ext}`, | ||
format | ||
}, | ||
plugins: (!info.min) ? plugins : plugins.concat(terser()), | ||
external: info.external | ||
} | ||
}, output) | ||
}) | ||
return Object.assign(defaults, config) | ||
} | ||
const builds = files.reduce((carry, file) => { | ||
const info = getFileInfo(file) | ||
const _builds = info.formats | ||
.reduce((carry, format) => { | ||
return carry | ||
.concat(getRollupObject(info, format)) | ||
}, []) | ||
return carry.concat(_builds) | ||
}, []) | ||
export default builds | ||
export default [ | ||
defaults({ | ||
input: 'src/index.ts', | ||
output: [ | ||
{file: 'dist/index.cjs.js', format: 'cjs'}, | ||
{file: 'dist/index.esm.js', format: 'esm'}, | ||
], | ||
}), | ||
] |
{ | ||
"name": "is-what", | ||
"version": "2.0.2", | ||
"description": "Very simple & small JS type check function", | ||
"main": "dist/index.cjs.min.js", | ||
"module": "dist/index.es.min.js", | ||
"version": "2.1.0", | ||
"description": "JS type check functions like `isObject() isArray()` etc. A simple & small integration.", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"typings": "types/index.d.ts", | ||
"scripts": { | ||
@@ -16,5 +17,5 @@ "test": "ava", | ||
"keywords": [ | ||
"JavaScript", | ||
"check", | ||
"type" | ||
"javascript", | ||
"typechecker", | ||
"check-type" | ||
], | ||
@@ -28,12 +29,8 @@ "author": "Luca Ban - Mesqueeb", | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"ava": "1.0.0-beta.8", | ||
"rollup": "^0.65.2", | ||
"rollup-plugin-babel": "^4.0.3", | ||
"rollup-plugin-commonjs": "^9.1.6", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-terser": "^2.0.2" | ||
"rollup-plugin-typescript2": "^0.17.0", | ||
"typescript": "^3.0.3" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -13,3 +13,3 @@ import test from 'ava' | ||
isDate | ||
} from '../dist/index.cjs.min' | ||
} from '../dist/index.cjs' | ||
@@ -16,0 +16,0 @@ test('true', t => { |
Sorry, the diff of this file is not supported yet
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
4
242
10623
10
1