@openmrs/esm-feature-flags 5.3.3-pre.1240 → 5.3.3-pre.1247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- @openmrs/esm-feature-flags:build: cache hit, replaying output 4307bc31174b1354
2
- @openmrs/esm-feature-flags:build: Browserslist: caniuse-lite is outdated. Please run:
3
- @openmrs/esm-feature-flags:build:  npx update-browserslist-db@latest
4
- @openmrs/esm-feature-flags:build:  Why you should do it regularly: https://github.com/browserslist/update-db#readme
5
- @openmrs/esm-feature-flags:build: asset openmrs-esm-feature-flags.js 3.95 KiB [emitted] [minimized] (name: main) 1 related asset
6
- @openmrs/esm-feature-flags:build: runtime modules 670 bytes 3 modules
7
- @openmrs/esm-feature-flags:build: orphan modules 8.16 KiB [orphan] 1 module
8
- @openmrs/esm-feature-flags:build: built modules 8.23 KiB [built]
9
- @openmrs/esm-feature-flags:build:  ./src/index.ts + 1 modules 8.19 KiB [built] [code generated]
10
- @openmrs/esm-feature-flags:build:  external "@openmrs/esm-state" 42 bytes [built] [code generated]
11
- @openmrs/esm-feature-flags:build: webpack 5.88.0 compiled successfully in 6305 ms
1
+ @openmrs/esm-feature-flags:build: cache hit, replaying output 27668fb5df5c877b
2
+ @openmrs/esm-feature-flags:build: Browserslist: caniuse-lite is outdated. Please run:
3
+ @openmrs/esm-feature-flags:build:  npx update-browserslist-db@latest
4
+ @openmrs/esm-feature-flags:build:  Why you should do it regularly: https://github.com/browserslist/update-db#readme
5
+ @openmrs/esm-feature-flags:build: asset openmrs-esm-feature-flags.js 3.95 KiB [emitted] [minimized] (name: main) 1 related asset
6
+ @openmrs/esm-feature-flags:build: runtime modules 670 bytes 3 modules
7
+ @openmrs/esm-feature-flags:build: orphan modules 8.16 KiB [orphan] 1 module
8
+ @openmrs/esm-feature-flags:build: built modules 8.23 KiB [built]
9
+ @openmrs/esm-feature-flags:build:  ./src/index.ts + 1 modules 8.19 KiB [built] [code generated]
10
+ @openmrs/esm-feature-flags:build:  external "@openmrs/esm-state" 42 bytes [built] [code generated]
11
+ @openmrs/esm-feature-flags:build: webpack 5.88.0 compiled successfully in 6712 ms
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-esm-feature-flags.js","mappings":"sLAAAA,EAAOC,QAAUC,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaL,QAGrB,IAAID,EAASG,EAAyBE,GAAY,CAGjDJ,QAAS,CAAC,GAOX,OAHAO,EAAoBH,GAAUL,EAAQA,EAAOC,QAASG,GAG/CJ,EAAOC,OACf,CCrBAG,EAAoBK,EAAI,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEX,EAASU,IAC5EE,OAAOC,eAAeb,EAASU,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAKrB,IACH,oBAAXsB,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAeb,EAASsB,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAeb,EAAS,aAAc,CAAEwB,OAAO,GAAO,E,2KCL1B,iB,04BAapC,IAAMC,EAAsB,CAAEC,MAqB9B,WACE,IAAMA,EAAQ,CAAC,EACV,mB,IAAL,QAAK,IAAad,OAAOe,KAAKC,cAAAA,OAAAA,cAAzB,0BAAwC,CAAxC,IAAMlB,EAAN,QACH,GAAIA,EAAImB,WAAW,yBAA0B,CAC3C,IAAMC,EAAWpB,EAAIqB,QAAQ,wBAAyB,IAChDC,EAAOC,KAAKC,MAChBN,aAAaO,QAAQ,6BAAsC,OAATL,KAAe,MAEnEJ,EAAMI,GAAY,GACh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esm-state\"","webpack://@openmrs/esm-feature-flags/webpack/bootstrap","webpack://@openmrs/esm-feature-flags/webpack/runtime/define property getters","webpack://@openmrs/esm-feature-flags/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-feature-flags/webpack/runtime/make namespace object","webpack://@openmrs/esm-feature-flags/./src/feature-flags.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/** @module @category Feature Flags */\nimport { getGlobalStore } from \"@openmrs/esm-state\";\n\nexport interface FeatureFlagsStore {\n flags: { [flagName: string]: FeatureFlag };\n}\n\nexport interface FeatureFlag {\n enabled: boolean;\n label: string;\n description: string;\n}\n\nconst initialFeatureFlags = { flags: getFeatureFlagsFromLocalStorage() };\n\n/** @internal */\nexport const featureFlagsStore = getGlobalStore<FeatureFlagsStore>(\n \"feature-flags\",\n initialFeatureFlags\n);\n\nfeatureFlagsStore.subscribe((state) => {\n for (const [flagName, flag] of Object.entries(state.flags)) {\n localStorage.setItem(\n `openmrs:feature-flag:${flagName}`,\n flag.enabled.toString()\n );\n localStorage.setItem(\n `openmrs:feature-flag-meta:${flagName}`,\n JSON.stringify({ label: flag.label, description: flag.description })\n );\n }\n});\n\nfunction getFeatureFlagsFromLocalStorage() {\n const flags = {};\n for (const key of Object.keys(localStorage)) {\n if (key.startsWith(\"openmrs:feature-flag:\")) {\n const flagName = key.replace(\"openmrs:feature-flag:\", \"\");\n const meta = JSON.parse(\n localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || \"{}\"\n );\n flags[flagName] = {\n enabled: localStorage.getItem(key) === \"true\",\n ...meta,\n };\n }\n }\n return flags;\n}\n\n/**\n * This function creates a feature flag. Call it in top-level code anywhere. It will\n * not reset whether the flag is enabled or not, so it's safe to call it multiple times.\n * Once a feature flag is created, it will appear with a toggle in the Implementer Tools.\n * It can then be used to turn on or off features in the code.\n *\n * @param flagName A code-friendly name for the flag, which will be used to reference it in code\n * @param label A human-friendly name which will be displayed in the Implementer Tools\n * @param description An explanation of what the flag does, which will be displayed in the Implementer Tools\n */\nexport function registerFeatureFlag(\n flagName: string,\n label: string,\n description: string\n) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: {\n enabled: state.flags[flagName]?.enabled ?? false,\n label,\n description,\n },\n },\n }));\n}\n\n/** Use this function to access the current value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function getFeatureFlag(flagName: string) {\n return featureFlagsStore.getState().flags[flagName].enabled;\n}\n\n/** Use this function to subscribe to the value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function subscribeToFeatureFlag(\n flagName: string,\n callback: (value: boolean) => void\n) {\n featureFlagsStore.subscribe((state) => {\n callback(state.flags[flagName].enabled);\n });\n}\n\n/** @internal for Implementer Tools */\nexport function setFeatureFlag(flagName: string, value: boolean) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: { ...state.flags[flagName], enabled: value },\n },\n }));\n}\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__685__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","initialFeatureFlags","flags","keys","localStorage","startsWith","flagName","replace","meta","JSON","parse","getItem","enabled","getFeatureFlagsFromLocalStorage","featureFlagsStore","getGlobalStore","registerFeatureFlag","label","description","state","setState","getFeatureFlag","getState","subscribeToFeatureFlag","callback","subscribe","setFeatureFlag","entries","flag","setItem","toString","stringify"],"sourceRoot":""}
1
+ {"version":3,"file":"openmrs-esm-feature-flags.js","mappings":"sLAAAA,EAAOC,QAAUC,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaL,QAGrB,IAAID,EAASG,EAAyBE,GAAY,CAGjDJ,QAAS,CAAC,GAOX,OAHAO,EAAoBH,GAAUL,EAAQA,EAAOC,QAASG,GAG/CJ,EAAOC,OACf,CCrBAG,EAAoBK,EAAI,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEX,EAASU,IAC5EE,OAAOC,eAAeb,EAASU,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAKrB,IACH,oBAAXsB,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAeb,EAASsB,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAA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AK,IAA0B/B,OAAOuC,QAAQR,EAAMjB,OAAK,qBAApD,0BAAuD,CAAvD,O,EAAA,Q,EAAA,E,+zBAAOI,EAAAA,EAAAA,GAAUsB,EAAAA,EAAAA,GACpBxB,aAAayB,QAAQ,wBAAiC,OAATvB,GAAYsB,EAAKhB,QAAQkB,YACtE1B,aAAayB,QACX,6BAAsC,OAATvB,GAC7BG,KAAKsB,UAAU,CAAEd,MAAOW,EAAKX,MAAOC,YAAaU,EAAKV,cAE1D,C,UANK,Q,aAAA,6B,YAAA,E,MAAA,C,EAOP,G","sources":["webpack://@openmrs/esm-feature-flags/external system \"@openmrs/esm-state\"","webpack://@openmrs/esm-feature-flags/webpack/bootstrap","webpack://@openmrs/esm-feature-flags/webpack/runtime/define property getters","webpack://@openmrs/esm-feature-flags/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-feature-flags/webpack/runtime/make namespace object","webpack://@openmrs/esm-feature-flags/./src/feature-flags.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/** @module @category Feature Flags */\nimport { getGlobalStore } from '@openmrs/esm-state';\n\nexport interface FeatureFlagsStore {\n flags: { [flagName: string]: FeatureFlag };\n}\n\nexport interface FeatureFlag {\n enabled: boolean;\n label: string;\n description: string;\n}\n\nconst initialFeatureFlags = { flags: getFeatureFlagsFromLocalStorage() };\n\n/** @internal */\nexport const featureFlagsStore = getGlobalStore<FeatureFlagsStore>('feature-flags', initialFeatureFlags);\n\nfeatureFlagsStore.subscribe((state) => {\n for (const [flagName, flag] of Object.entries(state.flags)) {\n localStorage.setItem(`openmrs:feature-flag:${flagName}`, flag.enabled.toString());\n localStorage.setItem(\n `openmrs:feature-flag-meta:${flagName}`,\n JSON.stringify({ label: flag.label, description: flag.description }),\n );\n }\n});\n\nfunction getFeatureFlagsFromLocalStorage() {\n const flags = {};\n for (const key of Object.keys(localStorage)) {\n if (key.startsWith('openmrs:feature-flag:')) {\n const flagName = key.replace('openmrs:feature-flag:', '');\n const meta = JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || '{}');\n flags[flagName] = {\n enabled: localStorage.getItem(key) === 'true',\n ...meta,\n };\n }\n }\n return flags;\n}\n\n/**\n * This function creates a feature flag. Call it in top-level code anywhere. It will\n * not reset whether the flag is enabled or not, so it's safe to call it multiple times.\n * Once a feature flag is created, it will appear with a toggle in the Implementer Tools.\n * It can then be used to turn on or off features in the code.\n *\n * @param flagName A code-friendly name for the flag, which will be used to reference it in code\n * @param label A human-friendly name which will be displayed in the Implementer Tools\n * @param description An explanation of what the flag does, which will be displayed in the Implementer Tools\n */\nexport function registerFeatureFlag(flagName: string, label: string, description: string) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: {\n enabled: state.flags[flagName]?.enabled ?? false,\n label,\n description,\n },\n },\n }));\n}\n\n/** Use this function to access the current value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function getFeatureFlag(flagName: string) {\n return featureFlagsStore.getState().flags[flagName].enabled;\n}\n\n/** Use this function to subscribe to the value of the feature flag\n *\n * If you are using React, use `useFeatureFlag` instead.\n */\nexport function subscribeToFeatureFlag(flagName: string, callback: (value: boolean) => void) {\n featureFlagsStore.subscribe((state) => {\n callback(state.flags[flagName].enabled);\n });\n}\n\n/** @internal for Implementer Tools */\nexport function setFeatureFlag(flagName: string, value: boolean) {\n featureFlagsStore.setState((state) => ({\n flags: {\n ...state.flags,\n [flagName]: { ...state.flags[flagName], enabled: value },\n },\n }));\n}\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__685__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","initialFeatureFlags","flags","keys","localStorage","startsWith","flagName","replace","meta","JSON","parse","getItem","enabled","getFeatureFlagsFromLocalStorage","featureFlagsStore","getGlobalStore","registerFeatureFlag","label","description","state","setState","getFeatureFlag","getState","subscribeToFeatureFlag","callback","subscribe","setFeatureFlag","entries","flag","setItem","toString","stringify"],"sourceRoot":""}
package/jest.config.js CHANGED
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
2
  transform: {
3
- "^.+\\.tsx?$": ["@swc/jest"],
3
+ '^.+\\.tsx?$': ['@swc/jest'],
4
4
  },
5
- testEnvironment: "jsdom",
5
+ testEnvironment: 'jsdom',
6
6
  testEnvironmentOptions: {
7
- url: "http://localhost/",
7
+ url: 'http://localhost/',
8
8
  },
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-feature-flags",
3
- "version": "5.3.3-pre.1240",
3
+ "version": "5.3.3-pre.1247",
4
4
  "license": "MPL-2.0",
5
5
  "description": "A feature flag system for the OpenMRS Single-Spa framework.",
6
6
  "browser": "dist/openmrs-esm-feature-flags.js",
@@ -46,8 +46,8 @@
46
46
  "single-spa": "5.x"
47
47
  },
48
48
  "devDependencies": {
49
- "@openmrs/esm-globals": "5.3.3-pre.1240",
50
- "@openmrs/esm-state": "5.3.3-pre.1240",
49
+ "@openmrs/esm-globals": "5.3.3-pre.1247",
50
+ "@openmrs/esm-state": "5.3.3-pre.1247",
51
51
  "single-spa": "^5.9.2"
52
52
  },
53
53
  "stableVersion": "5.3.2"
@@ -1,5 +1,5 @@
1
1
  /** @module @category Feature Flags */
2
- import { getGlobalStore } from "@openmrs/esm-state";
2
+ import { getGlobalStore } from '@openmrs/esm-state';
3
3
 
4
4
  export interface FeatureFlagsStore {
5
5
  flags: { [flagName: string]: FeatureFlag };
@@ -14,20 +14,14 @@ export interface FeatureFlag {
14
14
  const initialFeatureFlags = { flags: getFeatureFlagsFromLocalStorage() };
15
15
 
16
16
  /** @internal */
17
- export const featureFlagsStore = getGlobalStore<FeatureFlagsStore>(
18
- "feature-flags",
19
- initialFeatureFlags
20
- );
17
+ export const featureFlagsStore = getGlobalStore<FeatureFlagsStore>('feature-flags', initialFeatureFlags);
21
18
 
22
19
  featureFlagsStore.subscribe((state) => {
23
20
  for (const [flagName, flag] of Object.entries(state.flags)) {
24
- localStorage.setItem(
25
- `openmrs:feature-flag:${flagName}`,
26
- flag.enabled.toString()
27
- );
21
+ localStorage.setItem(`openmrs:feature-flag:${flagName}`, flag.enabled.toString());
28
22
  localStorage.setItem(
29
23
  `openmrs:feature-flag-meta:${flagName}`,
30
- JSON.stringify({ label: flag.label, description: flag.description })
24
+ JSON.stringify({ label: flag.label, description: flag.description }),
31
25
  );
32
26
  }
33
27
  });
@@ -35,13 +29,11 @@ featureFlagsStore.subscribe((state) => {
35
29
  function getFeatureFlagsFromLocalStorage() {
36
30
  const flags = {};
37
31
  for (const key of Object.keys(localStorage)) {
38
- if (key.startsWith("openmrs:feature-flag:")) {
39
- const flagName = key.replace("openmrs:feature-flag:", "");
40
- const meta = JSON.parse(
41
- localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || "{}"
42
- );
32
+ if (key.startsWith('openmrs:feature-flag:')) {
33
+ const flagName = key.replace('openmrs:feature-flag:', '');
34
+ const meta = JSON.parse(localStorage.getItem(`openmrs:feature-flag-meta:${flagName}`) || '{}');
43
35
  flags[flagName] = {
44
- enabled: localStorage.getItem(key) === "true",
36
+ enabled: localStorage.getItem(key) === 'true',
45
37
  ...meta,
46
38
  };
47
39
  }
@@ -59,11 +51,7 @@ function getFeatureFlagsFromLocalStorage() {
59
51
  * @param label A human-friendly name which will be displayed in the Implementer Tools
60
52
  * @param description An explanation of what the flag does, which will be displayed in the Implementer Tools
61
53
  */
62
- export function registerFeatureFlag(
63
- flagName: string,
64
- label: string,
65
- description: string
66
- ) {
54
+ export function registerFeatureFlag(flagName: string, label: string, description: string) {
67
55
  featureFlagsStore.setState((state) => ({
68
56
  flags: {
69
57
  ...state.flags,
@@ -88,10 +76,7 @@ export function getFeatureFlag(flagName: string) {
88
76
  *
89
77
  * If you are using React, use `useFeatureFlag` instead.
90
78
  */
91
- export function subscribeToFeatureFlag(
92
- flagName: string,
93
- callback: (value: boolean) => void
94
- ) {
79
+ export function subscribeToFeatureFlag(flagName: string, callback: (value: boolean) => void) {
95
80
  featureFlagsStore.subscribe((state) => {
96
81
  callback(state.flags[flagName].enabled);
97
82
  });
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export * from "./feature-flags";
1
+ export * from './feature-flags';
package/src/public.ts CHANGED
@@ -1 +1 @@
1
- export { registerFeatureFlag, getFeatureFlag } from "./feature-flags";
1
+ export { registerFeatureFlag, getFeatureFlag } from './feature-flags';
package/webpack.config.js CHANGED
@@ -1,42 +1,42 @@
1
- const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
2
- const { resolve } = require("path");
3
- const { CleanWebpackPlugin } = require("clean-webpack-plugin");
4
- const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
1
+ const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2
+ const { resolve } = require('path');
3
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
5
5
 
6
- const { peerDependencies } = require("./package.json");
6
+ const { peerDependencies } = require('./package.json');
7
7
 
8
8
  module.exports = (env) => ({
9
- entry: [resolve(__dirname, "src/index.ts")],
10
- devtool: "source-map",
9
+ entry: [resolve(__dirname, 'src/index.ts')],
10
+ devtool: 'source-map',
11
11
  output: {
12
- filename: "openmrs-esm-feature-flags.js",
13
- path: resolve(__dirname, "dist"),
14
- library: { type: "system" },
12
+ filename: 'openmrs-esm-feature-flags.js',
13
+ path: resolve(__dirname, 'dist'),
14
+ library: { type: 'system' },
15
15
  },
16
16
  module: {
17
17
  rules: [
18
18
  {
19
19
  test: /\.m?(js|ts|tsx)$/,
20
20
  exclude: /node_modules/,
21
- use: "swc-loader",
21
+ use: 'swc-loader',
22
22
  },
23
23
  ],
24
24
  },
25
25
  resolve: {
26
- extensions: [".ts", ".js", ".tsx", ".jsx"],
26
+ extensions: ['.ts', '.js', '.tsx', '.jsx'],
27
27
  },
28
28
  externals: Object.keys(peerDependencies || {}),
29
29
  plugins: [
30
30
  new CleanWebpackPlugin(),
31
31
  new ForkTsCheckerWebpackPlugin(),
32
32
  new BundleAnalyzerPlugin({
33
- analyzerMode: env && env.analyze ? "static" : "disabled",
33
+ analyzerMode: env && env.analyze ? 'static' : 'disabled',
34
34
  }),
35
35
  ],
36
36
  devServer: {
37
37
  disableHostCheck: true,
38
38
  headers: {
39
- "Access-Control-Allow-Origin": "*",
39
+ 'Access-Control-Allow-Origin': '*',
40
40
  },
41
41
  },
42
42
  });