Skip to content

Commit 812dc25

Browse files
authored
chore(perf): prevent core bundle being in both dist files (#50)
1 parent e080b9a commit 812dc25

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/cli/program.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { calculate_coverage, type Coverage, type CoverageResult } from '../lib/index.js'
1+
// import from absolute package name instead of relative import (like ../lib/index.ts)
2+
// to prevent lib/index.js being bundled into cli.js, which would mean that indexjs
3+
// ends up in our /dist twice which is wasteful
4+
import { calculate_coverage, type Coverage, type CoverageResult } from '@projectwallace/css-code-coverage'
25

36
export type Report = {
47
context: {

tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
],
1919
"declaration": true,
2020
"rootDirs": ["src/lib", "src/cli"],
21-
"outDir": "dist"
21+
"outDir": "dist",
22+
"paths": {
23+
// So we can import like an external in the CLI
24+
"@projectwallace/css-code-coverage": ["./src/lib/index.ts"]
25+
}
2226
},
2327
"include": [
2428
"src/lib/index.ts",

tsdown.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default defineConfig([
2020
platform: 'node',
2121
format: 'esm',
2222
dts: false,
23+
// The CLI references the Core via 'external' reference to prevent it
24+
// from ending up as duplicate code in cli.js
25+
external: ['@projectwallace/css-code-coverage'],
2326
plugins: [
2427
codecovVitePlugin({
2528
enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,

0 commit comments

Comments
 (0)