mazey 3.11.6 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +994 -991
- package/lib/index.cjs.js +1 -1
- package/lib/index.d.ts +9 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/mazey.min.js +1 -1
- package/lib/typing.d.ts +74 -74
- package/package.json +122 -119
- package/scripts/README.md +38 -38
- package/scripts/build-helper.js +76 -76
- package/scripts/dev.js +23 -23
- package/scripts/git-helper.js +155 -155
- package/scripts/release.js +9 -9
- package/scripts/rollup.config.mjs +152 -0
package/scripts/dev.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
-
// const execa = require('execa');
|
|
4
|
-
const { generateToc } = require('./build-helper');
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
// const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
|
|
8
|
-
// .catch(error => {
|
|
9
|
-
// console.log('error:', error.message);
|
|
10
|
-
// });
|
|
11
|
-
// try {
|
|
12
|
-
// await execa('git', ['push'], { stdio: 'pipe' });
|
|
13
|
-
// } catch (error) {
|
|
14
|
-
// console.log('error:', error.message);
|
|
15
|
-
// const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
|
|
16
|
-
// console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
|
|
17
|
-
// await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
|
|
18
|
-
// }
|
|
19
|
-
// console.log('pushMsg:', pushMsg);
|
|
20
|
-
// const cb = await getGitCurrentBranch('fix returns value');
|
|
21
|
-
// console.log('bbb', cb);
|
|
22
|
-
generateToc();
|
|
23
|
-
})();
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
// const execa = require('execa');
|
|
4
|
+
const { generateToc } = require('./build-helper');
|
|
5
|
+
|
|
6
|
+
(async () => {
|
|
7
|
+
// const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
|
|
8
|
+
// .catch(error => {
|
|
9
|
+
// console.log('error:', error.message);
|
|
10
|
+
// });
|
|
11
|
+
// try {
|
|
12
|
+
// await execa('git', ['push'], { stdio: 'pipe' });
|
|
13
|
+
// } catch (error) {
|
|
14
|
+
// console.log('error:', error.message);
|
|
15
|
+
// const { stdout: currentBranch } = await execa('git', ['branch', '--show-current'], { stdio: 'pipe' });
|
|
16
|
+
// console.log('currentBranch:', currentBranch); // currentBranch: fix/rollup_dependences_mon_oct_31st_2022
|
|
17
|
+
// await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
|
|
18
|
+
// }
|
|
19
|
+
// console.log('pushMsg:', pushMsg);
|
|
20
|
+
// const cb = await getGitCurrentBranch('fix returns value');
|
|
21
|
+
// console.log('bbb', cb);
|
|
22
|
+
generateToc();
|
|
23
|
+
})();
|
package/scripts/git-helper.js
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
// Git Helper
|
|
4
|
-
const execa = require('execa');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Release this project with version by `process.env.VERSION` or `package.json`.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
*
|
|
11
|
-
* ```javascript
|
|
12
|
-
* const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
13
|
-
* release(pkgVersion);
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* It will be more straightforward if you use the development dependence CrossEnv.
|
|
17
|
-
*
|
|
18
|
-
* ```shell
|
|
19
|
-
* # Install
|
|
20
|
-
* npm i cross-env -D
|
|
21
|
-
*
|
|
22
|
-
* # scripts
|
|
23
|
-
* cross-env SCRIPTS_NPM_PACKAGE_VERSION=$npm_package_version node ./scripts/release.js
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ```javascript
|
|
27
|
-
* // release.js
|
|
28
|
-
* release();
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* @param {string} ver Version
|
|
32
|
-
* @returns {void}
|
|
33
|
-
*/
|
|
34
|
-
async function release (ver, { canGenerateToc = false, defaultBranch = 'main' } = {}) {
|
|
35
|
-
if (!ver) {
|
|
36
|
-
ver = process.env.SCRIPTS_NPM_PACKAGE_VERSION;
|
|
37
|
-
}
|
|
38
|
-
if (!ver) {
|
|
39
|
-
console.error('Fail to get the current version.');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const { generateToc } = require('./build-helper');
|
|
43
|
-
const releaseVersion = `v${ver}`;
|
|
44
|
-
const { stdout: releaseStdout } = await execa('echo', [ `Start release ${releaseVersion}...` ]);
|
|
45
|
-
console.log(releaseStdout);
|
|
46
|
-
// Generating Table of Contents
|
|
47
|
-
if (canGenerateToc) {
|
|
48
|
-
generateToc();
|
|
49
|
-
}
|
|
50
|
-
// Commit
|
|
51
|
-
await gitCommit(`${releaseVersion} stage`);
|
|
52
|
-
// Marge
|
|
53
|
-
await gitMergeMaster2Release(defaultBranch);
|
|
54
|
-
// Build
|
|
55
|
-
await execa('npm', [ 'run', 'preview' ]);
|
|
56
|
-
await execa('npm', [ 'publish' ]);
|
|
57
|
-
// Commit Again
|
|
58
|
-
await gitCommit(releaseVersion);
|
|
59
|
-
// Push
|
|
60
|
-
console.log('Pushing to the remote Git...');
|
|
61
|
-
// await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
62
|
-
// await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
63
|
-
await gitTagPush(releaseVersion);
|
|
64
|
-
await gitPush();
|
|
65
|
-
console.log('All done.');
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Push git tag.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```
|
|
73
|
-
* await gitTagPush('v1.0.0');
|
|
74
|
-
* ```
|
|
75
|
-
*
|
|
76
|
-
* @param {string} ver Release version
|
|
77
|
-
* @returns {boolean} Is success
|
|
78
|
-
*/
|
|
79
|
-
async function gitTagPush (ver = '') {
|
|
80
|
-
if (!ver) {
|
|
81
|
-
console.error('Fail to get the current version.');
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
if (!ver.startsWith('v')) {
|
|
85
|
-
ver = `v${ver}`;
|
|
86
|
-
}
|
|
87
|
-
await execa('git', [ 'tag', '-a', `${ver}`, '-m', `Release ${ver}` ]);
|
|
88
|
-
await execa('git', [ 'push', 'origin', `refs/tags/${ver}` ]);
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Push code.
|
|
94
|
-
*/
|
|
95
|
-
async function gitPush () {
|
|
96
|
-
try {
|
|
97
|
-
await execa('git', [ 'push' ], { stdio: 'pipe' });
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.log('Error:', error.message);
|
|
100
|
-
const { stdout: currentBranch } = await execa('git', [ 'branch', '--show-current' ], { stdio: 'pipe' });
|
|
101
|
-
console.log(`Current Branch: ${currentBranch}`);
|
|
102
|
-
await execa('git', [ 'push', '--set-upstream', 'origin', currentBranch ]);
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Merge master to current branch.
|
|
109
|
-
*/
|
|
110
|
-
async function gitMergeMaster2Release (defaultBranch = 'main') {
|
|
111
|
-
const currentBranch = await getGitCurrentBranch();
|
|
112
|
-
await execa('git', [ 'checkout', defaultBranch ]);
|
|
113
|
-
await execa('git', [ 'pull' ]);
|
|
114
|
-
await execa('git', [ 'checkout', currentBranch ]);
|
|
115
|
-
await execa('git', [ 'merge', defaultBranch ]);
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get git current branch.
|
|
121
|
-
*/
|
|
122
|
-
async function getGitCurrentBranch () {
|
|
123
|
-
let currentBranch = '';
|
|
124
|
-
try {
|
|
125
|
-
({ stdout: currentBranch } = await execa('git', [ 'branch', '--show-current' ], { stdio: 'pipe' }));
|
|
126
|
-
} catch (error) {
|
|
127
|
-
({ stdout: currentBranch } = await execa('git', [ 'rev-parse', '--abbrev-ref', 'HEAD' ], { stdio: 'pipe' }));
|
|
128
|
-
}
|
|
129
|
-
console.log(`Current Branch: ${currentBranch}`);
|
|
130
|
-
return currentBranch;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Commit current code.
|
|
135
|
-
*/
|
|
136
|
-
async function gitCommit (releaseVersion = 0) {
|
|
137
|
-
const { stdout: diffStdout } = await execa('git', [ 'diff' ], { stdio: 'pipe' });
|
|
138
|
-
if (diffStdout) {
|
|
139
|
-
console.log('Committing changes...');
|
|
140
|
-
await execa('git', [ 'add', '-A' ]);
|
|
141
|
-
await execa('git', [ 'commit', '-m', `release: ${releaseVersion}` ]);
|
|
142
|
-
} else {
|
|
143
|
-
console.log('No changes to commit.');
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
module.exports = {
|
|
149
|
-
release,
|
|
150
|
-
gitPush,
|
|
151
|
-
gitMergeMaster2Release,
|
|
152
|
-
getGitCurrentBranch,
|
|
153
|
-
gitCommit,
|
|
154
|
-
gitTagPush,
|
|
155
|
-
};
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// Git Helper
|
|
4
|
+
const execa = require('execa');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Release this project with version by `process.env.VERSION` or `package.json`.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
*
|
|
11
|
+
* ```javascript
|
|
12
|
+
* const pkgVersion = process.env.VERSION || require('../package.json').version;
|
|
13
|
+
* release(pkgVersion);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* It will be more straightforward if you use the development dependence CrossEnv.
|
|
17
|
+
*
|
|
18
|
+
* ```shell
|
|
19
|
+
* # Install
|
|
20
|
+
* npm i cross-env -D
|
|
21
|
+
*
|
|
22
|
+
* # scripts
|
|
23
|
+
* cross-env SCRIPTS_NPM_PACKAGE_VERSION=$npm_package_version node ./scripts/release.js
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* ```javascript
|
|
27
|
+
* // release.js
|
|
28
|
+
* release();
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {string} ver Version
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
34
|
+
async function release (ver, { canGenerateToc = false, defaultBranch = 'main' } = {}) {
|
|
35
|
+
if (!ver) {
|
|
36
|
+
ver = process.env.SCRIPTS_NPM_PACKAGE_VERSION;
|
|
37
|
+
}
|
|
38
|
+
if (!ver) {
|
|
39
|
+
console.error('Fail to get the current version.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const { generateToc } = require('./build-helper');
|
|
43
|
+
const releaseVersion = `v${ver}`;
|
|
44
|
+
const { stdout: releaseStdout } = await execa('echo', [ `Start release ${releaseVersion}...` ]);
|
|
45
|
+
console.log(releaseStdout);
|
|
46
|
+
// Generating Table of Contents
|
|
47
|
+
if (canGenerateToc) {
|
|
48
|
+
generateToc();
|
|
49
|
+
}
|
|
50
|
+
// Commit
|
|
51
|
+
await gitCommit(`${releaseVersion} stage`);
|
|
52
|
+
// Marge
|
|
53
|
+
await gitMergeMaster2Release(defaultBranch);
|
|
54
|
+
// Build
|
|
55
|
+
await execa('npm', [ 'run', 'preview' ]);
|
|
56
|
+
await execa('npm', [ 'publish' ]);
|
|
57
|
+
// Commit Again
|
|
58
|
+
await gitCommit(releaseVersion);
|
|
59
|
+
// Push
|
|
60
|
+
console.log('Pushing to the remote Git...');
|
|
61
|
+
// await execa('git', ['tag', '-a', `${releaseVersion}`, '-m', `Release ${releaseVersion}`]);
|
|
62
|
+
// await execa('git', ['push', 'origin', `refs/tags/${releaseVersion}`]);
|
|
63
|
+
await gitTagPush(releaseVersion);
|
|
64
|
+
await gitPush();
|
|
65
|
+
console.log('All done.');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Push git tag.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```
|
|
73
|
+
* await gitTagPush('v1.0.0');
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @param {string} ver Release version
|
|
77
|
+
* @returns {boolean} Is success
|
|
78
|
+
*/
|
|
79
|
+
async function gitTagPush (ver = '') {
|
|
80
|
+
if (!ver) {
|
|
81
|
+
console.error('Fail to get the current version.');
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (!ver.startsWith('v')) {
|
|
85
|
+
ver = `v${ver}`;
|
|
86
|
+
}
|
|
87
|
+
await execa('git', [ 'tag', '-a', `${ver}`, '-m', `Release ${ver}` ]);
|
|
88
|
+
await execa('git', [ 'push', 'origin', `refs/tags/${ver}` ]);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Push code.
|
|
94
|
+
*/
|
|
95
|
+
async function gitPush () {
|
|
96
|
+
try {
|
|
97
|
+
await execa('git', [ 'push' ], { stdio: 'pipe' });
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.log('Error:', error.message);
|
|
100
|
+
const { stdout: currentBranch } = await execa('git', [ 'branch', '--show-current' ], { stdio: 'pipe' });
|
|
101
|
+
console.log(`Current Branch: ${currentBranch}`);
|
|
102
|
+
await execa('git', [ 'push', '--set-upstream', 'origin', currentBranch ]);
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Merge master to current branch.
|
|
109
|
+
*/
|
|
110
|
+
async function gitMergeMaster2Release (defaultBranch = 'main') {
|
|
111
|
+
const currentBranch = await getGitCurrentBranch();
|
|
112
|
+
await execa('git', [ 'checkout', defaultBranch ]);
|
|
113
|
+
await execa('git', [ 'pull' ]);
|
|
114
|
+
await execa('git', [ 'checkout', currentBranch ]);
|
|
115
|
+
await execa('git', [ 'merge', defaultBranch ]);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get git current branch.
|
|
121
|
+
*/
|
|
122
|
+
async function getGitCurrentBranch () {
|
|
123
|
+
let currentBranch = '';
|
|
124
|
+
try {
|
|
125
|
+
({ stdout: currentBranch } = await execa('git', [ 'branch', '--show-current' ], { stdio: 'pipe' }));
|
|
126
|
+
} catch (error) {
|
|
127
|
+
({ stdout: currentBranch } = await execa('git', [ 'rev-parse', '--abbrev-ref', 'HEAD' ], { stdio: 'pipe' }));
|
|
128
|
+
}
|
|
129
|
+
console.log(`Current Branch: ${currentBranch}`);
|
|
130
|
+
return currentBranch;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Commit current code.
|
|
135
|
+
*/
|
|
136
|
+
async function gitCommit (releaseVersion = 0) {
|
|
137
|
+
const { stdout: diffStdout } = await execa('git', [ 'diff' ], { stdio: 'pipe' });
|
|
138
|
+
if (diffStdout) {
|
|
139
|
+
console.log('Committing changes...');
|
|
140
|
+
await execa('git', [ 'add', '-A' ]);
|
|
141
|
+
await execa('git', [ 'commit', '-m', `release: ${releaseVersion}` ]);
|
|
142
|
+
} else {
|
|
143
|
+
console.log('No changes to commit.');
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
module.exports = {
|
|
149
|
+
release,
|
|
150
|
+
gitPush,
|
|
151
|
+
gitMergeMaster2Release,
|
|
152
|
+
getGitCurrentBranch,
|
|
153
|
+
gitCommit,
|
|
154
|
+
gitTagPush,
|
|
155
|
+
};
|
package/scripts/release.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
// release
|
|
4
|
-
const { release } = require('./git-helper');
|
|
5
|
-
const pkgVersion = process.env.SCRIPTS_NPM_PACKAGE_VERSION || process.env.VERSION || require('../package.json').version;
|
|
6
|
-
|
|
7
|
-
console.log('release: SCRIPTS_NPM_PACKAGE_VERSION', process.env.SCRIPTS_NPM_PACKAGE_VERSION);
|
|
8
|
-
|
|
9
|
-
release(pkgVersion, { canGenerateToc: true });
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// release
|
|
4
|
+
const { release } = require('./git-helper');
|
|
5
|
+
const pkgVersion = process.env.SCRIPTS_NPM_PACKAGE_VERSION || process.env.VERSION || require('../package.json').version;
|
|
6
|
+
|
|
7
|
+
console.log('release: SCRIPTS_NPM_PACKAGE_VERSION', process.env.SCRIPTS_NPM_PACKAGE_VERSION);
|
|
8
|
+
|
|
9
|
+
release(pkgVersion, { canGenerateToc: true });
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// import json from '@rollup/plugin-json'
|
|
4
|
+
import { babel } from '@rollup/plugin-babel';
|
|
5
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
6
|
+
import rollupTypescript from 'rollup-plugin-typescript2';
|
|
7
|
+
import { DEFAULT_EXTENSIONS } from '@babel/core';
|
|
8
|
+
import cleaner from 'rollup-plugin-cleaner';
|
|
9
|
+
import terser from '@rollup/plugin-terser';
|
|
10
|
+
import { dts } from 'rollup-plugin-dts';
|
|
11
|
+
// import { version as pkgJSONVersion } from '../package.json';
|
|
12
|
+
// import replace from '@rollup/plugin-replace';
|
|
13
|
+
// import copy from 'rollup-plugin-copy';
|
|
14
|
+
|
|
15
|
+
// const path = require('path');
|
|
16
|
+
// const _resolve = (_path) => path.resolve(__dirname, _path);
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { fileURLToPath } from 'url';
|
|
20
|
+
import { dirname } from 'path';
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
|
+
|
|
25
|
+
const _resolve = (_path) => path.resolve(__dirname, _path);
|
|
26
|
+
|
|
27
|
+
// const { _resolve } = require('./build-helper');
|
|
28
|
+
const pkgVersion = process.env.SCRIPTS_NPM_PACKAGE_VERSION || process.env.VERSION || 'unknown'; // || require('../package.json').version;
|
|
29
|
+
const debugMode = process.env.SCRIPTS_NPM_PACKAGE_DEBUG;
|
|
30
|
+
const banner =
|
|
31
|
+
'/*!\n' +
|
|
32
|
+
` * Mazey v${pkgVersion} https://github.com/mazeyqian/mazey\n` +
|
|
33
|
+
` * (c) 2018-${new Date().getFullYear()} Cheng\n` +
|
|
34
|
+
' * Released under the MIT License.\n' +
|
|
35
|
+
' */';
|
|
36
|
+
|
|
37
|
+
const plugins = [
|
|
38
|
+
// replace({
|
|
39
|
+
// __MAZEY_NPM_PACKAGE_VERSION__: pkgVersion,
|
|
40
|
+
// }),
|
|
41
|
+
// Remove the `lib` directory before rebuilding.
|
|
42
|
+
// https://github.com/aMarCruz/rollup-plugin-cleanup
|
|
43
|
+
// cleaner({
|
|
44
|
+
// targets: [
|
|
45
|
+
// _resolve('../lib/'),
|
|
46
|
+
// ],
|
|
47
|
+
// }),
|
|
48
|
+
rollupTypescript(),
|
|
49
|
+
commonjs({
|
|
50
|
+
include: /node_modules/,
|
|
51
|
+
}),
|
|
52
|
+
babel({
|
|
53
|
+
babelHelpers: 'runtime',
|
|
54
|
+
// 只转换源代码,不运行外部依赖
|
|
55
|
+
exclude: '**/node_modules/**',
|
|
56
|
+
// babel 默认不支持 ts 需要手动添加
|
|
57
|
+
extensions: [
|
|
58
|
+
...DEFAULT_EXTENSIONS,
|
|
59
|
+
'.ts',
|
|
60
|
+
],
|
|
61
|
+
// skipPreflightCheck: true,
|
|
62
|
+
}),
|
|
63
|
+
// dts(),
|
|
64
|
+
// uglify(),
|
|
65
|
+
// https://www.npmjs.com/package/rollup-plugin-copy
|
|
66
|
+
// copy({
|
|
67
|
+
// targets: [
|
|
68
|
+
// {
|
|
69
|
+
// src: _resolve('../src/t.html'),
|
|
70
|
+
// dest: _resolve('../docs'),
|
|
71
|
+
// },
|
|
72
|
+
// ],
|
|
73
|
+
// }),
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
const iifePlugins = [];
|
|
77
|
+
|
|
78
|
+
// console.log('debugMode:', debugMode);
|
|
79
|
+
if (debugMode !== 'open') {
|
|
80
|
+
iifePlugins.push(
|
|
81
|
+
// Add minification.
|
|
82
|
+
// https://github.com/TrySound/rollup-plugin-terser
|
|
83
|
+
terser({ // https://github.com/terser/terser
|
|
84
|
+
format: {
|
|
85
|
+
// https://github.com/terser/terser#format-options
|
|
86
|
+
comments: /^!\n\s\*\smazey/, // 'some', // `false` to omit comments in the output
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const dTsConf = {
|
|
93
|
+
input: _resolve('../src/typing.d.ts'),
|
|
94
|
+
// https://rollupjs.org/guide/en/#outputformat
|
|
95
|
+
output: [
|
|
96
|
+
{
|
|
97
|
+
file: _resolve('../lib/typing.d.ts'),
|
|
98
|
+
format: 'es',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
plugins: [
|
|
102
|
+
// ...plugins,
|
|
103
|
+
// cleaner({
|
|
104
|
+
// targets: [
|
|
105
|
+
// _resolve('../lib/index.d.ts'),
|
|
106
|
+
// ],
|
|
107
|
+
// }),
|
|
108
|
+
dts(),
|
|
109
|
+
],
|
|
110
|
+
external: [],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// console.log('dTsConf:', dTsConf);
|
|
114
|
+
|
|
115
|
+
// https://rollupjs.org/guide/en/
|
|
116
|
+
export default [
|
|
117
|
+
{
|
|
118
|
+
input: _resolve('../src/index.ts'),
|
|
119
|
+
// https://rollupjs.org/guide/en/#outputformat
|
|
120
|
+
output: [
|
|
121
|
+
{
|
|
122
|
+
file: _resolve('../lib/index.cjs.js'),
|
|
123
|
+
format: 'cjs',
|
|
124
|
+
banner,
|
|
125
|
+
plugins: iifePlugins,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
file: _resolve('../lib/index.esm.js'),
|
|
129
|
+
format: 'esm',
|
|
130
|
+
banner,
|
|
131
|
+
plugins: iifePlugins,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
file: _resolve('../lib/mazey.min.js'),
|
|
135
|
+
format: 'iife',
|
|
136
|
+
name: 'mazey',
|
|
137
|
+
banner,
|
|
138
|
+
plugins: iifePlugins,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
plugins: [
|
|
142
|
+
...plugins,
|
|
143
|
+
cleaner({
|
|
144
|
+
targets: [
|
|
145
|
+
_resolve('../lib/'),
|
|
146
|
+
],
|
|
147
|
+
}),
|
|
148
|
+
],
|
|
149
|
+
external: [],
|
|
150
|
+
},
|
|
151
|
+
dTsConf,
|
|
152
|
+
];
|