@pixpilot/scaffoldfy-configs 0.22.0 → 0.24.0

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,18 @@
1
1
  # @pixpilot/scaffoldfy-configs
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - add sideEffects and platform configuration for npm packages
8
+ - add support for configuration files hosted on URLs
9
+
10
+ ## 0.23.0
11
+
12
+ ### Minor Changes
13
+
14
+ - enhance test scripts and add coverage dependencies
15
+
3
16
  ## 0.22.0
4
17
 
5
18
  ### Minor Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/scaffoldfy-configs",
3
3
  "type": "module",
4
- "version": "0.22.0",
4
+ "version": "0.24.0",
5
5
  "author": "PixPilot <m.doaie@hotmail.com>",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -24,10 +24,10 @@
24
24
  "@types/node": "^22.18.11",
25
25
  "eslint": "^9.38.0",
26
26
  "@internal/eslint-config": "0.3.0",
27
- "@internal/tsdown-config": "0.1.0",
28
- "@internal/prettier-config": "0.0.1",
29
27
  "@internal/vitest-config": "0.1.0",
30
- "@pixpilot/scaffoldfy": "0.48.0"
28
+ "@internal/tsdown-config": "0.1.0",
29
+ "@pixpilot/scaffoldfy": "0.49.0",
30
+ "@internal/prettier-config": "0.0.1"
31
31
  },
32
32
  "prettier": "@internal/prettier-config",
33
33
  "publishConfig": {
@@ -198,8 +198,16 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
198
198
 
199
199
  expect(pkg.name).toBe('@internal/my-package');
200
200
  expect(pkg.private).toBe(true);
201
+ expect(pkg.sideEffects).toBeUndefined();
201
202
  expect(pkg.publishConfig).toBeUndefined();
202
203
  expect(pkg.files).toBeUndefined();
204
+ expect(pkg.scripts?.['test:ui']).toBe('vitest --ui --watch');
205
+ expect(pkg.scripts?.['test:ui:coverage']).toBe(
206
+ 'vitest --ui --coverage --watch --hookTimeout=30000 --coverage.thresholds.lines=0 --coverage.thresholds.functions=0 --coverage.thresholds.branches=0 --coverage.thresholds.statements=0',
207
+ );
208
+ expect(pkg.devDependencies?.['@vitest/coverage-v8']).toBe('catalog:dev');
209
+ expect(pkg.devDependencies?.['@vitest/ui']).toBe('catalog:dev');
210
+ expect(pkg.devDependencies?.vitest).toBe('catalog:dev');
203
211
  });
204
212
 
205
213
  /** Public npm package with tsdown bundler */
@@ -226,6 +234,7 @@ describe('workspace-package-generator – package.json.hbs rendering', () => {
226
234
 
227
235
  expect(pkg.name).toBe('@myorg/my-package');
228
236
  expect(pkg.private).toBeUndefined();
237
+ expect(pkg.sideEffects).toBe(false);
229
238
  expect(pkg.publishConfig?.access).toBe('public');
230
239
  expect(pkg.files).toContain('dist');
231
240
  expect(pkg.scripts?.build).toBe('tsdown');
@@ -314,6 +323,26 @@ describe('workspace-package-generator – tsdown.config.ts.hbs rendering', () =>
314
323
  expect(rendered).toContain('MAX_BUNDLE_SIZE_KB = 50');
315
324
  expect(rendered).toContain('bundleSize: MAX_BUNDLE_SIZE_KB * KB');
316
325
  });
326
+
327
+ it("should add platform: 'neutral' for an npm package", () => {
328
+ const ctx = {
329
+ tsdownConfigPackage: '@pixpilot/tsdown-config',
330
+ isNpmPackage: true,
331
+ };
332
+ const rendered = renderHbs(tplPath, ctx);
333
+
334
+ expect(rendered).toContain("platform: 'neutral'");
335
+ });
336
+
337
+ it("should not add platform: 'neutral' when not an npm package", () => {
338
+ const ctx = {
339
+ tsdownConfigPackage: '@pixpilot/tsdown-config',
340
+ isNpmPackage: false,
341
+ };
342
+ const rendered = renderHbs(tplPath, ctx);
343
+
344
+ expect(rendered).not.toContain('platform');
345
+ });
317
346
  });
318
347
 
319
348
  describe('workspace-package-generator – src/index.ts.hbs rendering', () => {
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "{{#if isNpmPackage}}{{#if packageOrgName}}@{{packageOrgName}}/{{packageBaseName}}{{else}}{{packageBaseName}}{{/if}}{{else}}@internal/{{packageBaseName}}{{/if}}",
3
3
  "type": "module",
4
+ {{#if isNpmPackage}}
5
+ "sideEffects": false,
6
+ {{/if}}
4
7
  "version": "0.0.0",
5
8
  {{#unless isNpmPackage}}
6
9
  "private": true,
@@ -67,7 +70,8 @@
67
70
  {{/if}}
68
71
  "test": "vitest --run --passWithNoTests",
69
72
  "test:watch": "vitest --watch",
70
- "test:ui": "vitest --ui",
73
+ "test:ui": "vitest --ui --watch",
74
+ "test:ui:coverage": "vitest --ui --coverage --watch --hookTimeout=30000 --coverage.thresholds.lines=0 --coverage.thresholds.functions=0 --coverage.thresholds.branches=0 --coverage.thresholds.statements=0",
71
75
  "test:coverage": "vitest --coverage",
72
76
  "typecheck": "tsc --noEmit",
73
77
  "lint": "eslint",
@@ -77,7 +81,21 @@
77
81
  "@internal/eslint-config": "workspace:*",
78
82
  "@internal/prettier-config": "workspace:*",
79
83
  "@internal/tsconfig": "workspace:*",
84
+ {{#if isNpmPackage}}
85
+ {{#if isBundlerTsdown}}
86
+ {{#if hasTsdownConfig}}
87
+ "{{tsdownConfigPackage}}": "workspace:*",
88
+ {{/if}}
89
+ {{/if}}
90
+ {{/if}}
80
91
  "@internal/vitest-config": "workspace:*",
92
+ {{#if isNpmPackage}}
93
+ {{#if isBundlerTsdown}}
94
+ {{#unless hasTsdownConfig}}
95
+ "{{tsdownConfigPackage}}": "^1.0.0",
96
+ {{/unless}}
97
+ {{/if}}
98
+ {{/if}}
81
99
  "@types/node": "catalog:dev",
82
100
  {{#if isReactPackage}}
83
101
  {{#if isNpmPackage}}
@@ -88,6 +106,8 @@
88
106
  "@types/react-dom": "catalog:",
89
107
  {{/if}}
90
108
  {{/if}}
109
+ "@vitest/coverage-v8": "catalog:dev",
110
+ "@vitest/ui": "catalog:dev",
91
111
  "eslint": "catalog:dev",
92
112
  {{#if isReactPackage}}
93
113
  {{#if isNpmPackage}}
@@ -100,15 +120,11 @@
100
120
  {{/if}}
101
121
  {{#if isNpmPackage}}
102
122
  {{#if isBundlerTsdown}}
103
- "{{tsdownConfigPackage}}": "{{#if hasTsdownConfig}}workspace:*{{else}}^1.0.0{{/if}}",
104
- {{/if}}
105
- {{/if}}
106
- {{#if isNpmPackage}}
107
- {{#if isBundlerTsdown}}
108
123
  "tsdown": "catalog:dev",
109
124
  {{/if}}
110
125
  {{/if}}
111
- "typescript": "catalog:dev"
126
+ "typescript": "catalog:dev",
127
+ "vitest": "catalog:dev"
112
128
  },
113
129
  "prettier": "@internal/prettier-config"
114
130
  }
@@ -13,4 +13,11 @@ export default defineConfig({
13
13
  dts: true,
14
14
  minify: false,
15
15
  clean: true,
16
+ {{#if isNpmPackage}}
17
+ // Keep `process.env.NODE_ENV` intact in the output so each consumer's bundler
18
+ // (Next.js, Vite, etc.) can dead-code-eliminate dev-only guards in production.
19
+ // A `browser` platform would inline it at build time, making dev-only code run
20
+ // unconditionally in shipped bundles.
21
+ platform: 'neutral',
22
+ {{/if}}
16
23
  });