• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..04-Mar-2022-

__tests__/H04-Mar-2022-603406

dist/H04-Mar-2022-42

jest/H04-Mar-2022-9439

Boolean.jsH A D03-Mar-2022185 128

Browser.jsH A D03-Mar-20221.1 KiB4834

ComboDate.jsH A D03-Mar-2022565 1912

ComboModal.jsH A D03-Mar-202211.5 KiB444259

DokuRequest.jsH A D03-Mar-20224.5 KiB184118

FormMeta.jsH A D03-Mar-20229.9 KiB340241

FormMetaField.jsH A D03-Mar-202214.7 KiB524370

FormMetaTab.jsH A D03-Mar-20222.1 KiB9677

Html.jsH A D03-Mar-2022872 3420

Logger.jsH A D03-Mar-2022665 3015

README.mdH A D03-Mar-20223.1 KiB11484

Xml.jsH A D03-Mar-20225 KiB16196

combo.jsH A D03-Mar-20221.1 KiB5634

README.md

1Library
2=======
3
4* Parcel to bundle
5* Babel-preset to support ES module
6* Jest for test
7
8Configuration
9=============
10
11### Babel
12
13`.babelrc` was written as per the [Jest documentation](https://jestjs.io/docs/getting-started#using-babel).
14
15### Parcel
16
17#### Transpilation problem
18
19To avoid this warning:
20
21```txt
22@parcel/transformer-babel: @babel/preset-env does not support Parcel's targets, which will likely result in unnecessary transpilation and larger bundle sizes.
23```
24
25`.parcelrc` was written to avoid double babel transpilation as dictated in
26the [doc](https://parceljs.org/languages/javascript/#usage-with-other-tools)
27It disable Babel transpilation in Parcel because Jest needs it also.
28
29#### Bootstrap
30
31Bootstrap been added as in `package.json`:
32
33* a [peer dependency](https://classic.yarnpkg.com/en/docs/dependency-types#toc-peerdependencies) (ie needed to run)
34* and a [dev dependency](https://github.com/yannickcr/eslint-plugin-react/issues/2332) (needed for library dependencies
35  resolution)
36
37```bash
38yarn add bootstrap --dev
39yarn add bootstrap --peer
40yarn add @popperjs/core --dev
41yarn add @popperjs/core --peer
42```
43
44Then we set it as an [global alias](https://parceljs.org/features/dependency-resolution/#global-aliases) in `package.json`
45to create a bootstrap global variable at build time
46```json
47{
48    "alias": {
49        "bootstrap": {
50            "global": "bootstrap"
51        }
52    }
53}
54```
55it means that all `from "bootstrap"` are replaced by the alias. ie
56
57```javascript
58import {Modal} from "bootstrap";
59
60let bootStrapModal = new Modal(this.modalRoot, options);
61```
62is replaced when bundling by:
63```javascript
64let bootStrapModal = new bootstrap.Modal(this.modalRoot, options);
65```
66
67See also the [bootstrap doc](https://getbootstrap.com/docs/5.0/getting-started/parcel/)
68
69#### Build / UMD
70
71We are not building a library (in parcel term, this is a node package to be used by other)
72
73The [entry](https://parceljs.org/features/targets/#entries) is defined in the `source`
74[package.json script](package.json)
75
76[UMD is not supported on Parcel 2](
77getting-started/migration/#--global), we then used `window``explicitly to set the value.
78
79* Old: https://en.parceljs.org/cli.html#expose-modules-as-umd
80* MIgration:
81  https://github.com/parcel-bundler/parcel/issues/766
82  https://github.com/parcel-bundler/parcel/discussions/6437
83  https://github.com/parcel-bundler/parcel/discussions/5583
84
85## Jest JsDom Execution Environment
86
87In the `jest` [package.json](package.json) conf, all test are started
88
89* in the `jsdom` [environment](https://jestjs.io/docs/configuration#testenvironment-string)
90* configured via the [test environment options](https://jestjs.io/docs/configuration#testenvironmentoptions-object) and
91  the [possible configuration value of jsdom](https://github.com/jsdom/jsdom#customizing-jsdom)
92
93```json
94{
95    "jest": {
96        "testEnvironment": "jsdom",
97        "testEnvironmentOptions": {
98            "userAgent": "Agent/007"
99        }
100    }
101}
102```
103
104You can change it by test with `jsdoc` annotation
105
106```javascript
107/**
108 * @jest-environment jsdom
109 */
110```
111
112The jsdom jest environment code can be
113found [here](https://github.com/facebook/jest/blob/main/packages/jest-environment-jsdom/src/index.ts)
114