arui-scripts 14.1.0 → 14.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [14.1.1](https://github.com/core-ds/arui-scripts/compare/v14.1.0...v14.1.1) (2023-04-02)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **webpack-server:** use dev plugins only in dev mode ([e04b27d](https://github.com/core-ds/arui-scripts/commit/e04b27d6efb7ba3169f8e010ac1ad75fb7a3c8f3))
7
+
1
8
  # [14.1.0](https://github.com/core-ds/arui-scripts/compare/v14.0.0...v14.1.0) (2023-04-02)
2
9
 
3
10
 
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
3
3
  * @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
4
+ * @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
4
5
  * @returns {*}
5
6
  */
6
- declare function getEntry(entryPoint: string | string[] | Record<string, string | string[]>, getSingleEntry: (entry: string[]) => string[]): string[] | Record<string, string | string[]>;
7
+ declare function getEntry<AdditionalArgs extends unknown[]>(entryPoint: string | string[] | Record<string, string | string[]>, getSingleEntry: (entry: string[], ...args: AdditionalArgs) => string[], ...args: AdditionalArgs): string[] | Record<string, string | string[]>;
7
8
  export default getEntry;
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
4
  * @param {string|string[]|object} entryPoint Строка, массив строк или объект с энтрипоинтами
5
5
  * @param {Function} getSingleEntry Функция, возвращающая конфигурацию для одного entryPoint
6
+ * @param args Дополнительные аргументы, которые будут переданы в getSingleEntry функцию
6
7
  * @returns {*}
7
8
  */
8
- function getEntry(entryPoint, getSingleEntry) {
9
+ function getEntry(entryPoint, getSingleEntry, ...args) {
9
10
  if (typeof entryPoint === 'string') {
10
- return getSingleEntry([entryPoint]);
11
+ return getSingleEntry([entryPoint], ...args);
11
12
  }
12
13
  if (Array.isArray(entryPoint)) {
13
- return getSingleEntry(entryPoint);
14
+ return getSingleEntry(entryPoint, ...args);
14
15
  }
15
16
  // client entry also can be an object, so we must add hot loader to each entry point
16
17
  return Object.keys(entryPoint).reduce((result, entryPointName) => {
17
- const entry = getEntry(entryPoint[entryPointName], getSingleEntry);
18
+ const entry = getEntry(entryPoint[entryPointName], getSingleEntry, ...args);
18
19
  return Object.assign(Object.assign({}, result), { [entryPointName]: entry });
19
20
  }, {});
20
21
  }
@@ -0,0 +1,2 @@
1
+ import { Configuration } from 'webpack';
2
+ export declare const createClientWebpackConfig: (mode: 'dev' | 'prod') => Configuration;
@@ -1,3 +1,2 @@
1
- import webpack from 'webpack';
2
- declare const webpackClientDev: webpack.Configuration;
3
- export default webpackClientDev;
1
+ declare const config: import("webpack").Configuration;
2
+ export default config;
@@ -3,297 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
7
- const webpack_1 = __importDefault(require("webpack"));
8
- const case_sensitive_paths_webpack_plugin_1 = __importDefault(require("case-sensitive-paths-webpack-plugin"));
9
- const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
10
- const assets_webpack_plugin_1 = __importDefault(require("assets-webpack-plugin"));
11
- const tsconfig_paths_webpack_plugin_1 = __importDefault(require("tsconfig-paths-webpack-plugin"));
12
- const getCSSModuleLocalIdent_1 = __importDefault(require("react-dev-utils/getCSSModuleLocalIdent"));
13
- const PnpWebpackPlugin = require('pnp-webpack-plugin');
14
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
15
- const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
16
- const ReactRefreshTypeScript = require('react-refresh-typescript');
17
- const app_configs_1 = __importDefault(require("./app-configs"));
18
- const babel_client_1 = __importDefault(require("./babel-client"));
19
- const babel_dependencies_1 = require("./babel-dependencies");
20
- const postcss_1 = __importDefault(require("./postcss"));
21
6
  const apply_overrides_1 = __importDefault(require("./util/apply-overrides"));
22
- const get_entry_1 = __importDefault(require("./util/get-entry"));
23
- // style files regexes
24
- const cssRegex = /\.css$/;
25
- const cssModuleRegex = /\.module\.css$/;
26
- function getSingleEntry(clientEntry) {
27
- return [
28
- ...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
29
- require.resolve('webpack/hot/dev-server'),
30
- // Finally, this is your app's code:
31
- ...clientEntry,
32
- // We include the app code last so that if there is a runtime error during
33
- // initialization, it doesn't blow up the WebpackDevServer client, and
34
- // changing JS code would still trigger a refresh.
35
- ].filter(Boolean);
36
- }
37
- // This is the development configuration.
38
- // It is focused on developer experience and fast rebuilds.
39
- // The production configuration is different and lives in a separate file.
40
- const webpackClientDev = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], {
41
- target: 'web',
42
- mode: 'development',
43
- devtool: app_configs_1.default.devSourceMaps,
44
- // These are the "entry points" to our application.
45
- // This means they will be the "root" imports that are included in JS bundle.
46
- entry: (0, get_entry_1.default)(app_configs_1.default.clientEntry, getSingleEntry),
47
- context: app_configs_1.default.cwd,
48
- output: {
49
- // Add /* filename */ comments to generated require()s in the output.
50
- pathinfo: true,
51
- path: app_configs_1.default.clientOutputPath,
52
- publicPath: app_configs_1.default.publicPath,
53
- filename: '[name].js',
54
- chunkFilename: '[name].js',
55
- // Point sourcemap entries to original disk location (format as URL on Windows)
56
- devtoolModuleFilenameTemplate: (info) => path_1.default
57
- .relative(app_configs_1.default.appSrc, info.absoluteResourcePath)
58
- .replace(/\\/g, '/'),
59
- },
60
- resolve: {
61
- // This allows you to set a fallback for where Webpack should look for modules.
62
- // We placed these paths second because we want `node_modules` to "win"
63
- // if there are any conflicts. This matches Node resolution mechanism.
64
- // https://github.com/facebookincubator/create-react-app/issues/253
65
- modules: ['node_modules', app_configs_1.default.appNodeModules],
66
- // These are the reasonable defaults supported by the Node ecosystem.
67
- // We also include JSX as a common component filename extension to support
68
- // some tools, although we do not recommend using it, see:
69
- // https://github.com/facebookincubator/create-react-app/issues/290
70
- // `web` extension prefixes have been added for better support
71
- // for React Native Web.
72
- extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx'],
73
- plugins: ([
74
- (app_configs_1.default.tsconfig && new tsconfig_paths_webpack_plugin_1.default({
75
- configFile: app_configs_1.default.tsconfig,
76
- extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx', '.ts', '.tsx']
77
- }))
78
- ].filter(Boolean)),
79
- },
80
- resolveLoader: {
81
- plugins: [
82
- PnpWebpackPlugin.moduleLoader(module),
83
- ],
84
- },
85
- cache: {
86
- type: 'filesystem',
87
- buildDependencies: {
88
- config: [__filename],
89
- },
90
- },
91
- module: {
92
- // typescript interface will be removed from modules, and we will get an error on correct code
93
- // see https://github.com/webpack/webpack/issues/7378
94
- strictExportPresence: !app_configs_1.default.tsconfig,
95
- rules: [
96
- {
97
- // "oneOf" will traverse all following loaders until one will
98
- // match the requirements. When no loader matches it will fall
99
- // back to the "file" loader at the end of the loader list.
100
- oneOf: ([
101
- {
102
- test: [/\.svg$/],
103
- loader: require.resolve('svg-url-loader'),
104
- options: {
105
- limit: 10000,
106
- iesafe: true,
107
- name: '[name].[hash:8].[ext]',
108
- },
109
- },
110
- // "url" loader works like "file" loader except that it embeds assets
111
- // smaller than specified limit in bytes as data URLs to avoid requests.
112
- // A missing `test` is equivalent to a match.
113
- {
114
- test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
115
- loader: require.resolve('url-loader'),
116
- options: {
117
- limit: 10000,
118
- name: '[name].[hash:8].[ext]',
119
- },
120
- },
121
- // Process JS with Babel.
122
- {
123
- test: app_configs_1.default.useTscLoader ? /\.(js|jsx|mjs|cjs)$/ : /\.(js|jsx|mjs|ts|tsx|cjs)$/,
124
- include: app_configs_1.default.appSrc,
125
- use: [
126
- {
127
- loader: require.resolve('babel-loader'),
128
- options: Object.assign({
129
- // This is a feature of `babel-loader` for webpack (not Babel itself).
130
- // It enables caching results in ./node_modules/.cache/babel-loader/
131
- // directory for faster rebuilds.
132
- cacheDirectory: true,
133
- plugins: require.resolve('react-refresh/babel')
134
- }, babel_client_1.default)
135
- }
136
- ]
137
- },
138
- (app_configs_1.default.tsconfig && app_configs_1.default.useTscLoader) && {
139
- test: /\.tsx?$/,
140
- use: [
141
- {
142
- loader: require.resolve('babel-loader'),
143
- options: Object.assign({
144
- // This is a feature of `babel-loader` for webpack (not Babel itself).
145
- // It enables caching results in ./node_modules/.cache/babel-loader/
146
- // directory for faster rebuilds.
147
- cacheDirectory: true,
148
- cacheCompression: false,
149
- plugins: require.resolve('react-refresh/babel')
150
- }, babel_client_1.default)
151
- },
152
- {
153
- loader: require.resolve('ts-loader'),
154
- options: {
155
- getCustomTransformers: () => ({
156
- before: [ReactRefreshTypeScript()],
157
- }),
158
- onlyCompileBundledFiles: true,
159
- transpileOnly: true,
160
- happyPackMode: true,
161
- configFile: app_configs_1.default.tsconfig
162
- }
163
- }
164
- ]
165
- },
166
- // Process any JS outside of the app with Babel.
167
- // Unlike the application JS, we only compile the standard ES features.
168
- {
169
- test: /\.(js|mjs)$/,
170
- exclude: /@babel(?:\/|\\{1,2})runtime/,
171
- loader: require.resolve('babel-loader'),
172
- options: Object.assign(Object.assign({}, babel_dependencies_1.babelDependencies), { babelrc: false, configFile: false, compact: false, cacheDirectory: true, cacheCompression: false }),
173
- },
174
- // "postcss" loader applies autoprefixer to our CSS.
175
- // "css" loader resolves paths in CSS and adds assets as dependencies.
176
- // "style" loader turns CSS into JS modules that inject <style> tags.
177
- // In production, we use a plugin to extract that CSS to a file, but
178
- // in development "style" loader enables hot editing of CSS.
179
- {
180
- test: cssRegex,
181
- exclude: cssModuleRegex,
182
- use: [
183
- {
184
- loader: MiniCssExtractPlugin.loader,
185
- options: {
186
- publicPath: './',
187
- },
188
- },
189
- {
190
- loader: require.resolve('css-loader'),
191
- options: {
192
- importLoaders: 1,
193
- },
194
- },
195
- {
196
- loader: require.resolve('postcss-loader'),
197
- options: {
198
- // Necessary for external CSS imports to work
199
- // https://github.com/facebookincubator/create-react-app/issues/2677
200
- ident: 'postcss',
201
- plugins: () => postcss_1.default,
202
- },
203
- },
204
- ],
205
- },
206
- {
207
- test: cssModuleRegex,
208
- use: [
209
- {
210
- loader: MiniCssExtractPlugin.loader,
211
- options: {
212
- publicPath: './',
213
- },
214
- },
215
- {
216
- loader: require.resolve('css-loader'),
217
- options: {
218
- importLoaders: 1,
219
- modules: {
220
- getLocalIdent: getCSSModuleLocalIdent_1.default
221
- },
222
- },
223
- },
224
- {
225
- loader: require.resolve('postcss-loader'),
226
- options: {
227
- // Necessary for external CSS imports to work
228
- // https://github.com/facebookincubator/create-react-app/issues/2677
229
- ident: 'postcss',
230
- plugins: () => postcss_1.default,
231
- },
232
- },
233
- ],
234
- },
235
- // "file" loader makes sure those assets get served by WebpackDevServer.
236
- // When you `import` an asset, you get its (virtual) filename.
237
- // In production, they would get copied to the `build` folder.
238
- // This loader doesn't use a "test" so it will catch all modules
239
- // that fall through the other loaders.
240
- {
241
- // Exclude `js` files to keep "css" loader working as it injects
242
- // its runtime that would otherwise processed through "file" loader.
243
- // Also exclude `html` and `json` extensions so they get processed
244
- // by webpacks internal loaders.
245
- exclude: [/\.(js|jsx|mjs|ts|tsx)$/, /\.(html|ejs)$/, /\.json$/],
246
- loader: require.resolve('file-loader'),
247
- options: {
248
- name: 'static/media/[name].[hash:8].[ext]',
249
- },
250
- },
251
- ].filter(Boolean)),
252
- },
253
- // ** STOP ** Are you adding a new loader?
254
- // Make sure to add the new loader(s) before the "file" loader.
255
- ],
256
- },
257
- plugins: ([
258
- new assets_webpack_plugin_1.default({ path: app_configs_1.default.serverOutputPath }),
259
- new webpack_1.default.DefinePlugin({
260
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
261
- // Tell Webpack to provide empty mocks for process.env.
262
- 'process.env': '{}'
263
- }),
264
- new ReactRefreshWebpackPlugin({
265
- overlay: {
266
- sockIntegration: 'whm',
267
- },
268
- }),
269
- // Watcher doesn't work well if you mistype casing in a path so we use
270
- // a plugin that prints an error when you attempt to do this.
271
- // See https://github.com/facebookincubator/create-react-app/issues/240
272
- new case_sensitive_paths_webpack_plugin_1.default(),
273
- app_configs_1.default.tsconfig !== null && new fork_ts_checker_webpack_plugin_1.default(),
274
- new MiniCssExtractPlugin(),
275
- ].filter(Boolean)),
276
- // Turn off performance hints during development because we don't do any
277
- // splitting or minification in interest of speed. These warnings become
278
- // cumbersome.
279
- performance: {
280
- hints: false,
281
- },
282
- optimization: {
283
- minimize: false,
284
- nodeEnv: false,
285
- // Оптимизации времени билда, см https://webpack.js.org/guides/build-performance/
286
- removeAvailableModules: false,
287
- removeEmptyChunks: false,
288
- splitChunks: false
289
- },
290
- experiments: {
291
- backCompat: app_configs_1.default.webpack4Compatibility,
292
- },
293
- // Без этого комиляция трирегилась на изменение в node_modules и приводила к утечке памяти
294
- watchOptions: {
295
- ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
296
- aggregateTimeout: 100,
297
- }
298
- });
299
- exports.default = webpackClientDev;
7
+ const webpack_client_1 = require("./webpack.client");
8
+ const config = (0, apply_overrides_1.default)(['webpack', 'webpackClient', 'webpackDev', 'webpackClientDev'], (0, webpack_client_1.createClientWebpackConfig)('dev'));
9
+ exports.default = config;