You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03-bundling/06-vite/06-typescript/README.md
+8-51Lines changed: 8 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,32 +226,18 @@ Install [Node.js and npm](https://nodejs.org/en/) (20.19.0 || >=22.12.0) if they
226
226
227
227
🔎 Check how we also get error feedback in the console.
228
228
229
-
-Unfortunately, it doesn't prevent us from generating the production bundle, eventhough the `build` script apparently failed. Actually you can run it with:
229
+
-We can see thank to `vite-plugin-checker`it is preventing us from generating the production bundle, with errors.
230
230
231
-
```bash
232
-
npm run preview
233
-
```
234
-
235
-
- But there are a couple of alternatives we can do:
236
-
237
-
### Alternative 1
238
-
239
-
- Let's update the `package.json` to run `tsc` before production build:
231
+
```text
232
+
vite v7.0.4 building for production...
233
+
✓ 2 modules transformed.
234
+
src/index.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'.
240
235
241
-
```diff
242
-
"scripts": {
243
-
"start": "vite",
244
-
+ "type-check": "tsc --noEmit",
245
-
+ "prebuild": "npm run type-check",
246
-
"build": "vite build",
247
-
"preview": "vite preview"
248
-
},
249
-
```
236
+
2 const numberB: string = 3;
237
+
~~~~~~~
250
238
251
-
🔎 Let's check we cannot build for production until all compilation errors are cleared:
252
239
253
-
```bash
254
-
npm run build
240
+
Found 1 error in src/index.ts:2
255
241
```
256
242
257
243
- So, we can only fix the issue to continue:
@@ -265,32 +251,3 @@ Install [Node.js and npm](https://nodejs.org/en/) (20.19.0 || >=22.12.0) if they
265
251
```
266
252
267
253
🔎 Run now a production build and check how it goes smoothly.
268
-
269
-
### Alternative 2
270
-
271
-
- Let's tweak `rollup`, which is run under the hood for bundling in production, and let's configure its typescript plugin to prevent emitting any artifact if transpilation fails. First, install the plugin and a required `tslib` dependency:
Copy file name to clipboardExpand all lines: 03-bundling/06-vite/06-typescript/package.json
+2-6Lines changed: 2 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,19 @@
1
1
{
2
2
"name": "hello-vite",
3
3
"private": true,
4
-
"type": "module",
5
4
"version": "0.0.0",
6
5
"description": "Let's start with a very basic sample, just add an html plus a simple console log (E5). This is what you can find in the getting started tutorial.",
@@ -140,7 +134,7 @@ Install [Node.js and npm](https://nodejs.org/en/) (20.19.0 || >=22.12.0) if they
140
134
npm start
141
135
```
142
136
143
-
🔎 First of all, chech your `react` application is up and running!
137
+
🔎 First of all, check your `react` application is up and running!
144
138
145
139
🔎 Then, look at the dev-tools `network` tab (refresh if needed) and, apart from the source code ES modules we already know, you will see a couple of `vite` pre-bundled dependencies: `react-dom_client` and `react_jsx-dev-runtime`. Take a look at both requests, they share a few things in common:
0 commit comments