Skip to content

Commit 065629c

Browse files
committed
Refactoring to increase tree-shakeability
1 parent d51c695 commit 065629c

File tree

8 files changed

+1209
-1198
lines changed

8 files changed

+1209
-1198
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "js-spec",
3-
"version": "0.1.73",
3+
"version": "0.1.74",
44
"license": "LGPL-3.0",
55
"homepage": "https://github.com/js-works/js-spec",
66
"main": "index.js",
@@ -14,6 +14,7 @@
1414
},
1515
"files": [
1616
"index.js",
17+
"validators",
1718
"dist"
1819
],
1920
"devDependencies": {

rollup.config.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,41 @@ import gzip from 'rollup-plugin-gzip'
88

99
const configs = []
1010

11-
for (const format of ['umd', 'cjs', 'amd', 'esm']) {
12-
for (const productive of [false, true]) {
13-
configs.push(createConfig(format, productive))
11+
for (const pkg of ['core', 'validators']) {
12+
for (const format of ['umd', 'cjs', 'amd', 'esm']) {
13+
for (const productive of [false, true]) {
14+
configs.push(createConfig(pkg, format, productive))
15+
}
1416
}
1517
}
1618

1719
export default configs
1820

1921
// --- locals -------------------------------------------------------
2022

21-
function createConfig(moduleFormat, productive) {
23+
function createConfig(pkg, moduleFormat, productive) {
24+
let file
25+
26+
if (pkg === 'core') {
27+
file = productive
28+
? `dist/js-spec.${moduleFormat}.production.js`
29+
: `dist/js-spec.${moduleFormat}.development.js`
30+
} else if (pkg === 'validators') {
31+
file = productive
32+
? `dist/js-spec.validators.${moduleFormat}.production.js`
33+
: `dist/js-spec.validators.${moduleFormat}.development.js`
34+
}
35+
2236
return {
23-
input: 'src/main/js-spec.ts',
37+
input:
38+
pkg === 'core'
39+
? 'src/main/js-spec.ts'
40+
: 'src/main/api/validators.ts',
2441

2542
output: {
26-
file: productive
27-
? `dist/js-spec.${moduleFormat}.production.js`
28-
: `dist/js-spec.${moduleFormat}.development.js`,
29-
43+
file,
3044
format: moduleFormat,
31-
name: 'jsSpec',
45+
name: pkg === 'core' ? 'jsSpec' : 'jsSpec.validators',
3246
sourcemap: productive ? false : 'inline',
3347

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

4155
plugins: [
42-
resolve({
43-
jsnext: true,
44-
main: true,
45-
browser: true,
46-
}),
56+
resolve(),
4757
// tslint({
4858
//}),
4959
replace({

0 commit comments

Comments
 (0)