@websolutespa/bom-compiler 3.1.0 → 3.1.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/index.js +84 -84
  3. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @websolutespa/bom-compiler
2
2
 
3
+ ## 3.1.2
4
+
5
+ ## 3.1.1
6
+
3
7
  ## 3.1.0
4
8
 
5
9
  ### Minor Changes
package/index.js CHANGED
@@ -1,84 +1,84 @@
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
+
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websolutespa/bom-compiler",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
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.0",
22
- "@websolutespa/tsconfig": "^3.1.0",
21
+ "@websolutespa/eslint-config": "^3.1.2",
22
+ "@websolutespa/tsconfig": "^3.1.2",
23
23
  "typescript": "6.0.3"
24
24
  },
25
25
  "publishConfig": {