Skip to content

feat(Assets): add Assets-fetch.js #7345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/main/scripts/generateI18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,24 @@ spawnSync('npx', ['prettier', '--write', path.resolve(SRC_I18N_PROPERTIES, 'i18n
stdio: [0, 1, 2],
});

// generate Assets.js
// generate Assets.js and Assets-fetch.js
const jsonImports = await readdir(TARGET_I18N_JSON_IMPORTS);

const assets = [`import '@ui5/webcomponents/dist/Assets.js';`, `import '@ui5/webcomponents-fiori/dist/Assets.js';`];
const assetsFetch = [
`import '@ui5/webcomponents/dist/Assets-fetch.js';`,
`import '@ui5/webcomponents-fiori/dist/Assets-fetch.js';`,
];
const assetsNode = [
`import '@ui5/webcomponents/dist/Assets-node.js';`,
`import '@ui5/webcomponents-fiori/dist/Assets-node.js';`,
];

for (const file of jsonImports) {
if (file.includes('-fetch')) {
//todo: add to Assets-fetch.js
assetsFetch.push(`import './json-imports/${file}';`);
} else if (file.includes('-node')) {
//todo: add to Assets-node.js
assetsNode.push(`import './json-imports/${file}';`);
} else {
assets.push(`import './json-imports/${file}';`);
}
Expand All @@ -74,3 +82,13 @@ await writeFile(
path.resolve(DIST_DIR, 'Assets.js'),
await prettier.format(assets.join('\n'), { ...prettierConfig, parser: 'babel' }),
);

await writeFile(
path.resolve(DIST_DIR, 'Assets-fetch.js'),
await prettier.format(assetsFetch.join('\n'), { ...prettierConfig, parser: 'babel' }),
);

await writeFile(
path.resolve(DIST_DIR, 'Assets-node.js'),
await prettier.format(assetsNode.join('\n'), { ...prettierConfig, parser: 'babel' }),
);
Loading