@eventvisor/module-localstorage 0.0.2
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.
- package/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -0
- package/jest.config.js +5 -0
- package/lib/index.d.ts +6 -0
- package/package.json +45 -0
- package/src/index.ts +59 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +8 -0
- package/webpack.config.js +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fahad Heylaal (https://fahad19.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @eventvisor/module-localstorage
|
|
2
|
+
|
|
3
|
+
> LocalStorage module for Eventvisor, for both persistence layer and lookups.
|
|
4
|
+
|
|
5
|
+
Visit [https://eventvisor.org/docs/modules/localstorage/](https://eventvisor.org/docs/modules/localstorage/) for more information.
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
MIT © [Fahad Heylaal](https://fahad19.com)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.EventvisorLocalStorageModule=e():t.EventvisorLocalStorageModule=e()}(this,()=>(()=>{"use strict";var t={};return{166:function(t,e){var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(o,a){function i(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,u)}c((r=r.apply(t,e||[])).next())})},r=this&&this.__generator||function(t,e){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.createLocalStorageModule=function(t){var e=this;void 0===t&&(t={});var o=t.prefix,a=void 0===o?"_eventvisor_":o,i=t.name;return{name:void 0===i?"localstorage":i,lookup:function(t){return n(e,[t],void 0,function(t){var e=t.key;return r(this,function(t){return[2,window.localStorage.getItem(e)]})})},readFromStorage:function(t){return n(e,[t],void 0,function(t){var e,n,o,i=t.key;return r(this,function(t){if(e="".concat(a).concat(i),!(n=window.localStorage.getItem(e)))return[2,null];try{if((o=JSON.parse(n))&&void 0!==o.data)return[2,o.data]}catch(t){return[2,null]}return[2,null]})})},writeToStorage:function(t){return n(e,[t],void 0,function(t){var e,n,o=t.key,i=t.value;return r(this,function(t){return e="".concat(a).concat(o),n=JSON.stringify({data:i}),window.localStorage.setItem(e,n),[2]})})},removeFromStorage:function(t){return n(e,[t],void 0,function(t){var e,n=t.key;return r(this,function(t){return e="".concat(a).concat(n),window.localStorage.removeItem(e),[2]})})}}}}}[166](0,t),t})());
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAsC,6BAAID,IAE1CD,EAAmC,6BAAIC,GACxC,CATD,CASGK,KAAM,I,uBCNLC,EAAsB,CAAC,E,miDCI3B,oCAAyCC,GAAzC,gBAAyC,IAAAA,IAAAA,EAAA,IAC/B,MAAmDA,EAAO,OAA1DC,OAAM,IAAG,iBAAc,EAAE,EAA0BD,EAAO,KAElE,MAAO,CACLE,UAHmC,IAAG,iBAAc,EAOpDC,OAAQ,2CAAO,G,IAAEC,EAAG,M,0BAClB,MAAO,CAAP,EAAOC,OAAOC,aAAaC,QAAQH,G,MAGrCI,gBAAiB,2CAAO,G,UAAEJ,EAAG,M,0BAK3B,GAJMK,EAAU,UAAGR,GAAM,OAAGG,KAEtBM,EAAQL,OAAOC,aAAaC,QAAQE,IAGxC,MAAO,CAAP,EAAO,MAGT,IAGE,IAFME,EAAcC,KAAKC,MAAMH,UAEgB,IAArBC,EAAYG,KACpC,MAAO,CAAP,EAAOH,EAAYG,KAGvB,CAAE,MAAOC,GACP,MAAO,CAAP,EAAO,KACT,CAEA,MAAO,CAAP,EAAO,K,MAGTC,eAAgB,2CAAO,G,QAAEZ,EAAG,MAAEM,EAAK,Q,iCAC3BD,EAAU,UAAGR,GAAM,OAAGG,GAEtBa,EAAmBL,KAAKM,UAAU,CACtCJ,KAAMJ,IAGRL,OAAOC,aAAaa,QAAQV,EAASQ,G,SAGvCG,kBAAmB,2CAAO,G,MAAEhB,EAAG,M,iCACvBK,EAAU,UAAGR,GAAM,OAAGG,GAE5BC,OAAOC,aAAae,WAAWZ,G,SAGrC,C,GDtDoB,KAAK,EAAGV,G","sources":["webpack://EventvisorLocalStorageModule/webpack/universalModuleDefinition","webpack://EventvisorLocalStorageModule/webpack/startup","webpack://EventvisorLocalStorageModule/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"EventvisorLocalStorageModule\"] = factory();\n\telse\n\t\troot[\"EventvisorLocalStorageModule\"] = factory();\n})(this, () => {\nreturn ","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = {};\n__webpack_modules__[166](0, __webpack_exports__);\n","import { Module } from \"@eventvisor/sdk\";\n\nexport type LocalStorageModuleOptions = {\n name?: string;\n prefix?: string;\n};\n\nexport function createLocalStorageModule(options: LocalStorageModuleOptions = {}): Module {\n const { prefix = \"_eventvisor_\", name = \"localstorage\" } = options;\n\n return {\n name,\n\n // this is different than storage use cases,\n // and prefix is not meant to be used here\n lookup: async ({ key }) => {\n return window.localStorage.getItem(key);\n },\n\n readFromStorage: async ({ key }) => {\n const fullKey = `${prefix}${key}`;\n\n const value = window.localStorage.getItem(fullKey);\n\n if (!value) {\n return null;\n }\n\n try {\n const parsedValue = JSON.parse(value);\n\n if (parsedValue && typeof parsedValue.data !== \"undefined\") {\n return parsedValue.data;\n }\n // eslint-disable-next-line\n } catch (e) {\n return null;\n }\n\n return null;\n },\n\n writeToStorage: async ({ key, value }) => {\n const fullKey = `${prefix}${key}`;\n\n const stringifiedValue = JSON.stringify({\n data: value,\n });\n\n window.localStorage.setItem(fullKey, stringifiedValue);\n },\n\n removeFromStorage: async ({ key }) => {\n const fullKey = `${prefix}${key}`;\n\n window.localStorage.removeItem(fullKey);\n },\n };\n}\n"],"names":["root","factory","exports","module","define","amd","this","__webpack_exports__","options","prefix","name","lookup","key","window","localStorage","getItem","readFromStorage","fullKey","value","parsedValue","JSON","parse","data","e","writeToStorage","stringifiedValue","stringify","setItem","removeFromStorage","removeItem"],"sourceRoot":""}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t={d:(e,o)=>{for(var n in o)t.o(o,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:o[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{F:()=>n});var o=function(t,e,o,n){return new(o||(o=Promise))(function(r,a){function i(t){try{u(n.next(t))}catch(t){a(t)}}function c(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(i,c)}u((n=n.apply(t,e||[])).next())})};function n(t={}){const{prefix:e="_eventvisor_",name:n="localstorage"}=t;return{name:n,lookup:t=>o(this,[t],void 0,function*({key:t}){return window.localStorage.getItem(t)}),readFromStorage:t=>o(this,[t],void 0,function*({key:t}){const o=`${e}${t}`,n=window.localStorage.getItem(o);if(!n)return null;try{const t=JSON.parse(n);if(t&&void 0!==t.data)return t.data}catch(t){return null}return null}),writeToStorage:t=>o(this,[t],void 0,function*({key:t,value:o}){const n=`${e}${t}`,r=JSON.stringify({data:o});window.localStorage.setItem(n,r)}),removeFromStorage:t=>o(this,[t],void 0,function*({key:t}){const o=`${e}${t}`;window.localStorage.removeItem(o)})}}const r=e.F;export{r as createLocalStorageModule};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,4TCO3E,SAASI,EAAyBC,EAAqC,CAAC,GAC7E,MAAM,OAAEC,EAAS,eAAc,KAAEC,EAAO,gBAAmBF,EAE3D,MAAO,CACLE,OAIAC,OAAQ,GAAmB,EAAD,2BAAX,IAAEf,IACf,OAAOgB,OAAOC,aAAaC,QAAQlB,EACrC,GAEAmB,gBAAiB,GAAmB,EAAD,2BAAX,IAAEnB,IACxB,MAAMoB,EAAU,GAAGP,IAASb,IAEtBqB,EAAQL,OAAOC,aAAaC,QAAQE,GAE1C,IAAKC,EACH,OAAO,KAGT,IACE,MAAMC,EAAcC,KAAKC,MAAMH,GAE/B,GAAIC,QAA2C,IAArBA,EAAYG,KACpC,OAAOH,EAAYG,IAGvB,CAAE,MAAOC,GACP,OAAO,IACT,CAEA,OAAO,IACT,GAEAC,eAAgB,GAA0B,EAAD,2BAAlB,IAAE3B,EAAG,MAAEqB,IAC5B,MAAMD,EAAU,GAAGP,IAASb,IAEtB4B,EAAmBL,KAAKM,UAAU,CACtCJ,KAAMJ,IAGRL,OAAOC,aAAaa,QAAQV,EAASQ,EACvC,GAEAG,kBAAmB,GAAmB,EAAD,2BAAX,IAAE/B,IAC1B,MAAMoB,EAAU,GAAGP,IAASb,IAE5BgB,OAAOC,aAAae,WAAWZ,EACjC,GAEJ,C","sources":["webpack://@eventvisor/module-localstorage/webpack/bootstrap","webpack://@eventvisor/module-localstorage/webpack/runtime/define property getters","webpack://@eventvisor/module-localstorage/webpack/runtime/hasOwnProperty shorthand","webpack://@eventvisor/module-localstorage/./src/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\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))","import { Module } from \"@eventvisor/sdk\";\n\nexport type LocalStorageModuleOptions = {\n name?: string;\n prefix?: string;\n};\n\nexport function createLocalStorageModule(options: LocalStorageModuleOptions = {}): Module {\n const { prefix = \"_eventvisor_\", name = \"localstorage\" } = options;\n\n return {\n name,\n\n // this is different than storage use cases,\n // and prefix is not meant to be used here\n lookup: async ({ key }) => {\n return window.localStorage.getItem(key);\n },\n\n readFromStorage: async ({ key }) => {\n const fullKey = `${prefix}${key}`;\n\n const value = window.localStorage.getItem(fullKey);\n\n if (!value) {\n return null;\n }\n\n try {\n const parsedValue = JSON.parse(value);\n\n if (parsedValue && typeof parsedValue.data !== \"undefined\") {\n return parsedValue.data;\n }\n // eslint-disable-next-line\n } catch (e) {\n return null;\n }\n\n return null;\n },\n\n writeToStorage: async ({ key, value }) => {\n const fullKey = `${prefix}${key}`;\n\n const stringifiedValue = JSON.stringify({\n data: value,\n });\n\n window.localStorage.setItem(fullKey, stringifiedValue);\n },\n\n removeFromStorage: async ({ key }) => {\n const fullKey = `${prefix}${key}`;\n\n window.localStorage.removeItem(fullKey);\n },\n };\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","createLocalStorageModule","options","prefix","name","lookup","window","localStorage","getItem","readFromStorage","fullKey","value","parsedValue","JSON","parse","data","e","writeToStorage","stringifiedValue","stringify","setItem","removeFromStorage","removeItem"],"sourceRoot":""}
|
package/jest.config.js
ADDED
package/lib/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eventvisor/module-localstorage",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Eventvisor LocalStorage module",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"transpile": "echo 'Nothing to transpile'",
|
|
18
|
+
"dist": "webpack --config ./webpack.config.js && tsc --project tsconfig.esm.json --declaration --emitDeclarationOnly --declarationDir dist",
|
|
19
|
+
"build": "npm run transpile && npm run dist",
|
|
20
|
+
"testJest": "jest --config jest.config.js --verbose --coverage",
|
|
21
|
+
"test": "echo 'Nothing to test'"
|
|
22
|
+
},
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Fahad Heylaal",
|
|
25
|
+
"url": "https://fahad19.com"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://eventvisor.org",
|
|
28
|
+
"keywords": [],
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/eventvisor/eventvisor.git"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/eventvisor/eventvisor/issues"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eventvisor/sdk": "0.0.2"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"gitHead": "373d5c00cb6fa0d6f4baaa05a10e57e505474847"
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Module } from "@eventvisor/sdk";
|
|
2
|
+
|
|
3
|
+
export type LocalStorageModuleOptions = {
|
|
4
|
+
name?: string;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export function createLocalStorageModule(options: LocalStorageModuleOptions = {}): Module {
|
|
9
|
+
const { prefix = "_eventvisor_", name = "localstorage" } = options;
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
|
|
14
|
+
// this is different than storage use cases,
|
|
15
|
+
// and prefix is not meant to be used here
|
|
16
|
+
lookup: async ({ key }) => {
|
|
17
|
+
return window.localStorage.getItem(key);
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
readFromStorage: async ({ key }) => {
|
|
21
|
+
const fullKey = `${prefix}${key}`;
|
|
22
|
+
|
|
23
|
+
const value = window.localStorage.getItem(fullKey);
|
|
24
|
+
|
|
25
|
+
if (!value) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const parsedValue = JSON.parse(value);
|
|
31
|
+
|
|
32
|
+
if (parsedValue && typeof parsedValue.data !== "undefined") {
|
|
33
|
+
return parsedValue.data;
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line
|
|
36
|
+
} catch (e) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
writeToStorage: async ({ key, value }) => {
|
|
44
|
+
const fullKey = `${prefix}${key}`;
|
|
45
|
+
|
|
46
|
+
const stringifiedValue = JSON.stringify({
|
|
47
|
+
data: value,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
window.localStorage.setItem(fullKey, stringifiedValue);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
removeFromStorage: async ({ key }) => {
|
|
54
|
+
const fullKey = `${prefix}${key}`;
|
|
55
|
+
|
|
56
|
+
window.localStorage.removeItem(fullKey);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
// cjs
|
|
5
|
+
{
|
|
6
|
+
entry: {
|
|
7
|
+
"index.cjs": path.join(__dirname, "src", "index.ts"),
|
|
8
|
+
},
|
|
9
|
+
output: {
|
|
10
|
+
path: path.join(__dirname, "dist"),
|
|
11
|
+
filename: "index.js",
|
|
12
|
+
library: "EventvisorLocalStorageModule",
|
|
13
|
+
libraryTarget: "umd",
|
|
14
|
+
globalObject: "this",
|
|
15
|
+
},
|
|
16
|
+
mode: "production",
|
|
17
|
+
devtool: "source-map",
|
|
18
|
+
resolve: {
|
|
19
|
+
extensions: [".ts", ".tsx", ".js"],
|
|
20
|
+
},
|
|
21
|
+
module: {
|
|
22
|
+
rules: [
|
|
23
|
+
{
|
|
24
|
+
test: /\.(ts|tsx)$/,
|
|
25
|
+
exclude: /(node_modules)/,
|
|
26
|
+
use: [
|
|
27
|
+
{
|
|
28
|
+
loader: "ts-loader",
|
|
29
|
+
options: {
|
|
30
|
+
configFile: path.join(__dirname, "tsconfig.cjs.json"),
|
|
31
|
+
transpileOnly: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
performance: {
|
|
39
|
+
hints: false,
|
|
40
|
+
},
|
|
41
|
+
optimization: {
|
|
42
|
+
minimize: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// esm
|
|
47
|
+
{
|
|
48
|
+
entry: path.join(__dirname, "src", "index.ts"),
|
|
49
|
+
output: {
|
|
50
|
+
path: path.join(__dirname, "dist"),
|
|
51
|
+
filename: "index.mjs",
|
|
52
|
+
library: {
|
|
53
|
+
type: "module",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
experiments: {
|
|
57
|
+
outputModule: true,
|
|
58
|
+
},
|
|
59
|
+
mode: "production",
|
|
60
|
+
devtool: "source-map",
|
|
61
|
+
resolve: {
|
|
62
|
+
extensions: [".ts", ".tsx", ".js"],
|
|
63
|
+
},
|
|
64
|
+
module: {
|
|
65
|
+
rules: [
|
|
66
|
+
{
|
|
67
|
+
test: /\.(ts|tsx)$/,
|
|
68
|
+
exclude: /(node_modules)/,
|
|
69
|
+
loader: "ts-loader",
|
|
70
|
+
options: {
|
|
71
|
+
configFile: path.join(__dirname, "tsconfig.esm.json"),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
performance: {
|
|
77
|
+
hints: false,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
];
|