Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 28-Aug-2022 | - | ||||
__tests__/ | H | 28-Aug-2022 | - | 603 | 406 | |
dist/ | H | 28-Aug-2022 | - | 4 | 2 | |
jest/ | H | 28-Aug-2022 | - | 94 | 39 | |
Boolean.js | H A D | 26-Aug-2022 | 185 | 12 | 8 | |
Browser.js | H A D | 26-Aug-2022 | 1.1 KiB | 48 | 34 | |
ComboDate.js | H A D | 26-Aug-2022 | 565 | 19 | 12 | |
ComboModal.js | H A D | 26-Aug-2022 | 11.5 KiB | 444 | 259 | |
DokuRequest.js | H A D | 26-Aug-2022 | 4.5 KiB | 184 | 118 | |
FormMeta.js | H A D | 26-Aug-2022 | 9.9 KiB | 340 | 241 | |
FormMetaField.js | H A D | 26-Aug-2022 | 14.7 KiB | 524 | 370 | |
FormMetaTab.js | H A D | 26-Aug-2022 | 2.1 KiB | 96 | 77 | |
Html.js | H A D | 26-Aug-2022 | 872 | 34 | 20 | |
Logger.js | H A D | 26-Aug-2022 | 665 | 30 | 15 | |
README.md | H A D | 26-Aug-2022 | 3.1 KiB | 114 | 84 | |
Xml.js | H A D | 26-Aug-2022 | 5 KiB | 161 | 96 | |
combo.js | H A D | 26-Aug-2022 | 1.1 KiB | 56 | 34 |
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