Skip to content

Commit 29fb7c1

Browse files
authored
perf(build): Don't invoke tsc during test and development (#1503)
* Since the repo migrated to Storybook and its Vite builder invoking tsc during development preview is a waste of developer time. * The same goes for unit test runs. Now the test runner uses the esbuild plugin to transform `.ts` files on the fly during testing. * Removed some obsolete npm scripts. The typescript compiler is now invoked only when running `build:publish`, i.e. before release.
1 parent 34dba96 commit 29fb7c1

File tree

4 files changed

+94
-26
lines changed

4 files changed

+94
-26
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ v18.19.1
2727
git clone https://github.com/IgniteUI/igniteui-webcomponents.git
2828
cd igniteui-webcomponents
2929
npm ci
30-
npm run build
30+
npm start
3131
```
3232

3333
## Making Changes

package-lock.json

Lines changed: 68 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@
1818
},
1919
"scripts": {
2020
"start": "npm run storybook",
21-
"build": "npm run clean && npm run build:styles && npm run build:typescript && npm run cem && npm run build:meta",
2221
"build:publish": "npm run cem && node scripts/build.mjs",
23-
"build:typescript": "tsc",
2422
"cem": "cem analyze --config cem.config.mjs",
2523
"cem:watch": "cem analyze --config cem.config.mjs --watch",
2624
"build:styles": "node scripts/build-styles.mjs",
27-
"build:watch": "npm run build:styles && concurrently -k -r \"npm:watch-scss\" \"npm:watch-ts\"",
2825
"build:meta": "node scripts/build-stories.mjs",
2926
"watch-meta": "node scripts/stories-watcher.js ",
3027
"watch-scss": "node scripts/styles-watcher.mjs",
31-
"watch-ts": "tsc --watch --preserveWatchOutput",
32-
"check": "madge --circular --warning --no-spinner dist/src/index.js",
28+
"check": "madge --circular --warning --no-spinner --ts-config ./tsconfig.json --extensions ts src/index.ts",
3329
"clean": "npm run clean:dist && npm run clean:styles && npm run clean:docs",
3430
"clean:dist": "rimraf ./dist",
3531
"clean:styles": "rimraf --glob \"src/**/*.css.ts\"",
@@ -41,10 +37,10 @@
4137
"lint:styles": "stylelint \"src/**/*.scss\"",
4238
"format": "biome check --fix && prettier \"**/*.ts\" --write --ignore-path .gitignore",
4339
"release": "node scripts/gen-changelog.mjs",
44-
"test": "npm run build && wtr --coverage",
45-
"test:watch": "npm run build && concurrently -k -r \"npm:watch-scss\" \"npm:watch-ts\" \"wtr --watch\"",
46-
"storybook": "npm run build && concurrently -k -r \"npm run cem:watch\" \"npm:watch-scss\" \"npm:watch-meta\" \"storybook dev -p 8000 --debug\"",
47-
"storybook:build": "npm run build && storybook build -o ./storybook-static",
40+
"test": "npm run build:styles && wtr --coverage",
41+
"test:watch": "npm run build:styles && concurrently -k -r \"npm:watch-scss\" \"wtr --watch\"",
42+
"storybook": "npm run build:styles && concurrently -k -r \"npm run cem:watch\" \"npm:watch-scss\" \"npm:watch-meta\" \"storybook dev -p 8000\"",
43+
"storybook:build": "npm run build:styles && storybook build -o ./storybook-static",
4844
"build:typedoc:export": "node scripts/build-typedoc.js export",
4945
"build:typedoc:import": "node scripts/build-typedoc.js import",
5046
"build:typedoc:watch": "node scripts/build-typedoc.js watch",
@@ -71,6 +67,7 @@
7167
"@storybook/web-components": "^8.4.6",
7268
"@storybook/web-components-vite": "^8.4.6",
7369
"@types/mocha": "^10.0.10",
70+
"@web/dev-server-esbuild": "^1.0.3",
7471
"@web/test-runner": "^0.19.0",
7572
"@web/test-runner-playwright": "^0.11.0",
7673
"autoprefixer": "^10.4.20",
@@ -90,7 +87,7 @@
9087
"node-watch": "^0.7.4",
9188
"playwright": "^1.49.0",
9289
"postcss": "^8.4.49",
93-
"prettier": "^3.4.1",
90+
"prettier": "^3.4.2",
9491
"rimraf": "^5.0.10",
9592
"sass": "^1.78.0",
9693
"sass-embedded": "^1.78.0",
@@ -105,7 +102,7 @@
105102
"typedoc": "^0.26.11",
106103
"typedoc-plugin-localization": "^3.0.5",
107104
"typescript": "^5.6.3",
108-
"vite": "^6.0.1"
105+
"vite": "^6.0.2"
109106
},
110107
"browserslist": [
111108
"defaults"
@@ -117,5 +114,12 @@
117114
"git add"
118115
]
119116
},
117+
"madge": {
118+
"detectiveOptions": {
119+
"ts": {
120+
"skipTypeImports": true
121+
}
122+
}
123+
},
120124
"customElements": "custom-elements.json"
121125
}

web-test-runner.config.mjs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { fileURLToPath } from 'node:url';
12
import { playwrightLauncher } from '@web/test-runner-playwright';
3+
import { esbuildPlugin } from '@web/dev-server-esbuild';
24

35
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
4-
files: ['dist/**/*.spec.js'],
6+
files: ['src/**/*.spec.ts'],
57
browsers: [playwrightLauncher({ product: 'chromium', headless: true })],
68

79
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
@@ -16,6 +18,13 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
1618
exclude: ['node_modules/**/*', '**/themes/**'],
1719
},
1820

21+
plugins: [
22+
esbuildPlugin({
23+
ts: true,
24+
tsconfig: fileURLToPath(new URL('./tsconfig.json', import.meta.url)),
25+
}),
26+
],
27+
1928
// See documentation for all available options
2029
// https://modern-web.dev/docs/test-runner/cli-and-configuration/#configuration-file
2130
});

0 commit comments

Comments
 (0)