@cmmn/tools 1.4.12 → 1.4.17

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/bin.js CHANGED
File without changes
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(path.join(rootDir, 'package.json')));
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.error(event.error.message);
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);
@@ -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,7 +13,10 @@ 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';
17
+ import postCSS from "rollup-plugin-postcss"
15
18
 
19
+ import flexbugs from 'postcss-flexbugs-fixes';
16
20
  /**
17
21
  * @typedef {import(rollup).RollupOptions} RollupOptions
18
22
  * @typedef {import(rollup).OutputOptions} OutputOptions
@@ -29,6 +33,7 @@ export class ConfigCreator {
29
33
  * external: string[],
30
34
  * stats: boolean,
31
35
  * name: string,
36
+ * styles: 'modules' | null,
32
37
  * outDir: string,
33
38
  * html: string,
34
39
  * browser: boolean,
@@ -80,6 +85,7 @@ export class ConfigCreator {
80
85
  dir: this.outDir,
81
86
  sourcemap: true,
82
87
  format: module,
88
+ globals: Array.isArray(this.options.external) ? Object.fromEntries(this.options.external.map(x => [x, x])) : this.options.external,
83
89
  name: this.options.global ?? 'global',
84
90
  }));
85
91
  }
@@ -124,6 +130,10 @@ export class ConfigCreator {
124
130
 
125
131
  get plugins() {
126
132
  const result = [
133
+ replace({
134
+ 'process.env.NODE_ENV': JSON.stringify('development'),
135
+ preventAssignment: true
136
+ }),
127
137
  nodeResolve({
128
138
  browser: this.options.browser,
129
139
  dedupe: this.options.dedupe || []
@@ -135,11 +145,31 @@ export class ConfigCreator {
135
145
  ]
136
146
  }),
137
147
  builtins(),
138
- styles({
139
- mode: "emit",
148
+ this.options.styles === 'modules' ? postCSS({
149
+ mode: [
150
+ "inject",
151
+ {container: "head", prepend: true, attributes: {id: "global"}},
152
+ ],
153
+ plugins: [
154
+ flexbugs,
155
+ ],
156
+ modules: {
157
+ root: ''
158
+ },
159
+ namedExports: false,
160
+ autoModules: true,
161
+ }) : styles({
162
+ mode: "emit"
163
+ }),
164
+ image({
165
+ output: `/assets`, // default the root
166
+ extensions: /\.(png|jpg|jpeg|gif)$/, // support png|jpg|jpeg|gif|svg, and it's alse the default value
167
+ limit: 8192, // default 8192(8k)
168
+ exclude: 'node_modules/**'
140
169
  }),
141
170
  string({
142
- include: /\.(html|svg|less|css)$/,
171
+ include: /\.(html|svg|less)$/,
172
+ exclude: /\.module\.css/
143
173
  }),
144
174
  json(),
145
175
 
@@ -175,6 +205,14 @@ export class ConfigCreator {
175
205
  return result;
176
206
  }
177
207
 
208
+ getExternals() {
209
+ if (!this.options.external)
210
+ return [];
211
+ if (Array.isArray(this.options.external))
212
+ return this.options.external.map(s => new RegExp(s));
213
+ return Object.keys(this.options.external).map(s => new RegExp(s));
214
+ }
215
+
178
216
  /**
179
217
  * @returns {RollupOptions[]}
180
218
  */
@@ -187,23 +225,27 @@ export class ConfigCreator {
187
225
  });
188
226
  if (this.options.external && typeof this.options.external === "string")
189
227
  this.options.external = [this.options.external]
190
- console.log(this.options);
228
+ console.log(this.options.name, this.options);
191
229
  return [{
192
230
  input: {
193
231
  [this.options.name]: path.join(this.root, this.options.input)
194
232
  },
195
233
  output: this.output,
196
- external: (this.options.external || []).map(s => new RegExp(s)),
234
+ external: this.getExternals(),
197
235
  onwarn(warning) {
198
- switch (warning.code){
236
+ switch (warning.code) {
199
237
  case 'CIRCULAR_DEPENDENCY':
200
238
  return;
201
239
  case 'THIS_IS_UNDEFINED':
202
240
  console.log(`${warning.message} at`);
203
241
  console.log(`\t${warning.id}`);
204
242
  break;
243
+ case 'PLUGIN_WARNING':
244
+ console.log(`${warning.message} at`);
245
+ console.log(`\t${warning.id}`);
246
+ break;
205
247
  default:
206
- console.warn(`\t(!) ${warning.message}`)
248
+ console.warn(`\t${warning.code}(!) ${warning.message}`)
207
249
  }
208
250
 
209
251
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.4.12",
3
+ "version": "1.4.17",
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",
@@ -49,10 +51,15 @@
49
51
  "fast-glob": "^3.2.11",
50
52
  "jest": "27.x.x",
51
53
  "less": "^4",
54
+ "postcss-composes": "^0.1.0",
55
+ "postcss-flexbugs-fixes": "5.x.x",
56
+ "postcss-normalize": "10.x.x",
52
57
  "rollup": "^2",
58
+ "rollup-plugin-img": "1.x.x",
53
59
  "rollup-plugin-livereload": "^2.0.5",
54
60
  "rollup-plugin-node-builtins": "^2.1.2",
55
61
  "rollup-plugin-node-globals": "^1.4.0",
62
+ "rollup-plugin-postcss": "4.x.x",
56
63
  "rollup-plugin-serve": "^1.1.0",
57
64
  "rollup-plugin-string": "^3.0.0",
58
65
  "rollup-plugin-styles": "^4",
@@ -65,5 +72,5 @@
65
72
  },
66
73
  "author": "",
67
74
  "license": "ISC",
68
- "gitHead": "6d71154c76d97bf9e1a8ebd52ab3c31df797d56d"
75
+ "gitHead": "5306e035e572997381eddb0ec715af52a1428b74"
69
76
  }