@cmmn/tools 1.4.3 → 1.4.13

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 CHANGED
@@ -89,16 +89,16 @@ export async function bundle(...options) {
89
89
  console.log('START BUNDLING');
90
90
  break;
91
91
  case 'END':
92
- console.log('FINISH');
92
+ console.log(`FINISH at ${new Date().toTimeString().substring(0,8)}`);
93
93
  break;
94
94
  case 'BUNDLE_START':
95
95
  for (let key in event.input){
96
- console.log(`1. ${key} -> ${event.output}`);
96
+ console.log(`\t${key} -> ${event.output}`);
97
97
  }
98
98
  break;
99
99
  case 'BUNDLE_END':
100
100
  for (let key in event.input){
101
- console.log(`1. ${key} -> ${event.output}, (${event.duration / 1000}s)`);
101
+ console.log(`\t${key} -> ${event.output}, (${event.duration / 1000}s)`);
102
102
  }
103
103
  break;
104
104
 
@@ -119,6 +119,8 @@ export async function bundle(...options) {
119
119
  break;
120
120
  }
121
121
  break;
122
+ default:
123
+ console.warn('WARNING:', event)
122
124
  }
123
125
  });
124
126
  }
@@ -80,6 +80,7 @@ export class ConfigCreator {
80
80
  dir: this.outDir,
81
81
  sourcemap: true,
82
82
  format: module,
83
+ globals: Object.fromEntries(this.options.external.map(x => [x,x])),
83
84
  name: this.options.global ?? 'global',
84
85
  }));
85
86
  }
@@ -193,16 +194,19 @@ export class ConfigCreator {
193
194
  [this.options.name]: path.join(this.root, this.options.input)
194
195
  },
195
196
  output: this.output,
196
- external: (this.options.external || []).map(s => new RegExp(s)),
197
+ external: (this.options.external || []),
197
198
  onwarn(warning) {
198
- // Silence circular dependency warning for moment package
199
- if (
200
- warning.code === 'CIRCULAR_DEPENDENCY'
201
- ) {
202
- return
199
+ switch (warning.code){
200
+ case 'CIRCULAR_DEPENDENCY':
201
+ return;
202
+ case 'THIS_IS_UNDEFINED':
203
+ console.log(`${warning.message} at`);
204
+ console.log(`\t${warning.id}`);
205
+ break;
206
+ default:
207
+ console.warn(`\t(!) ${warning.message}`)
203
208
  }
204
209
 
205
- console.warn(`(!) ${warning.message}`)
206
210
  },
207
211
  plugins: this.plugins,
208
212
  treeshake: this.options.minify ? "smallest" : "recommended",
@@ -1,5 +1,5 @@
1
1
  import ts from "ttypescript";
2
- import {resolve} from 'path';
2
+ import {resolve, relative} from 'path';
3
3
 
4
4
  const rootDir = process.cwd();
5
5
 
@@ -16,7 +16,7 @@ export function compile(...flags) {
16
16
  incremental: true,
17
17
  dry: false
18
18
  }, {
19
- excludeDirectories: ["node_modules", "dist"]
19
+ excludeDirectories: ["node_modules", "dist"],
20
20
  });
21
21
  builder.clean(rootDir);
22
22
  builder.build(rootDir);
@@ -26,7 +26,7 @@ function createProgram(rootNames, options, host, oldProgram, configFileParsingDi
26
26
  options.outDir = resolve(options.configFilePath, '../dist/esm');
27
27
  options.declarationDir = resolve(options.configFilePath, '../dist/typings');
28
28
  options.baseUrl = resolve(options.configFilePath, '../');
29
- console.log('build', options.configFilePath);
29
+ console.log('\t', relative(process.cwd(), options.baseUrl));
30
30
  return ts.createEmitAndSemanticDiagnosticsBuilderProgram(
31
31
  rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences
32
32
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmmn/tools",
3
- "version": "1.4.3",
3
+ "version": "1.4.13",
4
4
  "description": "Compilation, bundling, code generator, testing.",
5
5
  "main": "dist/rollup.config.js",
6
6
  "type": "module",
@@ -65,5 +65,5 @@
65
65
  },
66
66
  "author": "",
67
67
  "license": "ISC",
68
- "gitHead": "8c702b1a1d2608f4eb47102a6bce712b678d6304"
68
+ "gitHead": "2dc32e552dd5877be0ceb18f64cb896f13f15303"
69
69
  }
@@ -37,6 +37,8 @@ function visitImportNode(importNode, sourceFile, options) {
37
37
  const relFile = path.relative(absSource, abs).replaceAll(path.sep, '/');
38
38
  return ts.updateImportDeclaration(importNode, importNode.decorators, importNode.modifiers, importNode.importClause, ts.createStringLiteral(relFile));
39
39
  }
40
+ if (/\.(json|tsx?|jsx?)$/.test(file))
41
+ return;
40
42
  if (fs.existsSync(abs + '.ts')) {
41
43
  return ts.updateImportDeclaration(importNode, importNode.decorators, importNode.modifiers, importNode.importClause, ts.createStringLiteral(file + '.js'));
42
44
  }