@vixoniccom/module-packager 2.13.0-test.0 → 2.13.0-test.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.
package/dist/main.js CHANGED
@@ -13,7 +13,6 @@ import { Configuration } from '@vixoniccom/modules';
13
13
  import tsNode from 'ts-node';
14
14
  import { createRequire } from 'module';
15
15
  import which from 'which';
16
- import 'dotenv/config';
17
16
  const __filename = fileURLToPath(import.meta.url);
18
17
  const __dirname = path.dirname(__filename);
19
18
  const electronPath = path.join(__dirname, 'electron.js');
@@ -68,7 +67,6 @@ function createElectronArgs(mode) {
68
67
  ];
69
68
  }
70
69
  function spawnElectronProcess(mode) {
71
- console.log('env:', process.env.AQI_TOKEN);
72
70
  const args = createElectronArgs(mode);
73
71
  const nodeEnv = mode === 'run' ? 'production' : 'development';
74
72
  const child = spawn(npxPath, ['electron', ...args], {
@@ -5,6 +5,7 @@ import { CleanWebpackPlugin } from 'clean-webpack-plugin';
5
5
  import CopyWebpackPlugin from 'copy-webpack-plugin';
6
6
  import TerserPlugin from 'terser-webpack-plugin';
7
7
  import webpack from 'webpack';
8
+ import 'dotenv/config';
8
9
  export default (env = {}, argv = {}) => {
9
10
  const require = createRequire(import.meta.url);
10
11
  const options = {
@@ -13,9 +14,7 @@ export default (env = {}, argv = {}) => {
13
14
  port: env.port ?? 8080,
14
15
  mode: argv.mode ?? 'production',
15
16
  };
16
- const isDev = options.mode === 'development' ||
17
- argv.watch === true ||
18
- process.env.NODE_ENV === 'development';
17
+ const isDev = options.mode === 'development' || argv.watch === true || process.env.NODE_ENV === 'development';
19
18
  const buildPath = path.resolve(options.build);
20
19
  const controllerHtmlPath = path.resolve(options.src, 'index.html');
21
20
  const controllerStaticPath = path.resolve(path.dirname(controllerHtmlPath), '../static');
@@ -24,20 +23,22 @@ export default (env = {}, argv = {}) => {
24
23
  return {
25
24
  mode: isDev ? 'development' : 'production',
26
25
  target: options.target ?? 'electron-renderer',
27
- entry: isDev ? [
28
- `webpack-dev-server/client?http://localhost:${options.port}/`,
29
- 'webpack/hot/dev-server',
30
- path.resolve(options.src, 'main.ts')
31
- ] : path.resolve(options.src, 'main.ts'),
26
+ entry: isDev
27
+ ? [
28
+ `webpack-dev-server/client?http://localhost:${options.port}/`,
29
+ 'webpack/hot/dev-server',
30
+ path.resolve(options.src, 'main.ts'),
31
+ ]
32
+ : path.resolve(options.src, 'main.ts'),
32
33
  output: {
33
34
  path: buildPath,
34
35
  filename: '[name].js',
35
- publicPath: isDev ? '/' : './'
36
+ publicPath: isDev ? '/' : './',
36
37
  },
37
38
  performance: {
38
39
  maxAssetSize: 2000000, //2MB
39
40
  maxEntrypointSize: 2000000,
40
- hints: isDev ? false : 'warning'
41
+ hints: isDev ? false : 'warning',
41
42
  },
42
43
  externals: {
43
44
  electron: 'commonjs electron',
@@ -46,7 +47,7 @@ export default (env = {}, argv = {}) => {
46
47
  'terser-webpack-plugin': 'commonjs terser-webpack-plugin',
47
48
  esbuild: 'commonjs esbuild',
48
49
  '@swc/core': 'commonjs @swc/core',
49
- '@swc/wasm': 'commonjs @swc/wasm'
50
+ '@swc/wasm': 'commonjs @swc/wasm',
50
51
  },
51
52
  resolve: {
52
53
  extensions: ['.tsx', '.ts', '.js', '.jsx', '.mjs'],
@@ -54,9 +55,9 @@ export default (env = {}, argv = {}) => {
54
55
  fullySpecified: false,
55
56
  fallback: {
56
57
  process: require.resolve('process/browser.js'),
57
- global: require.resolve('global')
58
+ global: require.resolve('global'),
58
59
  },
59
- modules: ['node_modules', 'src', 'static']
60
+ modules: ['node_modules', 'src', 'static'],
60
61
  },
61
62
  module: {
62
63
  rules: [
@@ -66,25 +67,25 @@ export default (env = {}, argv = {}) => {
66
67
  use: {
67
68
  loader: 'ts-loader',
68
69
  options: {
69
- transpileOnly: true
70
- }
71
- }
70
+ transpileOnly: true,
71
+ },
72
+ },
72
73
  },
73
74
  {
74
75
  test: /\.s[ac]ss$/,
75
- use: ['style-loader', 'css-loader', 'sass-loader']
76
+ use: ['style-loader', 'css-loader', 'sass-loader'],
76
77
  },
77
78
  {
78
79
  test: /\.css$/,
79
80
  use: ['style-loader', 'css-loader'],
80
- exclude: /node_modules/
81
+ exclude: /node_modules/,
81
82
  },
82
83
  {
83
84
  test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|mp4)$/,
84
85
  type: 'asset/resource',
85
86
  generator: {
86
- filename: '[name][ext]'
87
- }
87
+ filename: '[name][ext]',
88
+ },
88
89
  },
89
90
  {
90
91
  test: /\.html$/,
@@ -92,32 +93,34 @@ export default (env = {}, argv = {}) => {
92
93
  loader: 'html-loader',
93
94
  options: {
94
95
  sources: false,
95
- }
96
- }
97
- }
98
- ]
96
+ },
97
+ },
98
+ },
99
+ ],
99
100
  },
100
101
  plugins: [
101
102
  new webpack.DefinePlugin({
102
- global: 'globalThis'
103
+ global: 'globalThis',
104
+ // env variables
105
+ 'process.env.AQI_TOKEN': JSON.stringify(process.env.AQI_TOKEN || ''),
103
106
  }),
104
107
  new webpack.ProvidePlugin({
105
- process: 'process/browser.js'
108
+ process: 'process/browser.js',
106
109
  }),
107
110
  new CleanWebpackPlugin(),
108
111
  new HtmlWebpackPlugin({
109
112
  template: controllerHtmlPath,
110
113
  filename: 'index.html',
111
114
  inject: 'body',
112
- chunks: ['main']
115
+ chunks: ['main'],
113
116
  }),
114
117
  new CopyWebpackPlugin({
115
118
  patterns: [
116
119
  { from: controllerStaticPath, to: 'static', noErrorOnMissing: true },
117
120
  { from: controllerFontsPath, to: 'fonts', noErrorOnMissing: true },
118
- { from: controllerTestPath, to: 'test', noErrorOnMissing: true }
119
- ]
120
- })
121
+ { from: controllerTestPath, to: 'test', noErrorOnMissing: true },
122
+ ],
123
+ }),
121
124
  ],
122
125
  optimization: {
123
126
  minimize: !isDev,
@@ -128,31 +131,33 @@ export default (env = {}, argv = {}) => {
128
131
  ecma: 2020,
129
132
  compress: true,
130
133
  mangle: true,
131
- format: { comments: false }
132
- }
133
- })
134
- ]
134
+ format: { comments: false },
135
+ },
136
+ }),
137
+ ],
135
138
  },
136
139
  devtool: isDev ? 'source-map' : false,
137
- devServer: isDev ? {
138
- static: [
139
- {
140
- directory: path.resolve(options.src, 'test'),
141
- publicPath: '/test',
142
- watch: true,
143
- }
144
- ],
145
- open: false,
146
- client: {
147
- overlay: true
148
- },
149
- port: options.port || 8080,
150
- hot: true,
151
- historyApiFallback: true,
152
- devMiddleware: {
153
- publicPath: '/',
154
- writeToDisk: false
140
+ devServer: isDev
141
+ ? {
142
+ static: [
143
+ {
144
+ directory: path.resolve(options.src, 'test'),
145
+ publicPath: '/test',
146
+ watch: true,
147
+ },
148
+ ],
149
+ open: false,
150
+ client: {
151
+ overlay: true,
152
+ },
153
+ port: options.port || 8080,
154
+ hot: true,
155
+ historyApiFallback: true,
156
+ devMiddleware: {
157
+ publicPath: '/',
158
+ writeToDisk: false,
159
+ },
155
160
  }
156
- } : undefined
161
+ : undefined,
157
162
  };
158
163
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vixoniccom/module-packager",
3
- "version": "2.13.0-test.0",
3
+ "version": "2.13.0-test.1",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "bin": {