Skip to content

Commit

Permalink
Refactoring to increase tree-shakeability
Browse files Browse the repository at this point in the history
  • Loading branch information
mcjazzyfunky committed Dec 5, 2019
1 parent d51c695 commit 065629c
Show file tree
Hide file tree
Showing 8 changed files with 1,209 additions and 1,198 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-spec",
"version": "0.1.73",
"version": "0.1.74",
"license": "LGPL-3.0",
"homepage": "https://github.com/js-works/js-spec",
"main": "index.js",
Expand All @@ -14,6 +14,7 @@
},
"files": [
"index.js",
"validators",
"dist"
],
"devDependencies": {
Expand Down
40 changes: 25 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,41 @@ import gzip from 'rollup-plugin-gzip'

const configs = []

for (const format of ['umd', 'cjs', 'amd', 'esm']) {
for (const productive of [false, true]) {
configs.push(createConfig(format, productive))
for (const pkg of ['core', 'validators']) {
for (const format of ['umd', 'cjs', 'amd', 'esm']) {
for (const productive of [false, true]) {
configs.push(createConfig(pkg, format, productive))
}
}
}

export default configs

// --- locals -------------------------------------------------------

function createConfig(moduleFormat, productive) {
function createConfig(pkg, moduleFormat, productive) {
let file

if (pkg === 'core') {
file = productive
? `dist/js-spec.${moduleFormat}.production.js`
: `dist/js-spec.${moduleFormat}.development.js`
} else if (pkg === 'validators') {
file = productive
? `dist/js-spec.validators.${moduleFormat}.production.js`
: `dist/js-spec.validators.${moduleFormat}.development.js`
}

return {
input: 'src/main/js-spec.ts',
input:
pkg === 'core'
? 'src/main/js-spec.ts'
: 'src/main/api/validators.ts',

output: {
file: productive
? `dist/js-spec.${moduleFormat}.production.js`
: `dist/js-spec.${moduleFormat}.development.js`,

file,
format: moduleFormat,
name: 'jsSpec',
name: pkg === 'core' ? 'jsSpec' : 'jsSpec.validators',
sourcemap: productive ? false : 'inline',

globals: {
Expand All @@ -39,11 +53,7 @@ function createConfig(moduleFormat, productive) {
external: [],

plugins: [
resolve({
jsnext: true,
main: true,
browser: true,
}),
resolve(),
// tslint({
//}),
replace({
Expand Down
Loading

0 comments on commit 065629c

Please sign in to comment.