@datagrok/compute 1.44.3 → 1.44.4

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/webpack.config.js CHANGED
@@ -1,54 +1,69 @@
1
1
  const path = require('path');
2
2
  const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
3
+ const FuncGeneratorPlugin = require('datagrok-tools/plugins/func-gen-plugin');
4
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
3
5
 
4
- module.exports = {
5
- mode: 'production',
6
- entry: {
7
- test: {
8
- filename: 'package-test.js',
9
- library: {type: 'var', name: `${packageName}_test`},
10
- import: './src/package-test.ts',
11
- },
12
- package: './src/package.ts',
13
- },
14
- resolve: {
15
- extensions: ['.wasm', '.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],
16
- },
17
- module: {
18
- rules: [
19
- {test: /\.tsx?$/, loader: 'ts-loader', options: {allowTsInNodeModules: true}},
20
- {
21
- test: /\.css$/,
22
- use: ['style-loader', 'css-loader'],
23
- },
24
- {
25
- test: /\.(ts|tsx|mjs|js|jsx)$/,
26
- enforce: 'pre',
27
- use: ['source-map-loader'],
6
+ module.exports = (env) => {
7
+ const stats = env.stats === 'true';
8
+ const mode = env.NODE_ENV ?? 'production';
9
+ return {
10
+ mode,
11
+ entry: {
12
+ test: {
13
+ filename: 'package-test.js',
14
+ library: { type: 'var', name: `${packageName}_test` },
15
+ import: './src/package-test.ts',
28
16
  },
29
- ],
30
- },
31
- devtool: 'source-map',
32
- externals: { // external modules won't be loaded to the output, but taken from the environment
33
- 'datagrok-api/dg': 'DG',
34
- 'datagrok-api/grok': 'grok',
35
- 'datagrok-api/ui': 'ui',
36
- 'openchemlib/full.js': 'OCL',
37
- 'rxjs': 'rxjs',
38
- 'rxjs/operators': 'rxjs.operators',
39
- 'cash-dom': '$',
40
- 'dayjs': 'dayjs',
41
- 'wu': 'wu',
42
- 'exceljs': 'ExcelJS'
43
- },
44
- output: {
45
- filename: '[name].js',
46
- library: 'compute',
47
- libraryTarget: 'var',
48
- path: path.resolve(__dirname, 'dist'),
49
- },
50
- optimization: {
51
- usedExports: true,
52
- concatenateModules: false,
53
- }
54
- };
17
+ package: './src/package.ts',
18
+ },
19
+ resolve: {
20
+ extensions: ['.wasm', '.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],
21
+ },
22
+ module: {
23
+ rules: [
24
+ { test: /\.tsx?$/, loader: 'ts-loader', options: { allowTsInNodeModules: true } },
25
+ {
26
+ test: /\.css$/,
27
+ use: ['style-loader', 'css-loader'],
28
+ },
29
+ {
30
+ test: /\.(ts|tsx|mjs|js|jsx)$/,
31
+ enforce: 'pre',
32
+ use: ['source-map-loader'],
33
+ },
34
+ ],
35
+ },
36
+ devtool: 'source-map',
37
+ externals: { // external modules won't be loaded to the output, but taken from the environment
38
+ 'datagrok-api/dg': 'DG',
39
+ 'datagrok-api/grok': 'grok',
40
+ 'datagrok-api/ui': 'ui',
41
+ 'openchemlib/full.js': 'OCL',
42
+ 'rxjs': 'rxjs',
43
+ 'rxjs/operators': 'rxjs.operators',
44
+ 'cash-dom': '$',
45
+ 'dayjs': 'dayjs',
46
+ 'wu': 'wu',
47
+ 'exceljs': 'ExcelJS',
48
+ 'html2canvas': 'html2canvas',
49
+ },
50
+ output: {
51
+ filename: '[name].js',
52
+ library: packageName,
53
+ libraryTarget: 'var',
54
+ path: path.resolve(__dirname, 'dist'),
55
+ clean: true,
56
+ },
57
+ optimization: {
58
+ concatenateModules: false,
59
+ },
60
+ plugins: [
61
+ new BundleAnalyzerPlugin({
62
+ defaultSizes: 'parsed',
63
+ generateStatsFile: stats,
64
+ analyzerMode: 'disabled',
65
+ }),
66
+ new FuncGeneratorPlugin({ outputPath: './src/package.g.ts' }),
67
+ ]
68
+ };
69
+ }