drf-react-by-schema 0.2.2 → 0.3.1

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.
Files changed (79) hide show
  1. package/dist/api.d.ts +84 -0
  2. package/dist/api.js +613 -0
  3. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.d.ts +8 -0
  4. package/dist/components/DataGridBySchemaEditable/ConfirmDialog.js +21 -0
  5. package/dist/components/DataGridBySchemaEditable/CustomToolbar.d.ts +16 -0
  6. package/dist/components/DataGridBySchemaEditable/CustomToolbar.js +77 -0
  7. package/dist/components/DataGridBySchemaEditable/FooterToolbar.d.ts +16 -0
  8. package/dist/components/DataGridBySchemaEditable/FooterToolbar.js +41 -0
  9. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.d.ts +8 -0
  10. package/dist/components/DataGridBySchemaEditable/GridDecimalInput.js +32 -0
  11. package/dist/components/DataGridBySchemaEditable/GridPatternInput.d.ts +8 -0
  12. package/dist/components/DataGridBySchemaEditable/GridPatternInput.js +30 -0
  13. package/dist/components/DataGridBySchemaEditable/InputInterval.d.ts +3 -0
  14. package/dist/components/DataGridBySchemaEditable/InputInterval.js +105 -0
  15. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.d.ts +33 -0
  16. package/dist/components/DataGridBySchemaEditable/SelectEditInputCell.js +140 -0
  17. package/dist/components/DataGridBySchemaEditable/utils.d.ts +15 -0
  18. package/{src/components/DataGridBySchemaEditable/utils.ts → dist/components/DataGridBySchemaEditable/utils.js} +32 -50
  19. package/dist/components/DataGridBySchemaEditable.d.ts +34 -0
  20. package/dist/components/DataGridBySchemaEditable.js +549 -0
  21. package/dist/components/DataTotals.d.ts +14 -0
  22. package/dist/components/DataTotals.js +23 -0
  23. package/dist/components/DialogActions.d.ts +10 -0
  24. package/dist/components/DialogActions.js +17 -0
  25. package/dist/components/DialogJSONSchemaForm.d.ts +12 -0
  26. package/dist/components/DialogJSONSchemaForm.js +20 -0
  27. package/dist/components/FormButtons.d.ts +14 -0
  28. package/dist/components/FormButtons.js +39 -0
  29. package/dist/components/GenericModelList.d.ts +19 -0
  30. package/dist/components/GenericModelList.js +113 -0
  31. package/dist/components/GenericRelatedModelList.d.ts +25 -0
  32. package/dist/components/GenericRelatedModelList.js +111 -0
  33. package/dist/components/TextFieldBySchema.js +39 -0
  34. package/dist/context/APIWrapper.d.ts +12 -0
  35. package/dist/context/APIWrapper.js +341 -0
  36. package/dist/context/APIWrapperContext.d.ts +75 -0
  37. package/dist/context/APIWrapperContext.js +15 -0
  38. package/dist/context/DRFReactBySchemaContext.d.ts +20 -0
  39. package/dist/context/DRFReactBySchemaContext.js +19 -0
  40. package/dist/context/DRFReactBySchemaProvider.d.ts +13 -0
  41. package/dist/context/DRFReactBySchemaProvider.js +53 -0
  42. package/dist/context/Form.d.ts +11 -0
  43. package/dist/context/Form.js +82 -0
  44. package/dist/context/Overlays.d.ts +4 -0
  45. package/dist/context/Overlays.js +87 -0
  46. package/dist/index.d.ts +11 -0
  47. package/dist/index.js +14 -27
  48. package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
  49. package/dist/styles/index.js +28 -0
  50. package/dist/styles/layout.d.ts +107 -0
  51. package/dist/styles/layout.js +56 -0
  52. package/dist/styles/theme.d.ts +21 -0
  53. package/dist/styles/theme.js +139 -0
  54. package/dist/utils.d.ts +75 -0
  55. package/dist/utils.js +268 -0
  56. package/package.json +15 -2
  57. package/.eslintrc.js +0 -14
  58. package/.gitlab-ci.yml +0 -14
  59. package/src/api.ts +0 -733
  60. package/src/components/DataGridBySchemaEditable/ConfirmDialog.tsx +0 -41
  61. package/src/components/DataGridBySchemaEditable/CustomToolbar.tsx +0 -93
  62. package/src/components/DataGridBySchemaEditable/FooterToolbar.tsx +0 -77
  63. package/src/components/DataGridBySchemaEditable/GridDecimalInput.tsx +0 -41
  64. package/src/components/DataGridBySchemaEditable/GridPatternInput.tsx +0 -37
  65. package/src/components/DataGridBySchemaEditable/InputInterval.tsx +0 -194
  66. package/src/components/DataGridBySchemaEditable/SelectEditInputCell.tsx +0 -153
  67. package/src/components/DataGridBySchemaEditable.md +0 -50
  68. package/src/components/DataGridBySchemaEditable.tsx +0 -747
  69. package/src/components/DataTotals.tsx +0 -56
  70. package/src/components/GenericModelList.tsx +0 -155
  71. package/src/context/DRFReactBySchemaProvider.md +0 -50
  72. package/src/context/DRFReactBySchemaProvider.tsx +0 -78
  73. package/src/index.ts +0 -64
  74. package/src/styles/layout.ts +0 -104
  75. package/src/styles/theme.ts +0 -190
  76. package/src/utils.ts +0 -321
  77. package/styleguide.config.js +0 -13
  78. package/tsconfig.json +0 -104
  79. package/webpack.config.js +0 -24
package/src/utils.ts DELETED
@@ -1,321 +0,0 @@
1
- import * as Yup from 'yup';
2
- import { GridActionsColDef, GridColDef } from '@mui/x-data-grid';
3
-
4
- export type Id = string | number;
5
- export type Item = Record<string, any>;
6
- export type SchemaType = Record<string, Field>;
7
- export interface Choice {
8
- value: string | number,
9
- display_name: string
10
- };
11
- type FieldChild = Record<string, SchemaType>;
12
- export interface Field {
13
- type: string,
14
- child?: FieldChild,
15
- children?: SchemaType,
16
- model_default?: any,
17
- model_required?: boolean
18
- choices?: Choice[],
19
- max_length?: number | string,
20
- label: string,
21
- read_only?: boolean
22
- };
23
- interface GridBySchemaColDef extends GridColDef {
24
- isIndexField?: boolean,
25
- creatable?: boolean,
26
- orderable?: boolean,
27
- patternFormat?: string
28
- };
29
- interface GridActionsBySchemaColDef extends GridActionsColDef {
30
- isIndexField?: boolean,
31
- creatable?: boolean,
32
- orderable?: boolean,
33
- patternFormat?: string
34
- };
35
- export type GridEnrichedBySchemaColDef = GridBySchemaColDef | GridActionsBySchemaColDef;
36
-
37
- export const emptyByType: any = (field:Field, forDatabase:boolean = false) => {
38
- if (field.model_default) {
39
- return field.model_default;
40
- }
41
- switch (field.type) {
42
- case 'nested object':
43
- // emptyByType must be an empty object for the database, but must be null for the mui-autocomplete component. So I had to make this ugly hack here, when we're preparing to sendo to the database:
44
- return forDatabase ? {} : null;
45
- case 'field':
46
- if (field.child) {
47
- return [];
48
- }
49
- return (forDatabase)
50
- ? undefined
51
- : null;
52
- case 'string':
53
- case 'email':
54
- return '';
55
- case 'integer':
56
- return 0;
57
- case 'array':
58
- return [];
59
- default:
60
- return null;
61
- }
62
- };
63
-
64
- export const getChoiceByValue = (
65
- value:number | string,
66
- choices:Choice[] | undefined
67
- ) => {
68
- if (!choices) {
69
- return null;
70
- }
71
- for (const choice of choices) {
72
- if (choice.value === value) {
73
- return choice.display_name;
74
- }
75
- }
76
- };
77
-
78
- export const populateValues = ({
79
- model,
80
- data,
81
- schema
82
- }: {
83
- model:string,
84
- data:Item,
85
- schema:SchemaType
86
- }) => {
87
- const values:Record<string, any> = {};
88
- for (const entry of Object.entries(schema)) {
89
- const [key, field] = entry;
90
- if (key === 'id' && isTmpId(data[key])) {
91
- continue;
92
- }
93
-
94
- if (!data[key]) {
95
- values[key] = emptyByType(field);
96
- continue;
97
- }
98
-
99
- if (field.type === 'field' && field.child) {
100
- if (Array.isArray(data[key])) {
101
- const arValues = [];
102
- for (const row of data[key]) {
103
- const value = populateValues({
104
- model,
105
- data: row,
106
- schema: field.child.children
107
- });
108
- arValues.push(value);
109
- }
110
- values[key] = arValues;
111
- continue;
112
- }
113
-
114
- values[key] = populateValues({
115
- model,
116
- data: data[key],
117
- schema: field.child.children
118
- });
119
- continue;
120
- }
121
-
122
- if (field.type === 'choice') {
123
- values[key] = data[key]
124
- ? {
125
- value: data[key],
126
- display_name: getChoiceByValue(data[key], field.choices)
127
- }
128
- : emptyByType(field);
129
- continue;
130
- }
131
-
132
- values[key] = data[key];
133
- }
134
- // console.log(values);
135
- return values;
136
- };
137
-
138
- const getYupValidator = (type:string) => {
139
- let yupFunc;
140
- try {
141
- switch (type) {
142
- case 'slug':
143
- yupFunc = Yup.string();
144
- break;
145
- case 'email':
146
- yupFunc = Yup.string().email('Este campo deve ser um e-mail válido.');
147
- break;
148
- case 'integer':
149
- yupFunc = Yup.number().integer('Este campo deve ser um número inteiro');
150
- break;
151
- case 'choice':
152
- yupFunc = Yup.object();
153
- break;
154
- case 'field':
155
- yupFunc = Yup.mixed();
156
- break;
157
- case 'nested object':
158
- yupFunc = Yup.object();
159
- break;
160
- case 'date':
161
- yupFunc = Yup.date();
162
- break;
163
- case 'string':
164
- yupFunc = Yup.string();
165
- break;
166
- case 'number':
167
- yupFunc = Yup.number();
168
- break;
169
- case 'boolean':
170
- yupFunc = Yup.boolean();
171
- break;
172
- case 'array':
173
- yupFunc = Yup.array();
174
- break;
175
- case 'object':
176
- yupFunc = Yup.object();
177
- break;
178
- default:
179
- yupFunc = Yup.string();
180
- break;
181
- }
182
- } catch (e) {
183
- yupFunc = Yup.string();
184
- }
185
- return yupFunc.nullable();
186
- };
187
-
188
- export const buildGenericYupValidationSchema = ({
189
- data,
190
- schema,
191
- many = false,
192
- skipFields = [],
193
- extraValidators = {}
194
- }:{
195
- data:Item,
196
- schema:SchemaType,
197
- many?:boolean,
198
- skipFields?: string[],
199
- extraValidators?:Item
200
- }) => {
201
- const yupValidator:Record<string, any> = {};
202
- for (const entry of Object.entries(schema)) {
203
- const [key, field] = entry;
204
-
205
- if (!data || !(key in data) || key === 'id' || skipFields.includes(key)) {
206
- continue;
207
- }
208
-
209
- // console.log({ key, field, data: data[key] });
210
-
211
- // OneToMany or ManyToMany:
212
- if (field.type === 'field' && field.child) {
213
- yupValidator[key] = buildGenericYupValidationSchema({
214
- schema: field.child.children,
215
- many: true,
216
- data: data[key],
217
- extraValidators: Object.prototype.hasOwnProperty.call(extraValidators, key)
218
- ? extraValidators[key]
219
- : {}
220
- });
221
- continue;
222
- }
223
-
224
- // Nested Object:
225
- if (field.type === 'nested object' && field.children) {
226
- // yupValidator[key] = buildGenericYupValidationSchema({
227
- // schema: field.children,
228
- // many: false,
229
- // data: data[key],
230
- // extraValidators: Object.prototype.hasOwnProperty.call(extraValidators, key)
231
- // ? extraValidators[key]
232
- // : {}
233
- // });
234
- // if (!field.model_required) {
235
- // yupValidator[key] = yupValidator[key].nullable();
236
- // }
237
- // continue;
238
- }
239
-
240
- yupValidator[key] = Object.prototype.hasOwnProperty.call(extraValidators, key)
241
- ? extraValidators[key]
242
- : getYupValidator(field.type);
243
-
244
- if (field.model_required) {
245
- yupValidator[key] = yupValidator[key].required('Este campo é obrigatório');
246
- }
247
- if (field.max_length) {
248
- yupValidator[key] = yupValidator[key].max(parseInt(field.max_length as string), `Este campo só pode ter no máximo ${field.max_length} caracteres`);
249
- }
250
- }
251
- // console.log({ yupValidator });
252
- return (many)
253
- ? Yup.array().of(Yup.object().shape(yupValidator))
254
- : Yup.object().shape(yupValidator);
255
- };
256
-
257
- export const errorProps = ({
258
- type,
259
- errors,
260
- fieldKey,
261
- fieldKeyProp,
262
- index
263
- }: {
264
- type:string,
265
- errors:Item,
266
- fieldKey:string,
267
- fieldKeyProp:string,
268
- index?:number
269
- }) => {
270
- let error;
271
- let helperText;
272
- if (index) {
273
- const hasErrors = errors && errors[fieldKey] && errors[fieldKey][index] && Boolean(errors[fieldKey][index][fieldKeyProp]);
274
- error = hasErrors;
275
- helperText = hasErrors ? errors[fieldKey][index][fieldKeyProp].message : null;
276
- return { error, helperText };
277
- }
278
-
279
- const hasErrors = errors && errors[fieldKey] && Boolean(errors[fieldKey][fieldKeyProp]);
280
- error = hasErrors;
281
- helperText = hasErrors ? errors[fieldKey][fieldKeyProp].message : null;
282
- return { error, helperText };
283
- };
284
-
285
- export const getTmpId = () => {
286
- return 'tmp' + Math.floor(Math.random() * 1000000);
287
- };
288
-
289
- export const isTmpId = (id:string | number | undefined | null) => {
290
- if (!id) {
291
- return true;
292
- }
293
- return id.toString().substr(0, 3) === 'tmp';
294
- };
295
-
296
- export const reducer = (state:Record<string, any>, newState:Record<string, any>) => {
297
- return { ...state, ...newState };
298
- };
299
-
300
- export const getPatternFormat = (type:string) => {
301
- let format = '';
302
- switch (type) {
303
- case 'telefone':
304
- case 'fone':
305
- case 'phone':
306
- case 'contact':
307
- case 'contato':
308
- format = '(##)#####-####';
309
- break;
310
- case 'cpf':
311
- format = '###.###.###-##';
312
- break;
313
- case 'cnpj':
314
- format = '##.###.###/####-##';
315
- break;
316
- case 'cep':
317
- format = '##.###-###';
318
- break;
319
- }
320
- return format;
321
- };
@@ -1,13 +0,0 @@
1
- const path = require('path');
2
- const glob = require('glob');
3
-
4
- module.exports = {
5
- title: 'Styleguides for DRF React By Schema Package',
6
- styleguideDir: 'public',
7
- components: [
8
- 'src/components/*.tsx',
9
- 'src/context/*.tsx'
10
- ],
11
- resolver: require('react-docgen').resolver.findAllComponentDefinitions,
12
- propsParser: require('react-docgen-typescript').withDefaultConfig({ propFilter: { skipPropsWithoutDoc: false } }).parse
13
- };
package/tsconfig.json DELETED
@@ -1,104 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- "jsx": "react", /* Specify what JSX code is generated. */
17
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "commonjs", /* Specify what module code is generated. */
29
- // "rootDir": "./", /* Specify the root folder within your source files. */
30
- "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "resolveJsonModule": true, /* Enable importing .json files. */
39
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
-
41
- /* JavaScript Support */
42
- // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
- // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
-
46
- /* Emit */
47
- "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
- "outDir": "./dist", /* Specify an output folder for all emitted files. */
53
- // "removeComments": true, /* Disable emitting comments. */
54
- // "noEmit": true, /* Disable emitting files from a compilation. */
55
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
- // "newLine": "crlf", /* Set the newline character for emitting files. */
64
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
-
71
- /* Interop Constraints */
72
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
- "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
- "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
-
78
- /* Type Checking */
79
- "strict": true, /* Enable all strict type-checking options. */
80
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
-
99
- /* Completeness */
100
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
- },
103
- "include": ["src/**/*"]
104
- }
package/webpack.config.js DELETED
@@ -1,24 +0,0 @@
1
- var path = require('path');
2
-
3
- module.exports = {
4
- entry: {
5
- bundle: ['./src/index.ts'],
6
- },
7
- context: path.resolve(__dirname),
8
- output: {
9
- filename: 'bundle.js',
10
- path: path.join(__dirname, 'temp')
11
- },
12
- module: {
13
- rules: [
14
- {
15
- test: /\.tsx?$/,
16
- loader: 'ts-loader',
17
- exclude: /node_modules/,
18
- }
19
- ]
20
- },
21
- resolve: {
22
- extensions: [".tsx", ".ts", ".js"]
23
- }
24
- };