arui-scripts 19.0.0 → 19.0.2

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.
@@ -5,19 +5,19 @@ ts-jest[versions] (WARN) Version 29.7.0 of jest installed has not been tested wi
5
5
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
6
6
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
7
7
  ts-jest[versions] (WARN) Version 5.6.3 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=4.3.0 <5.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions.
8
- PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (26.447 s)
8
+ PASS src/configs/app-configs/__tests__/update-with-presets.tests.ts (26.411 s)
9
9
  PASS src/configs/util/__tests__/get-polyfills.tests.ts
10
+ PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (26.868 s)
10
11
  PASS src/configs/util/__tests__/apply-overrides.tests.ts
11
- PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
12
- PASS src/plugins/postcss-global-variables/utils/__tests__/add-global-variable.tests.ts (27.198 s)
13
12
  PASS src/configs/app-configs/__tests__/update-with-package.tests.ts
14
- PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
13
+ PASS src/configs/app-configs/__tests__/update-with-env.tests.ts
15
14
  PASS src/plugins/postcss-global-variables/utils/__tests__/parse-variables.tests.ts
15
+ PASS src/configs/app-configs/__tests__/validate-settings-keys.tests.ts
16
16
  PASS src/plugins/postcss-global-variables/utils/__tests__/get-media-query-name.tests.ts
17
- PASS src/configs/util/__tests__/find-plugin.tests.ts (28.961 s)
17
+ PASS src/configs/util/__tests__/find-plugin.tests.ts (29.062 s)
18
18
 
19
19
  Test Suites: 10 passed, 10 total
20
20
  Tests: 26 passed, 26 total
21
21
  Snapshots: 0 total
22
- Time: 30.115 s
22
+ Time: 29.89 s
23
23
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # [15.3.0](https://github.com/core-ds/arui-scripts/compare/v15.2.0...v15.3.0) (2023-06-30)
2
2
 
3
+ ## 19.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#304](https://github.com/core-ds/arui-scripts/pull/304) [`f97f2ba`](https://github.com/core-ds/arui-scripts/commit/f97f2ba9fd22473e2a3725dfc3699c6b0577ed15) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Исправлена проблема с загрузкой WMF модулей в prod сборке
8
+
9
+ ## 19.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#303](https://github.com/core-ds/arui-scripts/pull/303) [`342c717`](https://github.com/core-ds/arui-scripts/commit/342c7171017056214e0ecc3cd7c866f7cce64e88) Thanks [@Echzio](https://github.com/Echzio)! - исправление парсинга postcss, в котором неправильно парсились @media
14
+
15
+ - [#301](https://github.com/core-ds/arui-scripts/pull/301) [`77bbf31`](https://github.com/core-ds/arui-scripts/commit/77bbf3108257192d056ebf779bc737800b60375c) Thanks [@heymdall-legal](https://github.com/heymdall-legal)! - Исправлена проблема при обработке маленьких svg (меньше, чем [config.dataUrlMaxSize](https://github.com/core-ds/arui-scripts/blob/master/packages/arui-scripts/docs/settings.md#dataurlmaxsize)): теперь они корректно преобразуются в data-url
16
+
3
17
  ## 19.0.0
4
18
 
5
19
  ### Major Changes
@@ -22,9 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.MODULES_ENTRY_NAME = void 0;
30
27
  exports.haveExposedDefaultModules = haveExposedDefaultModules;
@@ -36,32 +33,38 @@ exports.patchWebpackConfigForCompat = patchWebpackConfigForCompat;
36
33
  /* eslint-disable no-param-reassign */
37
34
  const rspack = __importStar(require("@rspack/core"));
38
35
  const postcss_prefix_selector_1 = require("../plugins/postcss-prefix-selector");
36
+ const turn_off_split_remote_entry_1 = require("../plugins/turn-off-split-remote-entry");
39
37
  const find_loader_1 = require("./util/find-loader");
40
- const app_configs_1 = __importDefault(require("./app-configs"));
38
+ const app_configs_1 = require("./app-configs");
41
39
  function haveExposedDefaultModules() {
42
40
  var _a;
43
- return (_a = app_configs_1.default.modules) === null || _a === void 0 ? void 0 : _a.exposes;
41
+ return (_a = app_configs_1.configs.modules) === null || _a === void 0 ? void 0 : _a.exposes;
44
42
  }
45
43
  exports.MODULES_ENTRY_NAME = 'remoteEntry.js';
46
44
  function patchMainWebpackConfigForModules(webpackConf) {
45
+ var _a;
46
+ if (!((_a = webpackConf.module) === null || _a === void 0 ? void 0 : _a.rules) || !webpackConf.plugins) {
47
+ // делаем TS счастливым, на самом деле module и plugins у нас будут всегда
48
+ return webpackConf;
49
+ }
47
50
  // Добавляем expose loader для библиотек, которые мы хотим вынести в глобальную область видимости
48
51
  webpackConf.module.rules.unshift(...getExposeLoadersFormCompatModules());
49
- if (!app_configs_1.default.modules || !webpackConf.output || !webpackConf.plugins) {
52
+ if (!app_configs_1.configs.modules || !webpackConf.output || !webpackConf.plugins) {
50
53
  return webpackConf;
51
54
  }
52
- const { cssPrefix } = app_configs_1.default.modules.options || {};
55
+ const { cssPrefix } = app_configs_1.configs.modules.options || {};
53
56
  if (cssPrefix) {
54
57
  addCssPrefix(webpackConf, cssPrefix);
55
58
  }
56
59
  webpackConf.output.publicPath = haveExposedDefaultModules()
57
60
  ? 'auto' // Для того чтобы модули могли подключаться из разных мест, нам необходимо использовать auto. Для корректной работы в IE надо подключaть https://github.com/amiller-gh/currentScript-polyfill
58
- : app_configs_1.default.publicPath;
61
+ : app_configs_1.configs.publicPath;
59
62
  webpackConf.plugins.push(new rspack.container.ModuleFederationPlugin({
60
- name: app_configs_1.default.modules.name || app_configs_1.default.normalizedName,
61
- filename: app_configs_1.default.modules.exposes ? exports.MODULES_ENTRY_NAME : undefined,
62
- shared: app_configs_1.default.modules.shared,
63
- exposes: app_configs_1.default.modules.exposes,
64
- }));
63
+ name: app_configs_1.configs.modules.name || app_configs_1.configs.normalizedName,
64
+ filename: app_configs_1.configs.modules.exposes ? exports.MODULES_ENTRY_NAME : undefined,
65
+ shared: app_configs_1.configs.modules.shared,
66
+ exposes: app_configs_1.configs.modules.exposes,
67
+ }), new turn_off_split_remote_entry_1.TurnOffSplitRemoteEntry(app_configs_1.configs.modules.name || app_configs_1.configs.normalizedName));
65
68
  return webpackConf;
66
69
  }
67
70
  function getCssPrefixForModule(module) {
@@ -75,7 +78,7 @@ function getCssPrefixForModule(module) {
75
78
  }
76
79
  function getExposeLoadersFormCompatModules() {
77
80
  var _a;
78
- const shared = (_a = app_configs_1.default.compatModules) === null || _a === void 0 ? void 0 : _a.shared;
81
+ const shared = (_a = app_configs_1.configs.compatModules) === null || _a === void 0 ? void 0 : _a.shared;
79
82
  if (!shared) {
80
83
  return [];
81
84
  }
@@ -260,7 +260,7 @@ const createSingleClientWebpackConfig = (mode, entry, configName) => (Object.ass
260
260
  test: /\.svg/,
261
261
  type: 'asset',
262
262
  generator: {
263
- dataUrl: (content) => (0, mini_svg_data_uri_1.default)(content.toString()),
263
+ dataUrl: (file) => (0, mini_svg_data_uri_1.default)(file.content.toString()),
264
264
  },
265
265
  parser: {
266
266
  dataUrlCondition: {
@@ -9,6 +9,8 @@ exports.addGlobalVariable = addGlobalVariable;
9
9
  const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const postcss_1 = require("postcss");
12
+ // eslint-disable-next-line import/no-extraneous-dependencies
13
+ const postcss_media_query_parser_1 = __importDefault(require("postcss-media-query-parser"));
12
14
  const getMediaQueryName = (rule) => rule.params.split(' ')[0];
13
15
  exports.getMediaQueryName = getMediaQueryName;
14
16
  function parseImport(root, postcssHelpers, filePath) {
@@ -64,13 +66,25 @@ const insertParsedCss = (root, parsedVariables, parsedCustomMedia) => {
64
66
  addGlobalVariable(decl.value, rootRule, parsedVariables);
65
67
  });
66
68
  root.walkAtRules('media', (rule) => {
67
- const mediaFullName = (0, exports.getMediaQueryName)(rule);
68
- if (mediaFullName.startsWith('(--')) {
69
- const mediaName = mediaFullName.slice(1, -1);
70
- if (parsedCustomMedia[mediaName]) {
71
- root.append(parsedCustomMedia[mediaName]);
69
+ var _a;
70
+ // парсим параметры
71
+ const mediaParsed = (0, postcss_media_query_parser_1.default)(rule.params);
72
+ // регулярка для (--desktop), (--mobile), (--desktop-m) и тд
73
+ const parseRule = /--\w+-?\w+/gi;
74
+ (_a = mediaParsed.nodes) === null || _a === void 0 ? void 0 : _a.forEach(({ value }) => {
75
+ // value приходит в виде (--desktop); not screen and (--mobile) и тд
76
+ if (parseRule.test(value)) {
77
+ // берем все вхождения --desktop, --mobile
78
+ const mediaName = value.match(parseRule);
79
+ // итерируемся по [--desktop, --mobile]
80
+ mediaName === null || mediaName === void 0 ? void 0 : mediaName.forEach((rule) => {
81
+ // подставляем значения если у нас есть под это custom-media
82
+ if (parsedCustomMedia[rule]) {
83
+ root.append(parsedCustomMedia[rule]);
84
+ }
85
+ });
72
86
  }
73
- }
87
+ });
74
88
  });
75
89
  return rootRule;
76
90
  };
@@ -0,0 +1,11 @@
1
+ import { Compiler, RspackPluginInstance } from '@rspack/core';
2
+ /**
3
+ * Force remote entry not be affected by user's chunkSplit strategy,
4
+ * Otherwise, the remote chunk will not be loaded correctly.
5
+ * @see https://github.com/web-infra-dev/rsbuild/discussions/1461#discussioncomment-8329790
6
+ */
7
+ export declare class TurnOffSplitRemoteEntry implements RspackPluginInstance {
8
+ name: string;
9
+ constructor(wmfContainerName: string);
10
+ apply(compiler: Compiler): void;
11
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TurnOffSplitRemoteEntry = void 0;
4
+ const util_1 = require("util");
5
+ /**
6
+ * Force remote entry not be affected by user's chunkSplit strategy,
7
+ * Otherwise, the remote chunk will not be loaded correctly.
8
+ * @see https://github.com/web-infra-dev/rsbuild/discussions/1461#discussioncomment-8329790
9
+ */
10
+ class TurnOffSplitRemoteEntry {
11
+ constructor(wmfContainerName) {
12
+ this.name = wmfContainerName;
13
+ }
14
+ apply(compiler) {
15
+ const { splitChunks } = compiler.options.optimization;
16
+ if (!splitChunks) {
17
+ return;
18
+ }
19
+ /* eslint-disable no-param-reassign */
20
+ const applyPatch = (cacheGroup) => {
21
+ if (typeof cacheGroup !== 'object' || util_1.types.isRegExp(cacheGroup)) {
22
+ return;
23
+ }
24
+ // cacheGroup.chunks will inherit splitChunks.chunks
25
+ // so we only need to modify the chunks that are set separately.
26
+ const { chunks } = cacheGroup;
27
+ if (!chunks || chunks === 'async') {
28
+ return;
29
+ }
30
+ if (typeof chunks === 'function') {
31
+ const prevChunks = chunks;
32
+ cacheGroup.chunks = (chunk) => {
33
+ if (chunk.name && chunk.name === this.name) {
34
+ return false;
35
+ }
36
+ return prevChunks(chunk);
37
+ };
38
+ return;
39
+ }
40
+ if (chunks === 'all') {
41
+ cacheGroup.chunks = (chunk) => {
42
+ if (chunk.name && chunk.name === this.name) {
43
+ return false;
44
+ }
45
+ return true;
46
+ };
47
+ return;
48
+ }
49
+ if (chunks === 'initial') {
50
+ cacheGroup.chunks = (chunk) => {
51
+ if (chunk.name && chunk.name === this.name) {
52
+ return false;
53
+ }
54
+ return chunk.isOnlyInitial();
55
+ };
56
+ }
57
+ };
58
+ /* eslint-enable no-param-reassign */
59
+ // patch splitChunk.chunks
60
+ applyPatch(splitChunks);
61
+ const { cacheGroups } = splitChunks;
62
+ if (!cacheGroups) {
63
+ return;
64
+ }
65
+ // patch splitChunk.cacheGroups[key].chunks
66
+ for (const cacheGroupKey of Object.keys(cacheGroups)) {
67
+ applyPatch(cacheGroups[cacheGroupKey]);
68
+ }
69
+ }
70
+ }
71
+ exports.TurnOffSplitRemoteEntry = TurnOffSplitRemoteEntry;