@websolutespa/bom-compiler 3.1.2 → 4.0.0-next.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @websolutespa/bom-compiler
2
2
 
3
+ ## 4.0.0-next.6
4
+
3
5
  ## 3.1.2
4
6
 
5
7
  ## 3.1.1
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # bom-compiler
2
-
3
- [![npm version](https://badge.fury.io/js/%40websolutespa%2Fbom-compiler.svg)](https://badge.fury.io/js/%40websolutespa%2Fbom-compiler)
4
-
5
- [![status alpha](https://img.shields.io/badge/status-alpha-red.svg)](https://shields.io/)
6
-
7
- BOM compiler helper of the [BOM Repository](https://github.com/websolutespa/bom) by [websolute](https://www.websolute.com/).
8
-
9
- ---
10
-
11
- ##### *this library is for internal usage and not production ready*
1
+ # bom-compiler
2
+
3
+ [![npm version](https://badge.fury.io/js/%40websolutespa%2Fbom-compiler.svg)](https://badge.fury.io/js/%40websolutespa%2Fbom-compiler)
4
+
5
+ [![status alpha](https://img.shields.io/badge/status-alpha-red.svg)](https://shields.io/)
6
+
7
+ BOM compiler helper of the [BOM Repository](https://github.com/websolutespa/bom) by [websolute](https://www.websolute.com/).
8
+
9
+ ---
10
+
11
+ ##### _this library is for internal usage and not production ready_
package/index.d.ts CHANGED
@@ -1,9 +1,6 @@
1
- declare function resolveDirname(pathname: string): string;
2
- declare function clean(): Promise<void>;
3
- declare function build(): Promise<void>;
4
- declare function emitDeclaration(): Promise<void>;
5
-
6
- export {
7
- build, clean, emitDeclaration, resolveDirname
8
- };
9
-
1
+ declare function resolveDirname(pathname: string): string;
2
+ declare function clean(): Promise<void>;
3
+ declare function build(): Promise<void>;
4
+ declare function emitDeclaration(): Promise<void>;
5
+
6
+ export { build, clean, emitDeclaration, resolveDirname };
package/index.js CHANGED
@@ -1,84 +1,83 @@
1
-
2
- const path = require('path');
3
- const fs = require('fs');
4
-
5
- function resolveDirname(pathname) {
6
- if (!/\.(t|j)s$/.test(pathname)) {
7
- return pathname;
8
- }
9
- return path.dirname(pathname);
10
- }
11
-
12
- async function clean() {
13
- try {
14
- const cwd = process.cwd();
15
- const distPath = path.join(cwd, 'dist');
16
- fs.rmSync(distPath, { recursive: true, force: true });
17
- } catch (error) {
18
- console.log('BomCompiler.clean', error);
19
- }
20
- }
21
-
22
- function escapeRegExp(text) {
23
- return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
24
- }
25
-
26
- /**
27
- * Shared tsdown options: unbundled modules from `src/index.ts`, dependencies and peerDependencies
28
- * of the compiled package kept external (and devDependencies for declarations, that reference them).
29
- */
30
- function getOptions(withDevDependencies = false) {
31
- const cwd = process.cwd();
32
- const packageJson = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
33
- const externals = [
34
- ...Object.keys(packageJson.dependencies || {}),
35
- ...Object.keys(packageJson.peerDependencies || {}),
36
- ...(withDevDependencies ? Object.keys(packageJson.devDependencies || {}) : []),
37
- ].map(name => new RegExp(`^${escapeRegExp(name)}(/|$)`));
38
- const tsconfig = path.join(cwd, 'tsconfig.json');
39
- return {
40
- config: false,
41
- cwd,
42
- entry: ['src/index.ts'],
43
- deps: { neverBundle: externals },
44
- format: 'esm',
45
- outExtensions: () => ({ dts: '.d.ts', js: '.js' }),
46
- platform: 'neutral',
47
- tsconfig: fs.existsSync(tsconfig) ? tsconfig : false,
48
- unbundle: true,
49
- };
50
- }
51
-
52
- async function build() {
53
- try {
54
- const { build: tsdown } = await import('tsdown');
55
- await tsdown({
56
- ...getOptions(),
57
- dts: false,
58
- outDir: 'dist/esm',
59
- sourcemap: true,
60
- });
61
- } catch (error) {
62
- console.log('BomCompiler.build', error);
63
- }
64
- }
65
-
66
- async function emitDeclaration() {
67
- try {
68
- const { build: tsdown } = await import('tsdown');
69
- await tsdown({
70
- ...getOptions(true),
71
- dts: { emitDtsOnly: true },
72
- outDir: 'dist/types',
73
- });
74
- } catch (error) {
75
- console.log('BomCompiler.emitDeclaration', error);
76
- }
77
- }
78
-
79
- module.exports = {
80
- resolveDirname,
81
- clean,
82
- build,
83
- emitDeclaration,
84
- };
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ function resolveDirname(pathname) {
5
+ if (!/\.(t|j)s$/.test(pathname)) {
6
+ return pathname;
7
+ }
8
+ return path.dirname(pathname);
9
+ }
10
+
11
+ async function clean() {
12
+ try {
13
+ const cwd = process.cwd();
14
+ const distPath = path.join(cwd, 'dist');
15
+ fs.rmSync(distPath, { recursive: true, force: true });
16
+ } catch (error) {
17
+ console.log('BomCompiler.clean', error);
18
+ }
19
+ }
20
+
21
+ function escapeRegExp(text) {
22
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
23
+ }
24
+
25
+ /**
26
+ * Shared tsdown options: unbundled modules from `src/index.ts`, dependencies and peerDependencies
27
+ * of the compiled package kept external (and devDependencies for declarations, that reference them).
28
+ */
29
+ function getOptions(withDevDependencies = false) {
30
+ const cwd = process.cwd();
31
+ const packageJson = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'));
32
+ const externals = [
33
+ ...Object.keys(packageJson.dependencies || {}),
34
+ ...Object.keys(packageJson.peerDependencies || {}),
35
+ ...(withDevDependencies ? Object.keys(packageJson.devDependencies || {}) : []),
36
+ ].map((name) => new RegExp(`^${escapeRegExp(name)}(/|$)`));
37
+ const tsconfig = path.join(cwd, 'tsconfig.json');
38
+ return {
39
+ config: false,
40
+ cwd,
41
+ entry: ['src/index.ts'],
42
+ deps: { neverBundle: externals },
43
+ format: 'esm',
44
+ outExtensions: () => ({ dts: '.d.ts', js: '.js' }),
45
+ platform: 'neutral',
46
+ tsconfig: fs.existsSync(tsconfig) ? tsconfig : false,
47
+ unbundle: true,
48
+ };
49
+ }
50
+
51
+ async function build() {
52
+ try {
53
+ const { build: tsdown } = await import('tsdown');
54
+ await tsdown({
55
+ ...getOptions(),
56
+ dts: false,
57
+ outDir: 'dist/esm',
58
+ sourcemap: true,
59
+ });
60
+ } catch (error) {
61
+ console.log('BomCompiler.build', error);
62
+ }
63
+ }
64
+
65
+ async function emitDeclaration() {
66
+ try {
67
+ const { build: tsdown } = await import('tsdown');
68
+ await tsdown({
69
+ ...getOptions(true),
70
+ dts: { emitDtsOnly: true },
71
+ outDir: 'dist/types',
72
+ });
73
+ } catch (error) {
74
+ console.log('BomCompiler.emitDeclaration', error);
75
+ }
76
+ }
77
+
78
+ module.exports = {
79
+ resolveDirname,
80
+ clean,
81
+ build,
82
+ emitDeclaration,
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-compiler",
3
- "version": "3.1.2",
3
+ "version": "4.0.0-next.6",
4
4
  "description": "Compiler helper of the BOM Repository",
5
5
  "keywords": [
6
6
  "bom",
@@ -18,8 +18,8 @@
18
18
  "typescript": "^6.0.3"
19
19
  },
20
20
  "devDependencies": {
21
- "@websolutespa/eslint-config": "^3.1.2",
22
- "@websolutespa/tsconfig": "^3.1.2",
21
+ "@websolutespa/eslint-config": "^4.0.0-next.6",
22
+ "@websolutespa/tsconfig": "^4.0.0-next.6",
23
23
  "typescript": "6.0.3"
24
24
  },
25
25
  "publishConfig": {
@@ -28,4 +28,4 @@
28
28
  "sideEffects": false,
29
29
  "main": "./index.js",
30
30
  "types": "./index.d.ts"
31
- }
31
+ }