Skip to content

Commit 1bfb1c5

Browse files
committed
Restrict published package to compiled output
`@oicl/openbridge-webcomponents@1.0.1` ships at 136 MB unpacked / 14,173 files. Two compounding problems: **Test infrastructure leaking into the build.** `vite.config.ts` configures `src/**/*.ts` as rollup input with only `*.stories.ts` excluded. That sweeps in `*.spec.ts` files (importing `vitest` and `vitest-browser-lit`), `src/storybook-util.ts` (importing `@open-wc/lit-helpers`), and `src/ar/_test-utils.ts` (a Storybook visual-test settle helper). Combined with `preserveModules: true` and an externals list that doesn't cover test deps, rollup faithfully outputs `vitest`, `@vitest`, `@open-wc`, `magic-string`, `tinyrainbow`, etc. under `dist/node_modules/`. Extend the input glob's `ignore` to also exclude `*.spec.ts`, `*.test.ts`, `src/storybook-util.ts`, and `src/ar/_test-utils.ts`, and mirror the same exclude on `vite-plugin-dts` so it stops emitting `.d.ts` for those files. **No `files` allowlist.** Without one, npm publishes everything in the package directory: - `__vis__/linux/` (40 MB) — Playwright visual baselines - `src/` (7 MB) — TS source, redundant with `dist/` - `public/` (8 MB) — demo assets - `AR-test-image.png` × 3 (24 MB) and `NotoSans.ttf` × 3 (1.8 MB) — same assets shipped in `bundle/`, `dist/`, `public/` - `companylogo-day.png` — demo asset used only by Storybook stories Add an explicit `files` allowlist scoped to `dist/`, the standalone bundle + sourcemap, and the custom-elements manifest. Drop `dist/AR-test-image.png` and `dist/companylogo-day.png` via negation since neither is referenced by shipped code. Keep one copy of `NotoSans.ttf` (in `dist/`) so consumers can `@font-face` against it. Also delete `public/vite.svg` — leftover from initial `npm create vite` scaffolding, unreferenced anywhere — so it no longer auto-copies into `dist/` during the regular build. Result (measured locally): **7.2 MB tarball / 55.0 MB unpacked / 9,698 files** — down from ~59 MB / 136 MB / 14,173.
1 parent c4eb8f5 commit 1bfb1c5

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/openbridge-webcomponents/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@
121121
},
122122
"types": "./dist/index.d.ts",
123123
"main": "./dist/index.js",
124+
"files": [
125+
"dist",
126+
"!dist/AR-test-image.png",
127+
"!dist/companylogo-day.png",
128+
"bundle/openbridge-webcomponents.bundle.js",
129+
"bundle/openbridge-webcomponents.bundle.js.map",
130+
"custom-elements.json"
131+
],
124132
"publishConfig": {
125133
"access": "public"
126134
},

packages/openbridge-webcomponents/public/vite.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/openbridge-webcomponents/vite.config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ import postcssConfig from './postcss.config.mjs';
77
import fs from 'fs';
88
import path from 'path';
99

10-
const input = globbySync('src/**/*.ts', {ignore: ['src/**/*.stories.ts']});
10+
const input = globbySync('src/**/*.ts', {
11+
ignore: [
12+
'src/**/*.stories.ts',
13+
'src/**/*.spec.ts',
14+
'src/**/*.test.ts',
15+
'src/storybook-util.ts',
16+
'src/ar/_test-utils.ts',
17+
],
18+
});
1119

1220
// https://vitejs.dev/config/
1321
export default defineConfig(({mode}) => {
@@ -62,6 +70,13 @@ export default defineConfig(({mode}) => {
6270
postcssLit(),
6371
dts({
6472
clearPureImport: false,
73+
exclude: [
74+
'src/**/*.stories.ts',
75+
'src/**/*.spec.ts',
76+
'src/**/*.test.ts',
77+
'src/storybook-util.ts',
78+
'src/ar/_test-utils.ts',
79+
],
6580
}),
6681
{
6782
name: 'custom-postcss',

0 commit comments

Comments
 (0)