Skip to content

Commit 6c5e718

Browse files
georginahalpernGeorgina
andauthored
Remove build dev from non-tooling UMD packages and copy their minified files into the expected .js or max.js file (#16770)
Following the same rational as [this PR](#16760), modifying the remaining packages in UMD directory. Had to change the logic slightly in the webpack plugin because of how some packages were overriding filename. I do still believe we will need further changes to fix memory pressure as I am still hitting high memory usage when building locally. --------- Co-authored-by: Georgina <[email protected]>
1 parent ab8dd7e commit 6c5e718

File tree

21 files changed

+49
-34
lines changed

21 files changed

+49
-34
lines changed

packages/dev/buildTools/src/webpackTools.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,24 +224,27 @@ export const commonDevWebpackConfiguration = (
224224
* Originally our build commands for our tools were running both dev and prod, outputted an unminified max.js file during CI. This impacted memory usage during
225225
* build and is not necessary for debugging since we offer source maps. We have since removed the dev step from our builds, but in order to preserve
226226
* backwards compatibility for users who may have been referencing the .max.js file directly, we now copy the minified file to a .max.js file
227-
* after the build is complete. This plugin will only run if the `copyMinToMax` option is set to true in the webpack configuration.
227+
* after the build is complete. This plugin will only run if the `minToMax` option is set to true in the webpack configuration.
228228
*/
229229
class CopyMinToMaxWebpackPlugin {
230230
apply(compiler: Compiler) {
231231
compiler.hooks.done.tap("CopyToMax", (stats) => {
232232
const outputPath = stats.compilation.outputOptions.path;
233-
const file = stats.compilation.outputOptions.filename?.toString();
234-
if (outputPath && file) {
235-
const from = path.join(outputPath, file);
236-
let to;
237-
if (file.includes(".min.js")) {
238-
// if maxMode is false, the minified file will have .min.js suffix and the max file will have no suffix
239-
to = path.join(outputPath, file.replace(/\.min\.js$/, ".js"));
240-
} else {
241-
// if maxMode is true, the minified file will have no suffix and the max file will have max.js suffix
242-
to = path.join(outputPath, file.replace(/\.js$/, ".max.js"));
233+
if (outputPath) {
234+
for (const chunk of stats.compilation.chunks) {
235+
for (const file of chunk.files) {
236+
const from = path.join(outputPath, file);
237+
let to;
238+
if (file.includes(".min.js")) {
239+
// if maxMode is false, the minified file will have .min.js suffix and the max file will have no suffix
240+
to = path.join(outputPath, file.replace(/\.min\.js$/, ".js"));
241+
} else {
242+
// if maxMode is true, the minified file will have no suffix and the max file will have max.js suffix
243+
to = path.join(outputPath, file.replace(/\.js$/, ".max.js"));
244+
}
245+
copyFile(from, to);
246+
}
243247
}
244-
copyFile(from, to);
245248
}
246249
});
247250
}

packages/public/umd/babylonjs-accessibility/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "babylonjs-accessibility",
33
"version": "8.13.0",
4-
"main": "babylon.accessibility.max.js",
4+
"main": "babylon.accessibility.js",
55
"types": "babylon.accessibility.module.d.ts",
66
"files": [
77
"*"
88
],
99
"scripts": {
10-
"build": "npm run clean && npm run build:dev && npm run build:prod && npm run build:declaration",
10+
"build": "npm run clean && npm run build:prod && npm run build:declaration",
1111
"build:dev": "webpack --env development",
1212
"build:prod": "webpack --env production",
1313
"build:declaration": "build-tools -c pud --config ./config.json",

packages/public/umd/babylonjs-accessibility/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = (env) => {
99
namespace: "ACCESSIBILITY",
1010
outputPath: path.resolve(__dirname),
1111
maxMode: true,
12+
minToMax: true,
1213
});
1314
return commonConfig;
1415
};

packages/public/umd/babylonjs-addons/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "babylonjs-addons",
33
"version": "8.13.0",
4-
"main": "babylonjs.addons.js",
4+
"main": "babylonjs.addons.min.js",
55
"types": "babylonjs.addons.module.d.ts",
66
"files": [
77
"*"
88
],
99
"scripts": {
10-
"build": "npm run clean && npm run build:dev && npm run build:prod && npm run build:declaration",
10+
"build": "npm run clean && npm run build:prod && npm run build:declaration",
1111
"build:dev": "webpack --env development",
1212
"build:prod": "webpack --env production",
1313
"build:declaration": "build-tools -c pud --config ./config.json",

packages/public/umd/babylonjs-addons/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ module.exports = (env) => {
1111
alias: {
1212
addons: path.resolve(__dirname, "../../../dev/addons/src"),
1313
},
14-
overrideFilename: (pathData) => {
14+
overrideFilename: () => {
1515
return `babylonjs.[name]${env.production ? ".min" : ""}.js`;
1616
},
17+
minToMax: true,
1718
});
1819
return commonConfig;
1920
};

packages/public/umd/babylonjs-gui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "babylonjs-gui",
33
"version": "8.13.0",
4-
"main": "babylon.gui.js",
4+
"main": "babylon.gui.min.js",
55
"types": "babylon.gui.module.d.ts",
66
"files": [
77
"*"
88
],
99
"scripts": {
10-
"build": "npm run clean && npm run build:dev && npm run build:prod && npm run build:declaration",
10+
"build": "npm run clean & npm run build:prod && npm run build:declaration",
1111
"build:dev": "webpack --env development",
1212
"build:prod": "webpack --env production",
1313
"build:declaration": "build-tools -c pud --config ./config.json",

packages/public/umd/babylonjs-gui/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = (env) => {
1111
gui: path.resolve(__dirname, "../../../dev/gui/src"),
1212
"@lts/gui": path.resolve(__dirname, "../../../lts/gui/src"),
1313
},
14+
minToMax: true,
1415
});
1516
return commonConfig;
1617
};

packages/public/umd/babylonjs-ktx2decoder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"*"
88
],
99
"scripts": {
10-
"build": "npm run clean && npm run build:dev && npm run build:prod && npm run build:declaration",
10+
"build": "npm run clean && npm run build:prod && npm run build:declaration",
1111
"build:dev": "webpack --env development",
1212
"build:prod": "webpack --env production",
1313
"build:declaration": "build-tools -c pud --config ./config.json",

packages/public/umd/babylonjs-ktx2decoder/webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ module.exports = (env) => {
66
devPackageName: "ktx2decoder",
77
namespace: "KTX2DECODER",
88
maxMode: true,
9+
minToMax: true,
910
outputPath: path.resolve(__dirname),
1011
devPackageAliasPath: `../../../tools/ktx2Decoder/dist`,
1112
alias: {
12-
"core": path.resolve(__dirname, "../../../dev/core/dist"),
13+
core: path.resolve(__dirname, "../../../dev/core/dist"),
1314
},
1415
extendedWebpackConfig: {
1516
externals: {},
@@ -19,7 +20,7 @@ module.exports = (env) => {
1920
includeCSS: true,
2021
}),
2122
},
22-
}
23+
},
2324
});
2425
return commonConfig;
2526
};

packages/public/umd/babylonjs-loaders/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "babylonjs-loaders",
33
"version": "8.13.0",
4-
"main": "babylonjs.loaders.js",
4+
"main": "babylonjs.loaders.min.js",
55
"types": "babylonjs.loaders.module.d.ts",
66
"files": [
77
"*"
88
],
99
"scripts": {
10-
"build": "npm run clean && npm run build:dev && npm run build:prod && npm run build:declaration",
10+
"build": "npm run clean && npm run build:prod && npm run build:declaration",
1111
"build:dev": "webpack --env development",
1212
"build:prod": "webpack --env production",
1313
"build:declaration": "build-tools -c pud --config ./config.json",

0 commit comments

Comments
 (0)