@amedia/user 0.13.12 → 0.13.15

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.
@@ -0,0 +1 @@
1
+ export {};
package/eik.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
- "name": "user-js",
3
- "version": "0.13.4",
2
+ "name": "user",
3
+ "version": "0.13.15",
4
4
  "server": "https://assets.acdn.no",
5
5
  "files": {
6
- "user.js": "./esm/user.js",
7
- "user.js.map": "./esm/user.js.map"
6
+ "user.js": "./dist/index.esm.js",
7
+ "user.js.map": "./dist/index.esm.js.map",
8
+ "user.d.ts": "./dist/index.d.ts"
8
9
  }
9
10
  }
package/package.json CHANGED
@@ -1,59 +1,50 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.13.12",
3
+ "version": "0.13.15",
4
4
  "description": "Client lib for working with aID user and associated data",
5
5
  "repository": "https://github.com/amedia/amedia-user-js",
6
6
  "author": "Amedia Utvikling (ID og data)",
7
7
  "main": "dist/index.js",
8
+ "module": "dist/index.esm.js",
9
+ "typings": "dist/index.d.ts",
8
10
  "scripts": {
9
11
  "test": "jest --coverage",
10
12
  "lint": "eslint ./src --ext .ts",
11
- "build": "npm install && webpack --mode=production",
12
- "build:rollup": "rollup -c",
13
- "prepublishOnly": "npm run lint && npm run test && npm run build"
13
+ "build": "npm install && node build.js",
14
+ "typings": "tsc",
15
+ "eik:publish": "run-p typings lint && npm run test && npm run build && eik package",
16
+ "prepublishOnly": "run-p typings lint && npm run test && npm run build"
14
17
  },
15
18
  "dependencies": {
16
- "@amedia/browserid": "0.1.6",
17
- "@amedia/frontend-rpc": "0.0.12",
18
- "regenerator-runtime": "0.13.7",
19
- "runtypes": "6.2.1",
19
+ "@amedia/browserid": "^0.1.6",
20
+ "@amedia/frontend-rpc": "^0.0.12",
21
+ "runtypes": "^6.3.2",
20
22
  "ts-deepmerge": "^1.0.8"
21
23
  },
22
24
  "devDependencies": {
23
- "@amedia/eslint-config-base": "4.0.7",
24
- "@amedia/eslint-config-typescript": "4.0.10",
25
- "@babel/core": "7.14.0",
26
- "@babel/preset-env": "7.14.1",
27
- "@babel/preset-typescript": "7.13.0",
28
- "@eik/cli": "^1.8.32",
29
- "@rollup/plugin-commonjs": "19.0.0",
30
- "@rollup/plugin-node-resolve": "13.0.0",
31
- "@rollup/plugin-typescript": "8.2.1",
32
- "@types/convict": "6.0.1",
33
- "@types/dexie": "1.3.1",
34
- "@types/jest": "^26.0.23",
35
- "@types/lodash": "4.14.168",
36
- "@typescript-eslint/eslint-plugin": "4.22.0",
37
- "eslint": "7.24.0",
38
- "eslint-config-airbnb-typescript": "12.3.1",
39
- "eslint-config-prettier": "8.2.0",
40
- "eslint-plugin-import": "2.22.1",
25
+ "@amedia/eslint-config-base": "^4.0.7",
26
+ "@amedia/eslint-config-typescript": "^4.0.10",
27
+ "@eik/cli": "^1.8.41",
28
+ "@types/convict": "^6.1.1",
29
+ "@types/dexie": "^1.3.1",
30
+ "@types/jest": "^26.0.24",
31
+ "@types/lodash": "^4.14.172",
32
+ "@typescript-eslint/eslint-plugin": "^4.29.1",
33
+ "esbuild": "^0.12.19",
34
+ "eslint": "^7.32.0",
35
+ "eslint-config-airbnb-typescript": "^12.3.1",
36
+ "eslint-config-prettier": "^8.3.0",
37
+ "eslint-plugin-import": "^2.24.0",
41
38
  "eslint-plugin-prettier": "^3.4.0",
42
39
  "jest": "^26.6.3",
43
40
  "jest-extended": "^0.11.5",
44
41
  "jest-fetch-mock": "^3.0.3",
45
- "mockdate": "3.0.5",
46
- "npm-run-all": "4.1.5",
47
- "prettier": "2.2.1",
48
- "rollup": "2.51.0",
49
- "rollup-plugin-peer-deps-external": "2.2.4",
50
- "rollup-plugin-typescript2": "0.30.0",
51
- "rollup-plugin-uglify": "^6.0.4",
52
- "ts-jest": "^26.5.5",
53
- "ts-loader": "9.1.0",
54
- "tslib": "2.2.0",
55
- "typescript": "4.2.4",
56
- "webpack": "5.36.2",
57
- "webpack-cli": "4.6.0"
42
+ "mockdate": "^3.0.5",
43
+ "npm-dts": "^1.3.10",
44
+ "npm-run-all": "^4.1.5",
45
+ "prettier": "^2.3.2",
46
+ "ts-jest": "^26.5.6",
47
+ "tslib": "^2.3.0",
48
+ "typescript": "^4.3.5"
58
49
  }
59
50
  }
@@ -9,15 +9,13 @@ import { getInfo } from '../clients/nebula';
9
9
  import { whenIsLoggedIn, whenLoginStateResolved } from '../utils/loginState';
10
10
 
11
11
  const getExtraData = () =>
12
- Promise.all([
13
- getBrowserId(),
14
- whenLoginStateResolved(),
15
- ]).then(([browserId, isLoggedIn]) =>
16
- getInfo(
17
- window.location.hostname,
18
- browserId,
19
- isLoggedIn ? store.get('userAttributes')?.trackingKey : undefined
20
- )
12
+ Promise.all([getBrowserId(), whenLoginStateResolved()]).then(
13
+ ([browserId, isLoggedIn]) =>
14
+ getInfo(
15
+ window.location.hostname,
16
+ browserId,
17
+ isLoggedIn ? store.get('userAttributes')?.trackingKey : undefined
18
+ )
21
19
  );
22
20
 
23
21
  const dataServiceMap: {
@@ -154,9 +154,7 @@ describe('jupiter service', () => {
154
154
  response
155
155
  );
156
156
 
157
- expect(
158
- fetch
159
- ).toHaveBeenCalledWith(
157
+ expect(fetch).toHaveBeenCalledWith(
160
158
  `/api/jupiter/v1/non_user_access/${publicationDomain}`,
161
159
  { method: 'post' }
162
160
  );
@@ -3,10 +3,7 @@
3
3
  */
4
4
 
5
5
  import fetch from 'jest-fetch-mock';
6
- import backendLog, {
7
- activateSubscription,
8
- UserDeactivatedError,
9
- } from './mercury';
6
+ import { activateSubscription, UserDeactivatedError } from './mercury';
10
7
  import restoreAllMocks = jest.restoreAllMocks;
11
8
 
12
9
  beforeEach(() => {
@@ -14,24 +11,6 @@ beforeEach(() => {
14
11
  fetch.resetMocks();
15
12
  });
16
13
 
17
- describe('Mercury backendlog', () => {
18
- it('should include level in url', () => {
19
- backendLog.error('jest message', {});
20
- expect(fetch).toHaveBeenCalledWith(
21
- expect.stringContaining('/error'),
22
- expect.anything()
23
- );
24
- expect(fetch).toHaveBeenCalledTimes(1);
25
- });
26
-
27
- it('should include additional context as query parameters', () => {
28
- backendLog.error('jest message', { referrer: 'https://www.rb.no/' });
29
- const formData = fetch.mock.calls[0][1]?.body as FormData;
30
-
31
- expect(formData?.get('referrer')).toEqual('https://www.rb.no/');
32
- });
33
- });
34
-
35
14
  describe('activateSubscription()', () => {
36
15
  it('should throw error if user is deactivated', async () => {
37
16
  fetch.mockResponse(JSON.stringify({ status: 'user_deactivated' }), {
@@ -43,7 +22,7 @@ describe('activateSubscription()', () => {
43
22
  });
44
23
 
45
24
  it('should return empty list if user not found', async () => {
46
- fetch.mockResponse(JSON.stringify({ status: 'whatever' }), {
25
+ fetch.mockResponse(JSON.stringify({ status: 'no_session_found' }), {
47
26
  status: 401,
48
27
  });
49
28
  await expect(activateSubscription(['newspaper'])).resolves.toEqual([]);
@@ -1,61 +1,13 @@
1
- import {
2
- getCurrentHostname,
3
- getCurrentPublicationDomain,
4
- getCurrentUrl,
5
- } from '../utils/url';
6
-
7
- function postLog(url: string, query: { [index: string]: any }) {
8
- const body = new FormData();
9
- Object.keys(query).forEach((key) => body.append(key, query[key]));
10
- const options: RequestInit = {
11
- method: 'POST',
12
- body,
13
- headers: {
14
- Accept: 'application/json',
15
- },
16
- };
17
- fetch(url, options).then((res) => {
18
- if (!res.ok) {
19
- throw new Error(`Error, status: ${res.status}, text: ${res.statusText}`);
20
- }
21
- });
22
- }
23
-
24
- const backendLog = (level: string, message: string, context: Object) => {
25
- const internalContext = {};
26
- Object.keys(context).forEach((key) => {
27
- if (['string', 'number', 'boolean'].includes(typeof context[key])) {
28
- internalContext[key] = context[key];
29
- return;
30
- }
31
- try {
32
- internalContext[key] = JSON.stringify(context[key]);
33
- } catch (e) {
34
- internalContext[key] = context[key];
35
- }
36
- });
37
- const extendedContext = {
38
- ...internalContext,
39
- message,
40
- url: getCurrentUrl(),
41
- domain: getCurrentHostname(),
42
- };
43
- postLog(`/api/mercury/v1/log/${level}`, extendedContext);
44
- };
45
-
46
- const log = {
47
- error: (message: string, context: Object) =>
48
- backendLog('error', message, context),
49
- warn: (message: string, context: Object) =>
50
- backendLog('warn', message, context),
51
- info: (message: string, context: Object) =>
52
- backendLog('info', message, context),
53
- debug: (message: string, context: Object) =>
54
- backendLog('debug', message, context),
55
- };
1
+ import log from '../utils/log';
2
+ import { getCurrentPublicationDomain } from '../utils/url';
56
3
 
57
4
  export class UserDeactivatedError extends Error {}
58
5
 
6
+ const EXPECTED_ERRORS = [
7
+ 'no_session_found', // Not logged in
8
+ 'subscription_not_found', // No active subscription
9
+ ];
10
+
59
11
  export const activateSubscription = async (
60
12
  accessFeatures: string[]
61
13
  ): Promise<string[]> =>
@@ -73,17 +25,23 @@ export const activateSubscription = async (
73
25
  data = JSON.parse(body);
74
26
  } catch (error) {
75
27
  log.error(
76
- 'Activate subscription. Response from mercury does not contain parsable json',
28
+ `Activate subscription failed. Mercury (HTTP/${response.status}: ${body})`,
77
29
  { error, response, accessFeatures, body }
78
30
  );
79
31
  }
80
32
  if (!response.ok) {
81
- if (response.status === 401 && data?.status === 'user_deactivated') {
33
+ // User deactivated
34
+ if (data?.status === 'user_deactivated') {
82
35
  throw new UserDeactivatedError();
83
36
  }
37
+ if (EXPECTED_ERRORS.includes(data?.status)) {
38
+ return [];
39
+ }
40
+ log.error(
41
+ `Activate subscription failed. Mercury (HTTP/${response.status}: ${body})`,
42
+ { response, accessFeatures, body }
43
+ );
84
44
  return [];
85
45
  }
86
46
  return data?.access_features;
87
47
  });
88
-
89
- export default log;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import fetch from 'jest-fetch-mock';
6
+ import backendLog from './mercuryLog';
7
+ import restoreAllMocks = jest.restoreAllMocks;
8
+
9
+ beforeEach(() => {
10
+ restoreAllMocks();
11
+ fetch.resetMocks();
12
+ });
13
+
14
+ describe('Mercury backendlog', () => {
15
+ it('should include level in url', () => {
16
+ backendLog.error('jest message', {});
17
+ expect(fetch).toHaveBeenCalledWith(
18
+ expect.stringContaining('/error'),
19
+ expect.anything()
20
+ );
21
+ expect(fetch).toHaveBeenCalledTimes(1);
22
+ });
23
+
24
+ it('should include additional context as query parameters', () => {
25
+ backendLog.error('jest message', { referrer: 'https://www.rb.no/' });
26
+ const formData = fetch.mock.calls[0][1]?.body as FormData;
27
+
28
+ expect(formData?.get('referrer')).toEqual('https://www.rb.no/');
29
+ });
30
+ });
@@ -0,0 +1,56 @@
1
+ import { getCurrentHostname, getCurrentUrl } from '../utils/url';
2
+
3
+ /**
4
+ * Extracted from mercury.tsx so other calls to mercury can log properly
5
+ */
6
+ function postLog(url: string, query: { [index: string]: any }) {
7
+ const body = new FormData();
8
+ Object.keys(query).forEach((key) => body.append(key, query[key]));
9
+ const options: RequestInit = {
10
+ method: 'POST',
11
+ body,
12
+ headers: {
13
+ Accept: 'application/json',
14
+ },
15
+ };
16
+ fetch(url, options).then((res) => {
17
+ if (!res.ok) {
18
+ throw new Error(`Error, status: ${res.status}, text: ${res.statusText}`);
19
+ }
20
+ });
21
+ }
22
+
23
+ const backendLog = (level: string, message: string, context: Object) => {
24
+ const internalContext = {};
25
+ Object.keys(context).forEach((key) => {
26
+ if (['string', 'number', 'boolean'].includes(typeof context[key])) {
27
+ internalContext[key] = context[key];
28
+ return;
29
+ }
30
+ try {
31
+ internalContext[key] = JSON.stringify(context[key]);
32
+ } catch (e) {
33
+ internalContext[key] = context[key];
34
+ }
35
+ });
36
+ const extendedContext = {
37
+ ...internalContext,
38
+ message,
39
+ url: getCurrentUrl(),
40
+ domain: getCurrentHostname(),
41
+ };
42
+ postLog(`/api/mercury/v1/log/${level}`, extendedContext);
43
+ };
44
+
45
+ const log = {
46
+ error: (message: string, context: Object) =>
47
+ backendLog('error', message, context),
48
+ warn: (message: string, context: Object) =>
49
+ backendLog('warn', message, context),
50
+ info: (message: string, context: Object) =>
51
+ backendLog('info', message, context),
52
+ debug: (message: string, context: Object) =>
53
+ backendLog('debug', message, context),
54
+ };
55
+
56
+ export default log;
@@ -151,8 +151,7 @@ describe('Pluto service', () => {
151
151
  fetch.mockResponseOnce(() =>
152
152
  Promise.resolve({
153
153
  init: { status: 404 },
154
- body:
155
- '{"errors":[{"id":"f84ea34e-d9eb-11eb-afe7-000000000000","title":"No currentSession found","detail":"Got currentSession not found error","status":"404","code":"session.not_found"}]}\n',
154
+ body: '{"errors":[{"id":"f84ea34e-d9eb-11eb-afe7-000000000000","title":"No currentSession found","detail":"Got currentSession not found error","status":"404","code":"session.not_found"}]}\n',
156
155
  })
157
156
  );
158
157
  currentSession = await getCurrentSession();
@@ -165,9 +164,7 @@ describe('Pluto service', () => {
165
164
  describe('removeSession()', () => {
166
165
  it('should call Plut session delete', () => {
167
166
  removeSession('www.rb.no');
168
- expect(
169
- fetch
170
- ).toHaveBeenCalledWith(
167
+ expect(fetch).toHaveBeenCalledWith(
171
168
  '/api/pluto/v1/sessions/current?publication_domain=www.rb.no',
172
169
  { method: 'DELETE' }
173
170
  );
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import store from '../store';
5
+ import { UserDataRequest } from '../index';
6
+ import { listenForUserAttributeRequests } from '../eventHandlers/userAttributes';
7
+ import { listenForStateRequests } from '../eventHandlers/state';
8
+ import { listenForStorageRequests } from '../eventHandlers/storage';
9
+ import { setRootElement } from '../utils/customEventWrapper';
10
+ import * as europa from '../clients/europa';
11
+
12
+ beforeEach(() => {
13
+ // We cannot use window as our event root during testing
14
+ // since tests are executed in parallel.
15
+ setRootElement(new Document());
16
+
17
+ store.clear();
18
+
19
+ // Also, since we keep creating new root elements, we also
20
+ // need to attach to these new roots.
21
+ listenForUserAttributeRequests();
22
+ listenForStateRequests();
23
+ listenForStorageRequests();
24
+ });
25
+
26
+ describe('UserDataRequest', () => {
27
+ describe('when fetching', () => {
28
+ describe('and is logged in', () => {
29
+ beforeEach(() => {
30
+ store.set('state', { isLoggedIn: true });
31
+ store.set('userAttributes', {
32
+ name: 'Donald Duck',
33
+ });
34
+ });
35
+
36
+ describe('and already have all requested attributes', () => {
37
+ let response;
38
+ beforeEach(async () => {
39
+ response = await new UserDataRequest()
40
+ .withAttributes(['name'])
41
+ .fetch();
42
+ });
43
+
44
+ it('should have resolved to include name', () => {
45
+ expect(response.attributes).toEqual({ name: 'Donald Duck' });
46
+ });
47
+
48
+ it('should be logged in', () => {
49
+ expect(response.state).toEqual({ isLoggedIn: true });
50
+ });
51
+ });
52
+ });
53
+
54
+ describe('and not logged in', () => {
55
+ beforeEach(() => {
56
+ store.set('state', { isLoggedIn: false });
57
+ });
58
+
59
+ describe('when getting storage', () => {
60
+ beforeEach(async () => {
61
+ spyOn(europa, 'getNamespaces');
62
+ await new UserDataRequest().withStorage(['euucp']).fetch();
63
+ });
64
+
65
+ it('should not request data', () => {
66
+ expect(europa.getNamespaces).not.toHaveBeenCalled();
67
+ });
68
+ });
69
+ });
70
+ });
71
+ });
package/src/utils/log.ts CHANGED
@@ -1,4 +1,4 @@
1
- import mercury from '../clients/mercury';
1
+ import mercury from '../clients/mercuryLog';
2
2
 
3
3
  export type Logger = {
4
4
  debug: (message: string | Error, context?: Object) => void;
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "extends": "@amedia/eslint-config-typescript/tsconfig.json",
3
3
  "compilerOptions": {
4
- "outDir": "./dist/",
5
- //"outFile": "./dist/amedia-user.js",
4
+ "outDir": "./dist",
6
5
  "rootDir": "./src",
7
6
  "typeRoots": [
8
7
  "./node_modules/@types"
9
8
  ],
10
9
  "module": "ES6",
11
- //"module": "AMD",
12
10
  "lib": [
13
11
  "DOM"
14
12
  ],
@@ -21,4 +19,4 @@
21
19
  "include": [
22
20
  "src/**/*",
23
21
  ]
24
- }
22
+ }
package/tsconfig.json CHANGED
@@ -2,9 +2,10 @@
2
2
  "extends": "@amedia/eslint-config-typescript/tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "./src",
5
- "outDir": "./dist/",
5
+ "outDir": "./dist",
6
6
  //"noImplicitAny": true,
7
7
  "declaration": true,
8
+ "emitDeclarationOnly": true,
8
9
  "typeRoots": [
9
10
  "./node_modules/@types"
10
11
  ],
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager" inherit-compiler-output="true">
4
- <exclude-output />
5
- <content url="file://$MODULE_DIR$" />
6
- <orderEntry type="inheritedJdk" />
7
- <orderEntry type="sourceFolder" forTests="false" />
8
- </component>
9
- </module>
@@ -1,7 +0,0 @@
1
- import { CacheEntry, Engine } from '../types';
2
- export declare const get: (key: string) => Promise<CacheEntry>;
3
- export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
4
- export declare const remove: (key: string) => Promise<void>;
5
- export declare const clear: () => Promise<void>;
6
- declare const _default: Engine;
7
- export default _default;
@@ -1,14 +0,0 @@
1
- /*!
2
- localForage -- Offline Storage, Improved
3
- Version 1.9.0
4
- https://localforage.github.io/localForage
5
- (c) 2013-2017 Mozilla, Apache License 2.0
6
- */
7
-
8
- /*!
9
- * JavaScript Cookie v2.2.1
10
- * https://github.com/js-cookie/js-cookie
11
- *
12
- * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
13
- * Released under the MIT license
14
- */
@@ -1,16 +0,0 @@
1
- declare class PaywallUnlocker {
2
- private requestedAccessFeatures;
3
- private reload;
4
- private requestedUrl;
5
- withAccessFeatures(accessFeatures: string[]): this;
6
- reloadOnAccess(): this;
7
- redirectOnAccess(requestedUrl: string): this;
8
- tryUnlock(): Promise<{
9
- isLoggedIn: boolean;
10
- hasAccess: boolean;
11
- accessFeatures: string[];
12
- }>;
13
- private resolveActualAccessFeatures;
14
- private setAccessCookiesAndPerformRequestedActions;
15
- }
16
- export default PaywallUnlocker;
@@ -1,4 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- export {};
@@ -1,21 +0,0 @@
1
- import { State, UserAttributes } from '../types';
2
- declare class User<UA extends UserAttributes, S extends {
3
- [index: string]: unknown;
4
- }, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends {} = {
5
- state: State;
6
- }> {
7
- private attributes?;
8
- private namespaces?;
9
- constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
10
- withAttributes<NewAttributes extends Array<keyof UA>>(attributes: NewAttributes): User<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
11
- attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
12
- }>;
13
- withStorage<NewNamespaces extends Array<string>>(...namespace: NewNamespaces): User<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
14
- storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
15
- }>;
16
- subscribe(onData: (data: SubscribeResponse) => void): void;
17
- private processUserAttributesEvent;
18
- private processStorageEvent;
19
- private setupLocalCache;
20
- }
21
- export default User;
@@ -1 +0,0 @@
1
- export default function logValidationError(name: string, error: Error, extra?: Object): void;
package/rollup.config.js DELETED
@@ -1,14 +0,0 @@
1
- import resolve from '@rollup/plugin-node-resolve';
2
- import commonjs from '@rollup/plugin-commonjs';
3
- import typescript from 'rollup-plugin-typescript2';
4
- import { uglify } from 'rollup-plugin-uglify';
5
-
6
- export default {
7
- input: 'src/index.ts',
8
- output: {
9
- file: 'esm/user.js',
10
- format: 'esm',
11
- sourcemap: true,
12
- },
13
- plugins: [resolve(), commonjs(), typescript(), uglify()],
14
- };
package/test.html DELETED
@@ -1,12 +0,0 @@
1
- <html>
2
- <head>
3
- <script type="module">
4
- import { user } from 'https://assets.acdn.no/pkg/user-js/0.0.1/files/user.js'
5
- console.log(user)
6
- </script>
7
- </head>
8
- <body>
9
-
10
- </body>
11
-
12
- </html>
package/webpack.config.js DELETED
@@ -1,28 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = {
4
- experiments: {
5
- outputModule: true,
6
- },
7
- entry: './src/index.ts',
8
- module: {
9
- rules: [
10
- {
11
- test: /\.tsx?$/,
12
- use: ['ts-loader'],
13
- exclude: /node_modules/,
14
- },
15
- ],
16
- },
17
- resolve: {
18
- extensions: ['.tsx', '.ts', '.js'],
19
- },
20
- output: {
21
- path: path.resolve(__dirname, 'dist'),
22
- filename: 'index.js',
23
- library: {
24
- type: 'module',
25
- },
26
- globalObject: 'this',
27
- },
28
- };