Skip to content

Commit b64fc5f

Browse files
fix(Framework): fix side-effects in rollup build (#414)
1 parent dca9b9a commit b64fc5f

17 files changed

+37
-268
lines changed

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"scripts": {
88
"start": "start-storybook -p 6006 -c .storybook",
9-
"build": "node ./scripts/rollup/build.js",
9+
"build": "yarn clean && lerna run build --stream && node ./scripts/rollup/build.js",
1010
"build:storybook": "build-storybook -c .storybook -o .out",
1111
"pretest": "node scripts/test/clean.js",
1212
"test": "jest --config=config/jest.config.js --coverage",
@@ -50,20 +50,16 @@
5050
"babel-loader": "^8.1.0",
5151
"babel-preset-react-app": "^9.1.2",
5252
"chalk": "^3.0.0",
53-
"cli-table": "^0.3.1",
5453
"dedent": "^0.7.0",
5554
"dotenv": "^8.2.0",
5655
"enzyme": "^3.11.0",
5756
"enzyme-adapter-react-16": "^1.15.2",
5857
"enzyme-to-json": "^3.4.4",
59-
"escape-string-regexp": "^2.0.0",
6058
"eslint": "^6.8.0",
6159
"eslint-plugin-prefer-arrow": "^1.1.7",
6260
"eslint-plugin-react": "^7.18.3",
63-
"filesize": "^6.0.1",
6461
"glob": "^7.1.6",
6562
"google-closure-compiler": "^20200315.0.0",
66-
"gzip-size": "^5.1.0",
6763
"husky": "^4.2.1",
6864
"identity-obj-proxy": "^3.0.0",
6965
"intersection-observer": "^0.7.0",
@@ -73,6 +69,7 @@
7369
"jest-enzyme": "^7.1.2",
7470
"lerna": "^3.20.2",
7571
"lint-staged": "^9.5.0",
72+
"micromatch": "^4.0.2",
7673
"minimist": "^1.2.0",
7774
"mkdirp": "^1.0.4",
7875
"ncp": "^2.0.0",

packages/base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"clean": "rimraf cjs Device hooks lib polyfill styling types utils index.esm.js index.d.ts",
2525
"build:rollup": "rollup -c rollup.config.js",
2626
"build:polyfills": "tsc ./src/polyfill/*.ts --outDir ./polyfill --skipLibCheck",
27-
"postbuild": "npm-run-all -s build:rollup build:polyfills"
27+
"build": "npm-run-all -s build:rollup build:polyfills"
2828
},
2929
"dependencies": {
3030
"core-js": "3.6.4",

packages/charts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"scripts": {
1919
"clean": "rimraf cjs components interfaces internal lib themes util index.esm.js index.d.ts config.d.ts hooks indexNew.d.ts",
20-
"postbuild": "rollup -c rollup.config.js"
20+
"build": "rollup -c rollup.config.js"
2121
},
2222
"dependencies": {
2323
"chart.js": "^2.9.3",

packages/charts/rollup.config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
const rollupConfigFactory = require('../../shared/rollup/configFactory');
22

3-
const config = rollupConfigFactory('charts', [
4-
'react',
5-
'react-jss',
6-
'@ui5/webcomponents',
7-
'@ui5/webcomponents-react-charts'
8-
]);
3+
const config = rollupConfigFactory('charts', ['@ui5/webcomponents', '@ui5/webcomponents-base']);
94
module.exports = config;

packages/main/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"@ui5/webcomponents-icons/dist/icons/*",
1717
"@ui5/webcomponents/dist/*",
1818
"@ui5/webcomponents-fiori/dist/*",
19-
"*/ThemingSupport.js"
19+
"**/ThemingSupport"
2020
],
2121
"scripts": {
2222
"clean": "rimraf cjs components enums interfaces internal lib webComponents index.esm.js index.d.ts",
23-
"postbuild": "rollup -c rollup.config.js"
23+
"build": "rollup -c rollup.config.js"
2424
},
2525
"dependencies": {
2626
"@ui5/webcomponents-react-base": "^0.9.0-rc.9",

packages/main/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const rollupConfigFactory = require('../../shared/rollup/configFactory');
22

3-
module.exports = rollupConfigFactory('main');
3+
module.exports = rollupConfigFactory('main', ['@ui5/webcomponents-base']);

packages/main/src/components/ThemeProvider/ThemingSupport.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
import '../components/ThemeProvider/ThemingSupport';
1+
import { root as sap_belize } from '@sap-theming/theming-base-content/content/Base/baseLib/sap_belize/variables.json';
2+
import { root as sap_belize_hcb } from '@sap-theming/theming-base-content/content/Base/baseLib/sap_belize_hcb/variables.json';
3+
import { root as sap_belize_hcw } from '@sap-theming/theming-base-content/content/Base/baseLib/sap_belize_hcw/variables.json';
4+
import { root as sap_fiori_3 } from '@sap-theming/theming-base-content/content/Base/baseLib/sap_fiori_3/variables.json';
5+
import { root as sap_fiori_3_dark } from '@sap-theming/theming-base-content/content/Base/baseLib/sap_fiori_3_dark/variables.json';
6+
7+
const themeMap = window['@ui5/webcomponents-react-theming'] || (window['@ui5/webcomponents-react-theming'] = new Map());
8+
themeMap.set('sap_fiori_3', sap_fiori_3);
9+
themeMap.set('sap_fiori_3_dark', sap_fiori_3_dark);
10+
themeMap.set('sap_belize', sap_belize);
11+
themeMap.set('sap_belize_hcb', sap_belize_hcb);
12+
themeMap.set('sap_belize_hcw', sap_belize_hcw);

scripts/ci/release-rc.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ yarn test
1717
# build the project
1818
yarn build
1919

20-
# reset potential changes in sizes
21-
git checkout scripts/rollup/results.json
22-
2320
# create npmrc with auth
2421
bash ${WORKSPACE}/scripts/ci/setup-npm.sh
2522

scripts/ci/release-snapshot.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#! /bin/bash
22

3-
# reset potential changes in sizes
4-
git checkout scripts/rollup/results.json
5-
63
CURRENT_LERNA_VERSION=$(node -p -e "require('./lerna.json').version")
74
IS_IN_RC_STATUS=$(echo "${CURRENT_LERNA_VERSION}" | awk '/rc\.[0-9]+$/')
85

scripts/rollup/build.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ const replace = require('@rollup/plugin-replace');
66
const resolve = require('@rollup/plugin-node-resolve');
77
const json = require('@rollup/plugin-json');
88
const closure = require('./plugins/closure-plugin');
9-
const sizes = require('./plugins/sizes-plugin');
109
const stripUnusedImports = require('./plugins/strip-unused-imports');
1110
const Bundles = require('./bundles');
12-
const Stats = require('./stats');
1311
const codeFrame = require('babel-code-frame');
1412
const chalk = require('chalk');
1513
const path = require('path');
@@ -170,24 +168,7 @@ function getPlugins(entry, externals, updateBabelOptions, filename, packageName,
170168
// Note that this plugin must be called after closure applies DCE.
171169
isProduction && stripUnusedImports([]),
172170
// Add the whitespace back if necessary.
173-
shouldStayReadable && prettier({ parser: 'babylon' }),
174-
// Record bundle size.
175-
sizes({
176-
getSize: (size, gzip) => {
177-
const currentSizes = Stats.currentBuildResults.bundleSizes;
178-
const recordIndex = currentSizes.findIndex(
179-
(record) => record.filename === filename && record.bundleType === bundleType
180-
);
181-
const index = recordIndex !== -1 ? recordIndex : currentSizes.length;
182-
currentSizes[index] = {
183-
filename,
184-
bundleType,
185-
packageName,
186-
size,
187-
gzip
188-
};
189-
}
190-
})
171+
shouldStayReadable && prettier({ parser: 'babylon' })
191172
].filter(Boolean);
192173
}
193174

@@ -292,11 +273,6 @@ async function buildEverything() {
292273

293274
await Packaging.prepareNpmPackages();
294275

295-
console.log(Stats.printResults());
296-
if (!forcePrettyOutput) {
297-
Stats.saveResults();
298-
}
299-
300276
if (shouldExtractErrors) {
301277
console.warn(
302278
'\nWarning: this build was created with --extract-errors enabled.\n' +

scripts/rollup/packaging.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ async function prepareNpmPackage(name) {
3030
async function prepareNpmPackages() {
3131
const builtPackageFolders = readdirSync('packages').filter((dir) => dir.charAt(0) !== '.');
3232
await Promise.all(builtPackageFolders.map(prepareNpmPackage));
33-
// create main lib
34-
await asyncExecuteCommand(`node_modules/.bin/lerna run postbuild --stream`);
3533
}
3634

3735
module.exports = {

scripts/rollup/plugins/sizes-plugin.js

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

scripts/rollup/results.json

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

scripts/rollup/stats.js

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

0 commit comments

Comments
 (0)