1
1
# Electron-React-TypeScript-Webpack (ERTW) Boilerplate
2
- ![ badge-ver] ![ badge-license]
2
+ ![ badge-ver] ![ badge-node-ver] ![ badge-license]
3
+
4
+ [ badge-ver ] : https://img.shields.io/github/package-json/v/devtography/electron-react-typescript-webpack-boilerplate
5
+ [ badge-license ] : https://img.shields.io/github/license/Devtography/electron-react-typescript-webpack-boilerplate
6
+ [ badge-node-ver ] : https://img.shields.io/badge/node--lts-%3E%3D16-orange
3
7
4
8
A boilerplate that let you instantly start working on your next [ Electron] app
5
9
project in [ TypeScript] with no time wasted messing with the config files.
@@ -34,6 +38,8 @@ implemented, please [file an issue], or consider make a [new pull request].
34
38
- [ ] Integrate another end-to-end testing framework to replace [ Spectron]
35
39
- [ ] Migrate to Webpack 5 ` Asset Modules ` __ * (pending for ` v4.2.0 ` )* __
36
40
- [ ] Integrate HMR & Webpack dev server
41
+ - [x] Monitor the status of ESM support on [ Jest] & [ ts-jest]
42
+ __ * (Check [ Known issues] ( #known-issues ) for details)* __
37
43
38
44
---
39
45
@@ -57,6 +63,11 @@ implemented, please [file an issue], or consider make a [new pull request].
57
63
to support ES module for its' config file. __ Converting the config file to
58
64
ES module will result in ESLint not working.__
59
65
66
+ - As of [ ` v4.1.2 ` ] , [ Jest] & [ ts-jest] are __ NOT__ configured to run the test
67
+ files as ES modules, despite all other sections of this boilerplate are
68
+ configured to support native ES modules. Please check
69
+ [ Known issues] ( #known-issues ) for details.
70
+
60
71
---
61
72
62
73
## Getting started
@@ -134,6 +145,42 @@ To package your Electron app, run `npm run prod` to get your code compiled in
134
145
uses Webpack to minify your code in `production` builds, so there shouldn't
135
146
be any significant performance difference with `asar` archiving disabled.
136
147
148
+ - __IMPORTANT!!!__
149
+
150
+ As of [`v4.1.2`], the `jest.mock()` function is broken if [Jest] and [ts-jest]
151
+ are configured with [ESM Support]. The following code will result in a
152
+ `SyntaxError` being thrown when trying to execute the test with Jest.
153
+
154
+ ```ts
155
+ import { jest } from '@jest/globals';
156
+ import { BrowserWindow } from 'electron';
157
+
158
+ jest.mock('electron', () => {
159
+ BrowserWindow: jest.fn().mockImplementation(() => {
160
+ loadFile: jest.fn(() => Promise.resolve()),
161
+ on: jest.fn(),
162
+ }),
163
+ });
164
+ ```
165
+
166
+ ```
167
+ SyntaxError: The requested module 'electron' does not provide an export named 'BrowserWindow'
168
+ ```
169
+
170
+ The current solution is to keep using the non ESM supported version of
171
+ ` jest.config.js ` , but with ` NODE_OPTIONS=--experimental-vm-modules ` set when
172
+ running Jest (already set in [ ` v4.1.2 ` ] ). The drawback of this is you won't
173
+ be able to use ` import.meta ` APIs in your code. It could be a deal breaker for
174
+ some of you.
175
+
176
+ I'm closely monitoring the situation atm, and I'll consider rollback the ESM
177
+ related setting introduced in [ ` v4.1.0 ` ] if there's no progress made solving
178
+ this issue by the time I prepare the release of ` v4.2.0 ` . You can track the
179
+ progress on a related issue [ facebook/jest #10025 ] if you want.
180
+
181
+ [ ESM Support ] : https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/
182
+ [ facebook/jest #10025 ] : https://github.com/facebook/jest/issues/10025
183
+
137
184
## Project folders & files
138
185
- ` dist/ ` - [ Webpack] output location
139
186
@@ -163,8 +210,8 @@ To package your Electron app, run `npm run prod` to get your code compiled in
163
210
many APIs for IPC. See example as below:
164
211
``` ts
165
212
// ipc-api/index.ts
166
- import submoduleA from './submodule-a';
167
- import submoduleB from './submodule-b';
213
+ import submoduleA from ' ./submodule-a.js ' ;
214
+ import submoduleB from ' ./submodule-b.js ' ;
168
215
169
216
export default { ... submoduleA , ... submoduleB };
170
217
@@ -217,6 +264,7 @@ To package your Electron app, run `npm run prod` to get your code compiled in
217
264
you ' d use TypeScript if you' re using this boilerplate .
218
265
219
266
- ` main/main.spec.ts ` - Sample test file for ` src/main/main `
267
+ - ` utils/node-env.spec.ts ` - Unit test for ` src/utils/node-env `
220
268
- ` tsconfig.json ` - TypeScript config file for ` tests ` module
221
269
- ` .eslintignore ` - [ESLint ] ignore file
222
270
- ` .eslintrc.cjs ` - [ESLint ] config file
@@ -263,9 +311,6 @@ great roasters I know 😉 ☕️️
263
311
Electron React TypeScript Webpack Boilerplate is open source software
264
312
[licensed as MIT ](LICENSE ).
265
313
266
- [badge-ver ]: https://img.shields.io/github/package-json/v/devtography/electron-react-typescript-webpack-boilerplate
267
- [badge-license ]: https://img.shields.io/github/license/Devtography/electron-react-typescript-webpack-boilerplate
268
-
269
314
[Electron ]: https :// www.electronjs.org
270
315
[React ]: https :// reactjs.org
271
316
[Webpack ]: https :// webpack.js.org
@@ -276,6 +321,7 @@ Electron React TypeScript Webpack Boilerplate is open source software
276
321
[file an issue ]: https :// www.electronjs.org
277
322
[new pull request ]: https :// github.com/Devtography/electron-react-typescript-webpack-boilerplate/compare
278
323
[Spectron ]: https :// github.com/electron-userland/spectron
324
+ [ts - jest ]: https :// github.com/kulshekhar/ts-jest
279
325
[Playwright ]: https :// playwright.dev
280
326
[WebdriverIO ]: https :// webdriver.io
281
327
[Spectron Deprecation Notice ]: https :// www.electronjs.org/blog/spectron-deprecation-notice
@@ -291,3 +337,4 @@ Electron React TypeScript Webpack Boilerplate is open source software
291
337
[` v3.0.0 ` ]: https :// github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v3.0.0
292
338
[` v4.0.0 ` ]: https :// github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v4.0.0
293
339
[` v4.1.0 ` ]: https :// github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v4.1.0
340
+ [` v4.1.2 ` ]: https :// github.com/Devtography/electron-react-typescript-webpack-boilerplate/releases/tag/v4.1.2
0 commit comments