Skip to content

Commit 2297706

Browse files
chore: create Assets.js for main package and adjust paths for i18n (#484)
1 parent ee1f314 commit 2297706

File tree

17 files changed

+51
-83
lines changed

17 files changed

+51
-83
lines changed

.storybook/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ module.exports = {
7575
config.resolve.alias = {
7676
...config.resolve.alias,
7777
'@shared': path.join(PATHS.root, 'shared'),
78-
'@ui5/webcomponents-react/assets': path.join(PATHS.root, 'packages', 'main', 'assets'),
79-
'@ui5/webcomponents-react/json-imports': path.join(PATHS.root, 'packages', 'main', 'json-imports'),
78+
'@ui5/webcomponents-react/dist': path.join(PATHS.root, 'packages', 'main', 'dist'),
8079
'@ui5/webcomponents-react': path.join(PATHS.root, 'packages', 'main', 'src'),
8180
'@ui5/webcomponents-react-charts': path.join(PATHS.root, 'packages', 'charts', 'src'),
8281
'@ui5/webcomponents-react-base/third-party': path.join(PATHS.root, 'packages', 'base', 'third-party'),

.storybook/preview.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ import { makeDecorator } from '@storybook/addons';
33
import { addDecorator, addParameters } from '@storybook/react';
44
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
55
import '@ui5/webcomponents-base/dist/features/browsersupport/IE11WithWebComponentsPolyfill';
6-
import '@ui5/webcomponents-fiori/dist/generated/json-imports/Themes';
6+
import '@ui5/webcomponents-fiori/dist/Assets';
77
import '@ui5/webcomponents-react-base/polyfill/IE11';
8-
import '@ui5/webcomponents-react/json-imports/i18n';
8+
import '@ui5/webcomponents-react/dist/Assets';
99
import { ContentDensity } from '@ui5/webcomponents-react/lib/ContentDensity';
1010
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider';
1111
import { Themes } from '@ui5/webcomponents-react/lib/Themes';
12-
import '@ui5/webcomponents-theme-base/dist/Assets';
12+
import '@ui5/webcomponents/dist/Assets';
1313
import '@ui5/webcomponents/dist/features/InputElementsFormSupport';
14-
import '@ui5/webcomponents/dist/generated/json-imports/i18n';
15-
import '@ui5/webcomponents/dist/generated/json-imports/Themes';
1614
import React, { useEffect } from 'react';
1715
import 'react-app-polyfill/ie11';
1816

config/jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module.exports = {
3232
transformIgnorePatterns: ['node_modules/(?!(@ui5|lit-html))'],
3333
moduleNameMapper: {
3434
'^@shared/(.*)$': '<rootDir>/shared/$1',
35-
'^@ui5/webcomponents-react/assets/(.*)$': '<rootDir>/packages/main/assets/$1',
36-
'^@ui5/webcomponents-react/json-imports/(.*)$': '<rootDir>/packages/main/json-imports/$1',
35+
'^@ui5/webcomponents-react/dist/(.*)$': '<rootDir>/packages/main/dist/$1',
3736
'^@ui5/webcomponents-react/(.*)$': '<rootDir>/packages/main/src/$1',
3837
'^@ui5/webcomponents-react-base/third-party/(.*)$': '<rootDir>/packages/base/third-party/$1',
3938
'^@ui5/webcomponents-react-base/(.*)$': '<rootDir>/packages/base/src/$1',

docs/MigrationGuide.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ UI5 Web Components and UI5 Web Components for React are both coming with the `sa
7676
In case you want to change your applications' theme, you have to import a couple of modules:
7777
```js
7878
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
79-
import '@ui5/webcomponents-theme-base/dist/Assets';
80-
import '@ui5/webcomponents/dist/generated/json-imports/Themes';
81-
import '@ui5/webcomponents-fiori/dist/generated/json-imports/Themes'; // only if you are using the ShellBar, Product Switch or UploadCollection
79+
import '@ui5/webcomponents/dist/Assets';
80+
import '@ui5/webcomponents-fiori/dist/Assets'; // only if you are using the ShellBar, Product Switch or UploadCollection
8281
```
8382

8483
Now you can call `setTheme` with a string parameter of the new theme.

docs/welcome/MigrationGuide.stories.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ UI5 Web Components and UI5 Web Components for React are both coming with the `sa
8181
In case you want to change your applications' theme, you have to import a couple of modules:
8282
```js
8383
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
84-
import '@ui5/webcomponents-theme-base/dist/Assets';
85-
import '@ui5/webcomponents/dist/generated/json-imports/Themes';
86-
import '@ui5/webcomponents-fiori/dist/generated/json-imports/Themes'; // only if you are using the ShellBar, Product Switch or UploadCollection
84+
import '@ui5/webcomponents/dist/Assets';
85+
import '@ui5/webcomponents-fiori/dist/Assets'; // only if you are using the ShellBar, Product Switch or UploadCollection
8786
```
8887

8988
Now you can call `setTheme` with a string parameter of the new theme.

docs/welcome/Welcome.stories.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ UI5 Web Components and UI5 Web Components for React are both coming with the `sa
8181
In case you want to change your applications' theme, you have to import a couple of modules:
8282
```js
8383
import { setTheme } from '@ui5/webcomponents-base/dist/config/Theme';
84-
import '@ui5/webcomponents-theme-base/dist/Assets';
85-
import '@ui5/webcomponents/dist/generated/json-imports/Themes';
86-
import '@ui5/webcomponents-fiori/dist/generated/json-imports/Themes'; // only if you are using the ShellBar or the Product Switch
84+
import '@ui5/webcomponents/dist/Assets';
85+
import '@ui5/webcomponents-fiori/dist/Assets'; // only if you are using the ShellBar, Product Switch or the Upload Collection
8786
```
8887

8988
You can now change the Theme by calling `setTheme` with a string parameter of the new theme.<br />

packages/main/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
/LICENSE
1111
/NOTICE.txt
1212
/scripts/wrapperGeneration/dist
13-
/assets
14-
/json-imports
13+
/dist

packages/main/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@
1616
"sideEffects": [
1717
"@ui5/webcomponents-icons/dist/icons/*",
1818
"@ui5/webcomponents/dist/*",
19-
"@ui5/webcomponents-fiori/dist/*"
19+
"@ui5/webcomponents-fiori/dist/*",
20+
"./dist/Assets.js",
21+
"./dist/json-imports/*"
2022
],
2123
"scripts": {
22-
"clean": "rimraf cjs components enums interfaces internal lib webComponents index.esm.js index.d.ts assets json-imports",
24+
"clean": "rimraf cjs components enums interfaces internal lib webComponents index.esm.js index.d.ts dist",
2325
"build": "npm-run-all -s build:i18n build:rollup",
2426
"build:rollup": "rollup -c rollup.config.js",
25-
"build:i18n": "npm-run-all -s build:i18n-bundles build:i18n-default build:i18n-imports",
26-
"build:i18n-bundles": "mkdirp assets/i18n && node ../../node_modules/@ui5/webcomponents-tools/lib/i18n/toJSON.js src/i18n assets/i18n",
27-
"build:i18n-default": "mkdirp assets/i18n && node ../../node_modules/@ui5/webcomponents-tools/lib/i18n/defaults.js src/i18n assets/i18n && tsc assets/i18n/i18n-defaults.js --allowJs --declaration --emitDeclarationOnly --declarationDir assets/i18n",
28-
"build:i18n-imports": "mkdirp json-imports && node ../../scripts/generate-json-imports/i18n.js"
27+
"build:i18n": "npm-run-all -s build:i18n-bundles build:i18n-default build:i18n-imports build:assets",
28+
"build:i18n-bundles": "mkdirp dist/assets/i18n && node ../../node_modules/@ui5/webcomponents-tools/lib/i18n/toJSON.js src/i18n dist/assets/i18n",
29+
"build:i18n-default": "node ../../node_modules/@ui5/webcomponents-tools/lib/i18n/defaults.js src/i18n dist/assets/i18n && tsc dist/assets/i18n/i18n-defaults.js --allowJs --declaration --emitDeclarationOnly --declarationDir dist/assets/i18n",
30+
"build:i18n-imports": "mkdirp dist/json-imports && node ../../node_modules/@ui5/webcomponents-tools/lib/generate-json-imports/i18n.js dist/assets/i18n dist/json-imports/",
31+
"build:assets": "node ../../scripts/generate-assets/index.js"
2932
},
3033
"dependencies": {
3134
"@babel/runtime": "7.9.0",

packages/main/src/components/AnalyticalCardHeader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createC
22
import { useI18nBundle, usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/hooks';
33
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
44
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/lib/Utils';
5-
import { DEVIATION, TARGET } from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
5+
import { DEVIATION, TARGET } from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
66
import { DeviationIndicator } from '@ui5/webcomponents-react/lib/DeviationIndicator';
77
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
88
import { FlexBoxAlignItems } from '@ui5/webcomponents-react/lib/FlexBoxAlignItems';

packages/main/src/components/AnalyticalTable/ColumnHeader/ColumnHeaderModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
SORT_ASCENDING,
99
SORT_DESCENDING,
1010
UNGROUP
11-
} from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
11+
} from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
1212
import { FlexBox } from '@ui5/webcomponents-react/lib/FlexBox';
1313
import { FlexBoxAlignItems } from '@ui5/webcomponents-react/lib/FlexBoxAlignItems';
1414
import { Icon } from '@ui5/webcomponents-react/lib/Icon';

packages/main/src/components/Loader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createC
22
import { useI18nBundle } from '@ui5/webcomponents-react-base/lib/hooks';
33
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
44
import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
5-
import { PLEASE_WAIT } from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
5+
import { PLEASE_WAIT } from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
66
import { LoaderType } from '@ui5/webcomponents-react/lib/LoaderType';
77
import React, { CSSProperties, FC, forwardRef, RefObject, useEffect, useMemo, useState } from 'react';
88
import { CommonProps } from '../../interfaces/CommonProps';

packages/main/src/components/MessageBox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
YES,
2525
SUCCESS,
2626
WARNING
27-
} from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
27+
} from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
2828
import { Button } from '@ui5/webcomponents-react/lib/Button';
2929
import { ButtonDesign } from '@ui5/webcomponents-react/lib/ButtonDesign';
3030
import { Dialog } from '@ui5/webcomponents-react/lib/Dialog';

packages/main/src/components/Notification/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createC
66
import { useI18nBundle } from '@ui5/webcomponents-react-base/lib/hooks';
77
import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
88
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/lib/Utils';
9-
import { COLLAPSE_GROUP, EXPAND_GROUP, SHOW_LESS, SHOW_MORE } from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
9+
import {
10+
COLLAPSE_GROUP,
11+
EXPAND_GROUP,
12+
SHOW_LESS,
13+
SHOW_MORE
14+
} from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
1015
import { Avatar } from '@ui5/webcomponents-react/lib/Avatar';
1116
import { AvatarShape } from '@ui5/webcomponents-react/lib/AvatarShape';
1217
import { AvatarSize } from '@ui5/webcomponents-react/lib/AvatarSize';

packages/main/src/components/Spinner/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createComponentStyles } from '@ui5/webcomponents-react-base/lib/createC
22
import { useI18nBundle } from '@ui5/webcomponents-react-base/lib/hooks';
33
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
44
import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
5-
import { PLEASE_WAIT } from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
5+
import { PLEASE_WAIT } from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
66
import { Size } from '@ui5/webcomponents-react/lib/Size';
77
import React, { FC, forwardRef, RefObject, useEffect, useState } from 'react';
88
import { CommonProps } from '../../interfaces/CommonProps';

packages/main/src/components/VariantManagement/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHe
55
import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingParameters';
66
import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
77
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/lib/Utils';
8-
import { CANCEL } from '@ui5/webcomponents-react/assets/i18n/i18n-defaults';
8+
import { CANCEL } from '@ui5/webcomponents-react/dist/assets/i18n/i18n-defaults';
99
import { Button } from '@ui5/webcomponents-react/lib/Button';
1010
import { ButtonDesign } from '@ui5/webcomponents-react/lib/ButtonDesign';
1111
import { List } from '@ui5/webcomponents-react/lib/List';

scripts/generate-assets/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require('fs');
2+
const prettier = require('prettier');
3+
const prettierConfig = require('../../prettier.config');
4+
// All languages present in the file system
5+
const files = fs.readdirSync('dist/json-imports');
6+
7+
let content;
8+
9+
// No i18n - just import dependencies, if any
10+
if (files.length === 0) {
11+
content = ``;
12+
// There is i18n - generate the full file
13+
} else {
14+
// Actual imports for json assets
15+
content = files.map((key) => `import './json-imports/${key}';`).join('\n');
16+
}
17+
18+
fs.writeFileSync('dist/Assets.js', prettier.format(content, prettierConfig));

scripts/generate-json-imports/i18n.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)