@ui5/webcomponents-tools 1.21.0-rc.2 → 1.21.0-rc.4
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 +24 -0
- package/components-package/nps.js +6 -12
- package/components-package/postcss.components.js +1 -24
- package/components-package/postcss.themes.js +1 -30
- package/lib/css-processors/css-processor-components.mjs +77 -0
- package/lib/css-processors/css-processor-themes.mjs +79 -0
- package/lib/{postcss-scope-vars/index.js → css-processors/scope-variables.mjs} +17 -30
- package/lib/{postcss-css-to-esm/index.js → css-processors/shared.mjs} +36 -50
- package/lib/dev-server/custom-hot-update-plugin.js +4 -4
- package/lib/esm-abs-to-rel/index.js +4 -1
- package/lib/generate-js-imports/illustrations.js +6 -4
- package/lib/jsdoc/preprocess.js +1 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +12 -5
- package/package.json +4 -6
- package/lib/postcss-css-to-json/index.js +0 -47
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/postcss-p/postcss-p.mjs +0 -14
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,30 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.21.0-rc.4](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.3...v1.21.0-rc.4) (2023-12-28)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.21.0-rc.3](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.2...v1.21.0-rc.3) (2023-12-21)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* declare webpackChunkName in more generated dynamic imports ([#8029](https://github.com/SAP/ui5-webcomponents/issues/8029)) ([c85fa23](https://github.com/SAP/ui5-webcomponents/commit/c85fa23bd32574434f537df95c7507a7f1a48b5e))
|
20
|
+
|
21
|
+
|
22
|
+
### Features
|
23
|
+
|
24
|
+
* **tools:** Optimize build by switching css processing to esbuild ([#8008](https://github.com/SAP/ui5-webcomponents/issues/8008)) ([b4d411f](https://github.com/SAP/ui5-webcomponents/commit/b4d411f00f8d74ccecb2d02254126243faf53dfd))
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
6
30
|
# [1.21.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v1.21.0-rc.1...v1.21.0-rc.2) (2023-12-14)
|
7
31
|
|
8
32
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -68,25 +68,23 @@ const getScripts = (options) => {
|
|
68
68
|
styleRelated: "nps build.styles build.jsonImports build.jsImports",
|
69
69
|
typescript: tsCommandOld,
|
70
70
|
},
|
71
|
-
copyGenerated: `node "${LIB}/copy-and-watch/index.js" --silent "src/generated/**/*.{js,json}" dist/generated/`,
|
72
71
|
build: {
|
73
72
|
default: "nps prepare lint build.bundle", // build.bundle2
|
74
73
|
templates: `mkdirp src/generated/templates && ${tsCrossEnv} node "${LIB}/hbs2ui5/index.js" -d src/ -o src/generated/templates`,
|
75
74
|
styles: {
|
76
75
|
default: `concurrently "nps build.styles.themes" "nps build.styles.components"`,
|
77
|
-
|
78
|
-
|
79
|
-
components: "postcss src/themes/*.css --config config/postcss.components --base src --dir dist/css/", // When updating this, also update the new files script
|
76
|
+
themes: `node "${LIB}/css-processors/css-processor-themes.mjs"`,
|
77
|
+
components: `node "${LIB}/css-processors/css-processor-components.mjs"`,
|
80
78
|
},
|
81
79
|
i18n: {
|
82
80
|
default: "nps build.i18n.defaultsjs build.i18n.json",
|
83
81
|
defaultsjs: `node "${LIB}/i18n/defaults.js" src/i18n src/generated/i18n`,
|
84
|
-
json: `node "${LIB}/i18n/toJSON.js" src/i18n
|
82
|
+
json: `node "${LIB}/i18n/toJSON.js" src/i18n dist/generated/assets/i18n`,
|
85
83
|
},
|
86
84
|
jsonImports: {
|
87
85
|
default: "mkdirp src/generated/json-imports && nps build.jsonImports.themes build.jsonImports.i18n",
|
88
|
-
themes: `node "${LIB}/generate-json-imports/themes.js"
|
89
|
-
i18n: `node "${LIB}/generate-json-imports/i18n.js"
|
86
|
+
themes: `node "${LIB}/generate-json-imports/themes.js" dist/generated/assets/themes src/generated/json-imports`,
|
87
|
+
i18n: `node "${LIB}/generate-json-imports/i18n.js" dist/generated/assets/i18n src/generated/json-imports`,
|
90
88
|
},
|
91
89
|
jsImports: {
|
92
90
|
default: "mkdirp src/generated/js-imports && nps build.jsImports.illustrationsLoaders",
|
@@ -112,11 +110,7 @@ const getScripts = (options) => {
|
|
112
110
|
styles: {
|
113
111
|
default: 'concurrently "nps watch.styles.themes" "nps watch.styles.components"',
|
114
112
|
themes: 'nps "build.styles.themes -w"',
|
115
|
-
components:
|
116
|
-
default: 'concurrently "nps watch.styles.components.existingFiles" "nps watch.styles.components.newFiles"',
|
117
|
-
existingFiles: `nps "build.styles.components -w"`,
|
118
|
-
newFiles: `node "${LIB}/postcss-new-files/index.js" --srcFiles="src/themes/*.css"`,
|
119
|
-
},
|
113
|
+
components: `nps "build.styles.components -w"`,
|
120
114
|
},
|
121
115
|
templates: 'chokidar "src/**/*.hbs" -c "nps build.templates"',
|
122
116
|
api: 'chokidar "test/**/*.sample.html" -c "nps generateAPI"',
|
@@ -1,24 +1 @@
|
|
1
|
-
|
2
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
3
|
-
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
4
|
-
const cssnano = require('cssnano');
|
5
|
-
const fs = require("fs")
|
6
|
-
|
7
|
-
|
8
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
9
|
-
|
10
|
-
module.exports = {
|
11
|
-
plugins: [
|
12
|
-
postcssImport(),
|
13
|
-
cssnano({
|
14
|
-
preset: [
|
15
|
-
'default', {
|
16
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
17
|
-
mergeRules: false, // https://github.com/cssnano/cssnano/issues/730
|
18
|
-
},
|
19
|
-
]
|
20
|
-
}),
|
21
|
-
postcssScopeVars({version: packageJSON.version}),
|
22
|
-
postcssCSStoESM({ toReplace: 'src', includeDefaultTheme: true, packageName: packageJSON.name }),
|
23
|
-
]
|
24
|
-
}
|
1
|
+
module.exports = {}
|
@@ -1,30 +1 @@
|
|
1
|
-
|
2
|
-
const combineSelectors = require('../lib/postcss-combine-duplicated-selectors/index.js');
|
3
|
-
const postcssCSStoJSON = require('../lib/postcss-css-to-json/index.js');
|
4
|
-
const postcssCSStoESM = require('../lib/postcss-css-to-esm/index.js');
|
5
|
-
const postcssScopeVars = require('../lib/postcss-scope-vars/index.js');
|
6
|
-
const cssnano = require('cssnano');
|
7
|
-
const fs = require("fs");
|
8
|
-
|
9
|
-
|
10
|
-
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
11
|
-
const packageName = packageJSON.name;
|
12
|
-
|
13
|
-
module.exports = {
|
14
|
-
plugins: [
|
15
|
-
postcssScopeVars({version: packageJSON.version}),
|
16
|
-
postcssImport(),
|
17
|
-
combineSelectors({
|
18
|
-
removeDuplicatedProperties: true
|
19
|
-
}),
|
20
|
-
cssnano({
|
21
|
-
preset: [
|
22
|
-
'default', {
|
23
|
-
mergeLonghand: false, // https://github.com/cssnano/cssnano/issues/675
|
24
|
-
},
|
25
|
-
]
|
26
|
-
},),
|
27
|
-
postcssCSStoJSON({ toReplace: 'src', packageName }),
|
28
|
-
postcssCSStoESM({ toReplace: 'src', packageName }),
|
29
|
-
]
|
30
|
-
};
|
1
|
+
module.exports = {};
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { globby } from "globby";
|
2
|
+
import * as esbuild from 'esbuild'
|
3
|
+
import * as fs from "fs";
|
4
|
+
import * as path from "path";
|
5
|
+
import { writeFile, mkdir } from "fs/promises";
|
6
|
+
import chokidar from "chokidar";
|
7
|
+
import scopeVariables from "./scope-variables.mjs";
|
8
|
+
import { writeFileIfChanged, getFileContent } from "./shared.mjs";
|
9
|
+
|
10
|
+
const tsMode = process.env.UI5_TS === "true";
|
11
|
+
const extension = tsMode ? ".css.ts" : ".css.js";
|
12
|
+
|
13
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
14
|
+
const inputFilesGlob = "src/themes/*.css";
|
15
|
+
const restArgs = process.argv.slice(2);
|
16
|
+
|
17
|
+
let customPlugin = {
|
18
|
+
name: 'ui5-tools',
|
19
|
+
setup(build) {
|
20
|
+
build.initialOptions.write = false;
|
21
|
+
|
22
|
+
build.onEnd(result => {
|
23
|
+
result.outputFiles.forEach(async f => {
|
24
|
+
// scoping
|
25
|
+
const newText = scopeVariables(f.text, packageJSON);
|
26
|
+
await mkdir(path.dirname(f.path), {recursive: true});
|
27
|
+
writeFile(f.path, newText);
|
28
|
+
|
29
|
+
// JS/TS
|
30
|
+
const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
|
31
|
+
const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`", true);
|
32
|
+
writeFileIfChanged(jsPath, jsContent);
|
33
|
+
});
|
34
|
+
})
|
35
|
+
},
|
36
|
+
}
|
37
|
+
|
38
|
+
const getConfig = async () => {
|
39
|
+
const config = {
|
40
|
+
entryPoints: await globby(inputFilesGlob),
|
41
|
+
bundle: true,
|
42
|
+
minify: true,
|
43
|
+
outdir: 'dist/css',
|
44
|
+
outbase: 'src',
|
45
|
+
plugins: [
|
46
|
+
customPlugin,
|
47
|
+
]
|
48
|
+
};
|
49
|
+
return config;
|
50
|
+
}
|
51
|
+
|
52
|
+
if (restArgs.includes("-w")) {
|
53
|
+
let ready;
|
54
|
+
let config = await getConfig();
|
55
|
+
let ctx = await esbuild.context(config);
|
56
|
+
await ctx.watch()
|
57
|
+
console.log('watching...')
|
58
|
+
|
59
|
+
// when new component css files are added, they do not trigger a build as no one directly imports them
|
60
|
+
// restart the watch mode with the new entry points if a css file is added.
|
61
|
+
const watcher = chokidar.watch(inputFilesGlob);
|
62
|
+
watcher.on("ready", () => {
|
63
|
+
ready = true; // Initial scan is over -> waiting for new files
|
64
|
+
});
|
65
|
+
watcher.on("add", async path => {
|
66
|
+
if (ready) {
|
67
|
+
// new file
|
68
|
+
ctx.dispose();
|
69
|
+
config = await getConfig();
|
70
|
+
ctx = await esbuild.context(config);
|
71
|
+
ctx.watch();
|
72
|
+
}
|
73
|
+
});
|
74
|
+
} else {
|
75
|
+
const config = await getConfig();
|
76
|
+
const result = await esbuild.build(config);
|
77
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { globby } from "globby";
|
2
|
+
import * as esbuild from 'esbuild'
|
3
|
+
import * as fs from "fs";
|
4
|
+
import * as path from "path";
|
5
|
+
import { writeFile, mkdir } from "fs/promises";
|
6
|
+
import postcss from "postcss";
|
7
|
+
import combineDuplicatedSelectors from "../postcss-combine-duplicated-selectors/index.js"
|
8
|
+
import { writeFileIfChanged, stripThemingBaseContent, getFileContent } from "./shared.mjs";
|
9
|
+
import scopeVariables from "./scope-variables.mjs";
|
10
|
+
|
11
|
+
const tsMode = process.env.UI5_TS === "true";
|
12
|
+
const extension = tsMode ? ".css.ts" : ".css.js";
|
13
|
+
|
14
|
+
const packageJSON = JSON.parse(fs.readFileSync("./package.json"))
|
15
|
+
|
16
|
+
let inputFiles = await globby("src/**/parameters-bundle.css");
|
17
|
+
const restArgs = process.argv.slice(2);
|
18
|
+
|
19
|
+
const removeDuplicateSelectors = async (text) => {
|
20
|
+
const result = await postcss(combineDuplicatedSelectors).process(text);
|
21
|
+
return result.css;
|
22
|
+
}
|
23
|
+
|
24
|
+
let scopingPlugin = {
|
25
|
+
name: 'scoping',
|
26
|
+
setup(build) {
|
27
|
+
build.initialOptions.write = false;
|
28
|
+
|
29
|
+
build.onEnd(result => {
|
30
|
+
result.outputFiles.forEach(async f => {
|
31
|
+
// remove duplicate selectors
|
32
|
+
let newText = await removeDuplicateSelectors(f.text);
|
33
|
+
|
34
|
+
// strip unnecessary theming-base-content
|
35
|
+
newText = stripThemingBaseContent(newText);
|
36
|
+
|
37
|
+
// scoping
|
38
|
+
newText = scopeVariables(newText, packageJSON, f.path);
|
39
|
+
await mkdir(path.dirname(f.path), {recursive: true});
|
40
|
+
writeFile(f.path, newText);
|
41
|
+
|
42
|
+
// JSON
|
43
|
+
const jsonPath = f.path.replace(/dist[\/\\]css/, "dist/generated/assets").replace(".css", ".css.json");
|
44
|
+
await mkdir(path.dirname(jsonPath), {recursive: true});
|
45
|
+
const data = {
|
46
|
+
packageName: packageJSON.name,
|
47
|
+
fileName: jsonPath.substr(jsonPath.lastIndexOf("themes")),
|
48
|
+
content: newText,
|
49
|
+
};
|
50
|
+
writeFileIfChanged(jsonPath, JSON.stringify({_: data}));
|
51
|
+
|
52
|
+
// JS/TS
|
53
|
+
const jsPath = f.path.replace(/dist[\/\\]css/, "src/generated/").replace(".css", extension);
|
54
|
+
const jsContent = getFileContent(tsMode, jsPath, packageJSON.name, "\`" + newText + "\`");
|
55
|
+
writeFileIfChanged(jsPath, jsContent);
|
56
|
+
});
|
57
|
+
})
|
58
|
+
},
|
59
|
+
}
|
60
|
+
|
61
|
+
const config = {
|
62
|
+
entryPoints: inputFiles,
|
63
|
+
bundle: true,
|
64
|
+
minify: true,
|
65
|
+
outdir: 'dist/css',
|
66
|
+
outbase: 'src',
|
67
|
+
plugins: [
|
68
|
+
scopingPlugin,
|
69
|
+
],
|
70
|
+
external: ["*.ttf", "*.woff", "*.woff2"],
|
71
|
+
};
|
72
|
+
|
73
|
+
if (restArgs.includes("-w")) {
|
74
|
+
let ctx = await esbuild.context(config);
|
75
|
+
await ctx.watch()
|
76
|
+
console.log('watching...')
|
77
|
+
} else {
|
78
|
+
const result = await esbuild.build(config);
|
79
|
+
}
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
const name = "postcss-scope-vars";
|
3
|
-
|
4
|
-
const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
|
1
|
+
import * as path from "path";
|
5
2
|
|
6
3
|
/**
|
7
4
|
* Tries to detect an override for a package
|
8
5
|
* @param {*} filePath For example: /my_project/src/themes/overrides/@ui5/webcomponents/my_custom_theme/parameters-bundle.css
|
9
|
-
* @returns
|
6
|
+
* @returns
|
10
7
|
*/
|
11
8
|
const getOverrideVersion = filePath => {
|
12
|
-
|
9
|
+
if (!filePath) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
|
13
13
|
if (!filePath.includes(`overrides${path.sep}`)) {
|
14
14
|
return; // The "overrides/" directory is the marker
|
15
15
|
}
|
@@ -33,27 +33,14 @@ const getOverrideVersion = filePath => {
|
|
33
33
|
return overrideVersion;
|
34
34
|
}
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
// add version after ui5
|
49
|
-
const expr = /(--_?ui5)([^\,\:\)\s]+)/g
|
50
|
-
declaration.prop = declaration.prop.replaceAll(expr, `$1-${versionStr}$2`)
|
51
|
-
declaration.value = declaration.value.replaceAll(expr, `$1-${versionStr}$2`)
|
52
|
-
declaration.__ui5_replaced = true;
|
53
|
-
},
|
54
|
-
};
|
55
|
-
},
|
56
|
-
};
|
57
|
-
};
|
58
|
-
|
59
|
-
module.exports.postcss = true;
|
36
|
+
const scopeVariables = (cssText, packageJSON, inputFile) => {
|
37
|
+
const escapeVersion = version => "v" + version?.replaceAll(/[^0-9A-Za-z\-_]/g, "-");
|
38
|
+
const versionStr = escapeVersion(getOverrideVersion(inputFile) || packageJSON.version);
|
39
|
+
|
40
|
+
const expr = /(--_?ui5)([^\,\:\)\s]+)/g;
|
41
|
+
|
42
|
+
return cssText.replaceAll(expr, `$1-${versionStr}$2`);
|
43
|
+
}
|
44
|
+
|
45
|
+
export default scopeVariables;
|
46
|
+
|
@@ -1,7 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { writeFile, readFile, mkdir } from "fs/promises";
|
2
|
+
import * as path from "path";
|
3
|
+
import assets from "../../assets-meta.js";
|
4
|
+
|
5
|
+
const readOldContent = async (fileName) => {
|
6
|
+
// it seems slower to read the old content, but writing the same content with no real changes
|
7
|
+
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
8
|
+
let oldContent = "";
|
9
|
+
try {
|
10
|
+
oldContent = (await readFile(fileName)).toString();
|
11
|
+
} catch (e) {
|
12
|
+
// file not found
|
13
|
+
}
|
14
|
+
return oldContent;
|
15
|
+
}
|
16
|
+
|
17
|
+
const writeFileIfChanged = async (fileName, content) => {
|
18
|
+
const oldContent = await readOldContent(fileName);
|
19
|
+
if (content !== oldContent) {
|
20
|
+
if (!oldContent) {
|
21
|
+
await mkdir(path.dirname(fileName), {recursive: true});
|
22
|
+
}
|
23
|
+
return writeFile(fileName, content);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// strips the unnecessary theming data coming from @sap-theming/theming-base-content and leaves only the css parameters
|
28
|
+
const stripThemingBaseContent = css => {
|
29
|
+
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
30
|
+
css = css.replace(/\.background-image.*{.*}/, "");
|
31
|
+
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
32
|
+
css = css.replace(/--sapFontUrl.*\);?/, "");
|
33
|
+
return css;
|
34
|
+
}
|
35
|
+
|
5
36
|
|
6
37
|
const DEFAULT_THEME = assets.themes.default;
|
7
38
|
|
@@ -42,49 +73,4 @@ const getJSContent = (targetFile, packageName, css, includeDefaultTheme) => {
|
|
42
73
|
return `${defaultTheme}export default {packageName:"${packageName}",fileName:"${targetFile.substr(targetFile.lastIndexOf("themes"))}",content:${css}}`
|
43
74
|
}
|
44
75
|
|
45
|
-
|
46
|
-
const proccessCSS = css => {
|
47
|
-
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
48
|
-
css = css.replace(/\.background-image.*{.*}/, "");
|
49
|
-
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
50
|
-
css = css.replace(/--sapFontUrl.*\);?/, "");
|
51
|
-
return JSON.stringify(css);
|
52
|
-
}
|
53
|
-
|
54
|
-
module.exports = function (opts) {
|
55
|
-
opts = opts || {};
|
56
|
-
|
57
|
-
const packageName = opts.packageName;
|
58
|
-
const includeDefaultTheme = opts.includeDefaultTheme;
|
59
|
-
const toReplace = opts.toReplace;
|
60
|
-
|
61
|
-
return {
|
62
|
-
postcssPlugin: 'postcss-css-to-esm',
|
63
|
-
OnceExit(root) {
|
64
|
-
const tsMode = process.env.UI5_TS === "true";
|
65
|
-
|
66
|
-
let css = root.toString();
|
67
|
-
css = proccessCSS(css);
|
68
|
-
|
69
|
-
const targetFile = root.source.input.from.replace(`/${toReplace}/`, "/src/generated/").replace(`\\${toReplace}\\`, "\\src\\generated\\");
|
70
|
-
mkdirp.sync(path.dirname(targetFile));
|
71
|
-
|
72
|
-
const filePath = `${targetFile}.${tsMode ? "ts" : "js"}`;
|
73
|
-
|
74
|
-
// it seems slower to read the old content, but writing the same content with no real changes
|
75
|
-
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
76
|
-
let oldContent = "";
|
77
|
-
try {
|
78
|
-
oldContent = fs.readFileSync(filePath).toString();
|
79
|
-
} catch (e) {
|
80
|
-
// file not found
|
81
|
-
}
|
82
|
-
|
83
|
-
const content = getFileContent(tsMode, targetFile, packageName, css, includeDefaultTheme);
|
84
|
-
if (content !== oldContent) {
|
85
|
-
fs.writeFileSync(filePath, content);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
};
|
89
|
-
};
|
90
|
-
module.exports.postcss = true;
|
76
|
+
export { writeFileIfChanged, stripThemingBaseContent, getFileContent}
|
@@ -3,15 +3,15 @@ const fs = require("fs");
|
|
3
3
|
/**
|
4
4
|
* A change is observed on MacOS since 13.5, where the build generates a large amount
|
5
5
|
* of JSON file that spotlight search has to index, as they are considered new files.
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* Starting the vitejs dev server reads all of these files and this triggers the indexing.
|
8
8
|
* The indexing has a side effect of changing some file metadata (can be checked with `mdls <path_to_file>`).
|
9
9
|
* This metadata change is changing the ctime of the file, but not the mtime. This can be checked with `stat -x <path_to_file>
|
10
|
-
*
|
10
|
+
*
|
11
11
|
* Essentially only metadata is changed, not content. This should not cause a page refresh,
|
12
12
|
* but chokidar reports this change and vite refreshes the page.
|
13
13
|
* The indexing is running with a 10 second interval, so for roughtly 20 minutes vite is refreshing the page every 10 seconds
|
14
|
-
*
|
14
|
+
*
|
15
15
|
* This plugin checks if the file causing the refresh is a generated json file (dist/*.json) and if ctime is changed after mtime
|
16
16
|
* In that case, returing an empty array tells vitejs that a custom update will be made by the plugin,
|
17
17
|
* which is in effect ignoring the page refresh.
|
@@ -22,7 +22,7 @@ const customHotUpdate = async () => {
|
|
22
22
|
name: 'custom-hot-update',
|
23
23
|
handleHotUpdate(ctx) {
|
24
24
|
// custom check for generated json files
|
25
|
-
if (ctx.file.
|
25
|
+
if (ctx.file.endsWith(".json")) {
|
26
26
|
const stat = fs.statSync(ctx.file);
|
27
27
|
|
28
28
|
// metadata change only
|
@@ -7,8 +7,11 @@ const basePath = process.argv[2];
|
|
7
7
|
|
8
8
|
const convertImports = async (srcPath) => {
|
9
9
|
let changed = false;
|
10
|
-
// console.log("scanning imports of", srcPath);
|
11
10
|
let code = (await fs.readFile(srcPath)).toString();
|
11
|
+
if (code.includes("import(")) {
|
12
|
+
// esprima can't parse this, but it's from the project files
|
13
|
+
return;
|
14
|
+
}
|
12
15
|
const tree = esprima.parseModule(code);
|
13
16
|
const importer = srcPath.replace(basePath, "");
|
14
17
|
const importerDir = path.dirname(importer);
|
@@ -1,12 +1,14 @@
|
|
1
1
|
const fs = require("fs").promises;
|
2
2
|
const path = require("path");
|
3
3
|
|
4
|
-
const generateDynamicImportLines = (fileNames, location, exclusionPatterns = []) => {
|
4
|
+
const generateDynamicImportLines = async (fileNames, location, exclusionPatterns = []) => {
|
5
|
+
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
5
6
|
return fileNames
|
6
7
|
.filter((fileName) => !exclusionPatterns.some((pattern) => fileName.startsWith(pattern)))
|
7
8
|
.map((fileName) => {
|
8
|
-
const
|
9
|
-
|
9
|
+
const illustrationName = fileName.replace(".js", "");
|
10
|
+
const illustrationPath = `${location}/${illustrationName}`;
|
11
|
+
return `\t\tcase "${fileName.replace('.js', '')}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${illustrationName.toLowerCase()}" */ "${illustrationPath}.js")).default;`;
|
10
12
|
})
|
11
13
|
.join("\n");
|
12
14
|
};
|
@@ -57,7 +59,7 @@ const generateIllustrations = async (config) => {
|
|
57
59
|
|
58
60
|
const illustrations = await getMatchingFiles(normalizedInputFolder, /^.*\.js$/);
|
59
61
|
|
60
|
-
const dynamicImports = generateDynamicImportLines(illustrations, location, filterOut);
|
62
|
+
const dynamicImports = await generateDynamicImportLines(illustrations, location, filterOut);
|
61
63
|
const availableIllustrations = generateAvailableIllustrationsArray(illustrations, filterOut);
|
62
64
|
|
63
65
|
const contentDynamic = generateDynamicImportsFileContent(dynamicImports, availableIllustrations, collection, prefix);
|
package/lib/jsdoc/preprocess.js
CHANGED
@@ -116,7 +116,7 @@ const processComponentFile = async (fileName) => {
|
|
116
116
|
const destFileName = fileName.replace(sourceDir, inputDir).replace(/\.ts$/, ".js");
|
117
117
|
let jsFileContent = `${await fs.readFile(destFileName)}`;
|
118
118
|
|
119
|
-
const classDefinitionRegExp = new RegExp(`let.*? = class`, "gm");
|
119
|
+
const classDefinitionRegExp = new RegExp(`(let.*? = class)|(^class.*?)`, "gm");
|
120
120
|
let classDefinitionMatch = jsFileContent.match(classDefinitionRegExp);
|
121
121
|
if (!classDefinitionMatch) {
|
122
122
|
return; // not a file, generated by typescript, nothing to do here
|
@@ -154,22 +154,29 @@ module.exports = (options) => {
|
|
154
154
|
options.removeDuplicatedProperties ||
|
155
155
|
options.removeDuplicatedValues
|
156
156
|
) {
|
157
|
-
removeDupProperties(
|
158
|
-
|
159
|
-
|
160
|
-
);
|
157
|
+
// removeDupProperties(
|
158
|
+
// destination,
|
159
|
+
// options.removeDuplicatedValues,
|
160
|
+
// );
|
161
161
|
}
|
162
162
|
} else {
|
163
163
|
if (
|
164
164
|
options.removeDuplicatedProperties ||
|
165
165
|
options.removeDuplicatedValues
|
166
166
|
) {
|
167
|
-
removeDupProperties(rule, options.removeDuplicatedValues);
|
167
|
+
// removeDupProperties(rule, options.removeDuplicatedValues);
|
168
168
|
}
|
169
169
|
// add new selector to symbol table
|
170
170
|
map.set(selector, rule);
|
171
171
|
}
|
172
172
|
},
|
173
|
+
OnceExit(root) {
|
174
|
+
root.nodes.forEach(node => {
|
175
|
+
if (node.type === "rule") {
|
176
|
+
removeDupProperties(node, options.removeDuplicatedValues);
|
177
|
+
}
|
178
|
+
})
|
179
|
+
}
|
173
180
|
};
|
174
181
|
},
|
175
182
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "1.21.0-rc.
|
3
|
+
"version": "1.21.0-rc.4",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -36,7 +36,6 @@
|
|
36
36
|
"command-line-args": "^5.1.1",
|
37
37
|
"concurrently": "^6.0.0",
|
38
38
|
"cross-env": "^7.0.3",
|
39
|
-
"cssnano": "^6.0.1",
|
40
39
|
"escodegen": "^2.0.0",
|
41
40
|
"eslint": "^7.22.0",
|
42
41
|
"eslint-config-airbnb-base": "^14.2.1",
|
@@ -54,7 +53,6 @@
|
|
54
53
|
"nps": "^5.10.0",
|
55
54
|
"postcss": "^8.4.5",
|
56
55
|
"postcss-cli": "^9.1.0",
|
57
|
-
"postcss-import": "^14.0.2",
|
58
56
|
"postcss-selector-parser": "^6.0.10",
|
59
57
|
"prompts": "^2.4.2",
|
60
58
|
"properties-reader": "^2.2.0",
|
@@ -63,8 +61,7 @@
|
|
63
61
|
"rimraf": "^3.0.2",
|
64
62
|
"slash": "3.0.0",
|
65
63
|
"vite": "^4.4.9",
|
66
|
-
"wdio-chromedriver-service": "^7.3.2"
|
67
|
-
"zx": "^7.2.3"
|
64
|
+
"wdio-chromedriver-service": "^7.3.2"
|
68
65
|
},
|
69
66
|
"peerDependencies": {
|
70
67
|
"chromedriver": "*",
|
@@ -76,7 +73,8 @@
|
|
76
73
|
}
|
77
74
|
},
|
78
75
|
"devDependencies": {
|
76
|
+
"esbuild": "^0.19.9",
|
79
77
|
"yargs": "^17.5.1"
|
80
78
|
},
|
81
|
-
"gitHead": "
|
79
|
+
"gitHead": "0e573370d4361a05c94ff2cf09f474501ea6b1b9"
|
82
80
|
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
const fs = require('fs');
|
2
|
-
const path = require('path');
|
3
|
-
const mkdirp = require('mkdirp');
|
4
|
-
|
5
|
-
const proccessCSS = css => {
|
6
|
-
css = css.replace(/\.sapThemeMeta[\s\S]*?:root/, ":root");
|
7
|
-
css = css.replace(/\.background-image.*{.*}/, "");
|
8
|
-
css = css.replace(/\.sapContrast[ ]*:root[\s\S]*?}/, "");
|
9
|
-
css = css.replace(/--sapFontUrl.*\);?/, "");
|
10
|
-
return css;
|
11
|
-
}
|
12
|
-
|
13
|
-
module.exports = function (opts) {
|
14
|
-
opts = opts || {};
|
15
|
-
|
16
|
-
return {
|
17
|
-
postcssPlugin: 'postcss-css-to-json',
|
18
|
-
OnceExit (root) {
|
19
|
-
let css = root.toString();
|
20
|
-
css = proccessCSS(css);
|
21
|
-
|
22
|
-
const targetFile = root.source.input.from.replace(`/${opts.toReplace}/`, "/src/generated/assets/").replace(`\\${opts.toReplace}\\`, "\\src\\generated\\assets\\");
|
23
|
-
mkdirp.sync(path.dirname(targetFile));
|
24
|
-
|
25
|
-
const filePath = `${targetFile}.json`;
|
26
|
-
const data = {
|
27
|
-
packageName: opts.packageName,
|
28
|
-
fileName: targetFile.substr(targetFile.lastIndexOf("themes")),
|
29
|
-
content: css
|
30
|
-
};
|
31
|
-
// it seems slower to read the old content, but writing the same content with no real changes
|
32
|
-
// (as in initial build and then watch mode) will cause an unnecessary dev server refresh
|
33
|
-
let oldContent = "";
|
34
|
-
try {
|
35
|
-
oldContent = fs.readFileSync(filePath).toString();
|
36
|
-
} catch (e) {
|
37
|
-
// file not found
|
38
|
-
}
|
39
|
-
const content = JSON.stringify({_: data});
|
40
|
-
if (content !== oldContent) {
|
41
|
-
fs.writeFileSync(filePath, content);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
};
|
45
|
-
};
|
46
|
-
|
47
|
-
module.exports.postcss = true;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
const chokidar = require("chokidar");
|
2
|
-
const commandLineArgs = require("command-line-args");
|
3
|
-
const { exec } = require("child_process");
|
4
|
-
|
5
|
-
const options = commandLineArgs([
|
6
|
-
{ name: "srcFiles", type: String },
|
7
|
-
]);
|
8
|
-
|
9
|
-
const runPostcss = path => {
|
10
|
-
let command = `postcss ${path} --config config/postcss.components --base src --dir dist/css/`;
|
11
|
-
console.log(`Executing: ${command}`);
|
12
|
-
exec(command, (err, stdout, stderr) => {
|
13
|
-
if (err) {
|
14
|
-
console.log(`Could not run postcss for ${path}. Error: ${err}`);
|
15
|
-
}
|
16
|
-
});
|
17
|
-
|
18
|
-
command = `${command} -w`;
|
19
|
-
console.log(`Executing: ${command}`);
|
20
|
-
exec(command, (err, stdout, stderr) => {
|
21
|
-
if (err) {
|
22
|
-
console.log(`Could not run postcss in watch mode for ${path}. Error: ${err}`);
|
23
|
-
}
|
24
|
-
});
|
25
|
-
};
|
26
|
-
|
27
|
-
let ready = false; // Do nothing until the ready event has been fired (we don't want to recompile all files initially)
|
28
|
-
const watcher = chokidar.watch(options.srcFiles);
|
29
|
-
watcher.on("ready", () => {
|
30
|
-
ready = true; // Initial scan is over -> waiting for new files
|
31
|
-
});
|
32
|
-
watcher.on("add", path => {
|
33
|
-
if (ready) {
|
34
|
-
runPostcss(path);
|
35
|
-
}
|
36
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import 'zx/globals';
|
2
|
-
|
3
|
-
// don't print executed commands and their output
|
4
|
-
$.verbose = false;
|
5
|
-
|
6
|
-
let inputFiles = await globby("src/**/parameters-bundle.css");
|
7
|
-
// inputFiles = inputFiles.filter(x => x.includes("fiori_3"))
|
8
|
-
const restArgs = process.argv.slice(2);
|
9
|
-
|
10
|
-
// run all postcss processes in parallel as passing the glob directly to postcss makes them processed sequentially.
|
11
|
-
// and the amount of imports give a big speed up when run in parallel
|
12
|
-
await Promise.all(inputFiles.map(file => {
|
13
|
-
return $`postcss ${file} --config config/postcss.themes --base src --dir dist/css/ ${restArgs}`;
|
14
|
-
}));
|