@cmmn/tools 1.4.2 → 1.4.12

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
  }
@@ -195,14 +195,17 @@ export class ConfigCreator {
195
195
  output: this.output,
196
196
  external: (this.options.external || []).map(s => new RegExp(s)),
197
197
  onwarn(warning) {
198
- // Silence circular dependency warning for moment package
199
- if (
200
- warning.code === 'CIRCULAR_DEPENDENCY'
201
- ) {
202
- return
198
+ switch (warning.code){
199
+ case 'CIRCULAR_DEPENDENCY':
200
+ return;
201
+ case 'THIS_IS_UNDEFINED':
202
+ console.log(`${warning.message} at`);
203
+ console.log(`\t${warning.id}`);
204
+ break;
205
+ default:
206
+ console.warn(`\t(!) ${warning.message}`)
203
207
  }
204
208
 
205
- console.warn(`(!) ${warning.message}`)
206
209
  },
207
210
  plugins: this.plugins,
208
211
  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.2",
3
+ "version": "1.4.12",
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": "824d290afabaa3a44ccb98322cb1758825bd9efb"
68
+ "gitHead": "6d71154c76d97bf9e1a8ebd52ab3c31df797d56d"
69
69
  }
@@ -14,7 +14,7 @@ function visitExportNode(exportNode, sourceFile) {
14
14
  const abs = path.resolve(sourceFileDir, file);
15
15
  if (/\.(less|css|scss|sass|svg|png|html)$/.test(file)) {
16
16
  const absSource = path.join(options.outDir, path.relative(options.baseUrl, sourceFileDir));
17
- const relFile = path.relative(absSource, abs)
17
+ const relFile = path.relative(absSource, abs).replaceAll(path.sep, '/');
18
18
  return ts.updateExportDeclaration(exportNode, exportNode.decorators, exportNode.modifiers, exportNode.exportClause, ts.createStringLiteral(relFile), exportNode.typeOnly);
19
19
  }
20
20
  if (fs.existsSync(abs + '.ts')) {
@@ -34,9 +34,11 @@ function visitImportNode(importNode, sourceFile, options) {
34
34
  const abs = path.resolve(sourceFileDir, file);
35
35
  if (/\.(less|css|scss|sass|svg|png|html)$/.test(file)) {
36
36
  const absSource = path.join(options.outDir, path.relative(options.baseUrl, sourceFileDir));
37
- const relFile = path.relative(absSource, abs)
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
  }
@@ -56,7 +58,7 @@ function visitRequireNode(importNode, sourceFile) {
56
58
  const sourceFileDir = path.dirname(sourceFile.path);
57
59
  const abs = path.join(sourceFileDir, file);
58
60
  const absSource = path.join(options.outDir, path.relative(options.baseUrl, sourceFileDir));
59
- const relFile = path.relative(absSource, abs)
61
+ const relFile = path.relative(absSource, abs).replaceAll(path.sep, '/');
60
62
  return ts.updateCall(importNode, importNode.expression, undefined, [ts.createStringLiteral(relFile)]);
61
63
  }
62
64
  }