@cmmn/tools 1.4.13 → 1.4.16
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/bundle/bundle.js +8 -2
- package/bundle/rollup.config.js +44 -8
- package/package.json +6 -2
package/bundle/bundle.js
CHANGED
|
@@ -14,8 +14,11 @@ function getProjectConfig(rootDir, cmmn, options) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function getPackageConfigs(rootDir, options, name = null) {
|
|
17
|
+
const pckPath = path.join(rootDir, 'package.json');
|
|
18
|
+
if (!fs.existsSync(pckPath))
|
|
19
|
+
return [];
|
|
17
20
|
const results = [];
|
|
18
|
-
const pkg = JSON.parse(fs.readFileSync(
|
|
21
|
+
const pkg = JSON.parse(fs.readFileSync(pckPath));
|
|
19
22
|
if (name) {
|
|
20
23
|
results.push(...getProjectConfig(rootDir, pkg.cmmn[name], {
|
|
21
24
|
...options,
|
|
@@ -111,7 +114,10 @@ export async function bundle(...options) {
|
|
|
111
114
|
console.log(`\tline: ${event.error.frame}`);
|
|
112
115
|
break;
|
|
113
116
|
case 'UNRESOLVED_IMPORT':
|
|
114
|
-
console.
|
|
117
|
+
console.warn('UNRESOLVED_IMPORT:\t',event.error.message);
|
|
118
|
+
break;
|
|
119
|
+
case 'MISSING_EXPORT':
|
|
120
|
+
console.warn('MISSING_EXPORT: \t', event.error.message);
|
|
115
121
|
break;
|
|
116
122
|
default:
|
|
117
123
|
console.warn('Unknown error:', event.error.code);
|
package/bundle/rollup.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import commonjs from '@rollup/plugin-commonjs';
|
|
2
2
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import image from "rollup-plugin-img";
|
|
3
4
|
import {terser} from "rollup-plugin-terser"
|
|
4
5
|
import {visualizer} from 'rollup-plugin-visualizer';
|
|
5
6
|
import styles from "rollup-plugin-styles";
|
|
@@ -12,6 +13,7 @@ import path from "path";
|
|
|
12
13
|
import html from '@open-wc/rollup-plugin-html';
|
|
13
14
|
import json from '@rollup/plugin-json';
|
|
14
15
|
import alias from '@rollup/plugin-alias';
|
|
16
|
+
import replace from '@rollup/plugin-replace';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @typedef {import(rollup).RollupOptions} RollupOptions
|
|
@@ -29,6 +31,7 @@ export class ConfigCreator {
|
|
|
29
31
|
* external: string[],
|
|
30
32
|
* stats: boolean,
|
|
31
33
|
* name: string,
|
|
34
|
+
* styles: 'modules' | null,
|
|
32
35
|
* outDir: string,
|
|
33
36
|
* html: string,
|
|
34
37
|
* browser: boolean,
|
|
@@ -80,7 +83,7 @@ export class ConfigCreator {
|
|
|
80
83
|
dir: this.outDir,
|
|
81
84
|
sourcemap: true,
|
|
82
85
|
format: module,
|
|
83
|
-
globals: Object.fromEntries(this.options.external.map(x => [x,x])),
|
|
86
|
+
globals: Array.isArray(this.options.external) ? Object.fromEntries(this.options.external.map(x => [x, x])) : this.options.external,
|
|
84
87
|
name: this.options.global ?? 'global',
|
|
85
88
|
}));
|
|
86
89
|
}
|
|
@@ -125,6 +128,10 @@ export class ConfigCreator {
|
|
|
125
128
|
|
|
126
129
|
get plugins() {
|
|
127
130
|
const result = [
|
|
131
|
+
replace({
|
|
132
|
+
'process.env.NODE_ENV': JSON.stringify('development'),
|
|
133
|
+
preventAssignment: true
|
|
134
|
+
}),
|
|
128
135
|
nodeResolve({
|
|
129
136
|
browser: this.options.browser,
|
|
130
137
|
dedupe: this.options.dedupe || []
|
|
@@ -136,11 +143,28 @@ export class ConfigCreator {
|
|
|
136
143
|
]
|
|
137
144
|
}),
|
|
138
145
|
builtins(),
|
|
139
|
-
styles({
|
|
140
|
-
mode:
|
|
146
|
+
styles(this.options.styles === 'modules' ? {
|
|
147
|
+
mode: [
|
|
148
|
+
"inject",
|
|
149
|
+
{container: "head", prepend: true, attributes: {id: "global"}},
|
|
150
|
+
],
|
|
151
|
+
modules: {
|
|
152
|
+
failOnWrongOrder: true
|
|
153
|
+
},
|
|
154
|
+
namedExports: false,
|
|
155
|
+
autoModules: true,
|
|
156
|
+
}: {
|
|
157
|
+
mode: "emit"
|
|
158
|
+
}),
|
|
159
|
+
image({
|
|
160
|
+
output: `/assets`, // default the root
|
|
161
|
+
extensions: /\.(png|jpg|jpeg|gif)$/, // support png|jpg|jpeg|gif|svg, and it's alse the default value
|
|
162
|
+
limit: 8192, // default 8192(8k)
|
|
163
|
+
exclude: 'node_modules/**'
|
|
141
164
|
}),
|
|
142
165
|
string({
|
|
143
|
-
include: /\.(html|svg|less
|
|
166
|
+
include: /\.(html|svg|less)$/,
|
|
167
|
+
exclude: /\.module\.css/
|
|
144
168
|
}),
|
|
145
169
|
json(),
|
|
146
170
|
|
|
@@ -176,6 +200,14 @@ export class ConfigCreator {
|
|
|
176
200
|
return result;
|
|
177
201
|
}
|
|
178
202
|
|
|
203
|
+
getExternals() {
|
|
204
|
+
if (!this.options.external)
|
|
205
|
+
return [];
|
|
206
|
+
if (Array.isArray(this.options.external))
|
|
207
|
+
return this.options.external.map(s => new RegExp(s));
|
|
208
|
+
return Object.keys(this.options.external).map(s => new RegExp(s));
|
|
209
|
+
}
|
|
210
|
+
|
|
179
211
|
/**
|
|
180
212
|
* @returns {RollupOptions[]}
|
|
181
213
|
*/
|
|
@@ -188,23 +220,27 @@ export class ConfigCreator {
|
|
|
188
220
|
});
|
|
189
221
|
if (this.options.external && typeof this.options.external === "string")
|
|
190
222
|
this.options.external = [this.options.external]
|
|
191
|
-
console.log(this.options);
|
|
223
|
+
console.log(this.options.name, this.options);
|
|
192
224
|
return [{
|
|
193
225
|
input: {
|
|
194
226
|
[this.options.name]: path.join(this.root, this.options.input)
|
|
195
227
|
},
|
|
196
228
|
output: this.output,
|
|
197
|
-
external:
|
|
229
|
+
external: this.getExternals(),
|
|
198
230
|
onwarn(warning) {
|
|
199
|
-
switch (warning.code){
|
|
231
|
+
switch (warning.code) {
|
|
200
232
|
case 'CIRCULAR_DEPENDENCY':
|
|
201
233
|
return;
|
|
202
234
|
case 'THIS_IS_UNDEFINED':
|
|
203
235
|
console.log(`${warning.message} at`);
|
|
204
236
|
console.log(`\t${warning.id}`);
|
|
205
237
|
break;
|
|
238
|
+
case 'PLUGIN_WARNING':
|
|
239
|
+
console.log(`${warning.message} at`);
|
|
240
|
+
console.log(`\t${warning.id}`);
|
|
241
|
+
break;
|
|
206
242
|
default:
|
|
207
|
-
console.warn(`\t(!) ${warning.message}`)
|
|
243
|
+
console.warn(`\t${warning.code}(!) ${warning.message}`)
|
|
208
244
|
}
|
|
209
245
|
|
|
210
246
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmmn/tools",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.16",
|
|
4
4
|
"description": "Compilation, bundling, code generator, testing.",
|
|
5
5
|
"main": "dist/rollup.config.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jest/globals": "27.x.x",
|
|
39
|
+
"@modular-css/rollup": "28.x.x",
|
|
39
40
|
"@open-wc/rollup-plugin-html": "^1.2.5",
|
|
40
41
|
"@rollup/plugin-alias": "3",
|
|
41
42
|
"@rollup/plugin-commonjs": "^21",
|
|
42
43
|
"@rollup/plugin-json": "4",
|
|
43
44
|
"@rollup/plugin-node-resolve": "^13",
|
|
45
|
+
"@rollup/plugin-replace": "4.x.x",
|
|
44
46
|
"@rollup/plugin-typescript": "^8",
|
|
45
47
|
"@swc/jest": "0.2.17",
|
|
46
48
|
"@testdeck/jest": "0.2.0",
|
|
@@ -50,9 +52,11 @@
|
|
|
50
52
|
"jest": "27.x.x",
|
|
51
53
|
"less": "^4",
|
|
52
54
|
"rollup": "^2",
|
|
55
|
+
"rollup-plugin-img": "1.x.x",
|
|
53
56
|
"rollup-plugin-livereload": "^2.0.5",
|
|
54
57
|
"rollup-plugin-node-builtins": "^2.1.2",
|
|
55
58
|
"rollup-plugin-node-globals": "^1.4.0",
|
|
59
|
+
"rollup-plugin-postcss": "4.x.x",
|
|
56
60
|
"rollup-plugin-serve": "^1.1.0",
|
|
57
61
|
"rollup-plugin-string": "^3.0.0",
|
|
58
62
|
"rollup-plugin-styles": "^4",
|
|
@@ -65,5 +69,5 @@
|
|
|
65
69
|
},
|
|
66
70
|
"author": "",
|
|
67
71
|
"license": "ISC",
|
|
68
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "dec0db17451f8b98d7e10abc3221c567bcddc72d"
|
|
69
73
|
}
|