Skip to content

Commit 0af55f1

Browse files
authored
Inspector v2: umd cdn (#17379)
This is a follow up to my initial umd package PR: #17357 In the initial PR, the path I went was to redirect `inspector` to `inspector-v2` in the context of the Inspector v2 build, since they ultimately are the same package with different versions (v2 having the `-prefix` suffix). This was simpler, but it turns out doesn't work with the way we publish umd bundles to our cdn. For that, we need unique entries in the package mappings, so now I've added a separate entry for inspector-v2. This gets used by the prepareSnapshot script to determine what gets copied to the cdn. The way I set it up is the inspector v2 bundle gets copied to the inspector directory, but with a new unique name (babylon.inspector-v2.bundle.js). I tested the snapshot copy locally, but in the process I noticed that we were copying webpack.config.js files to the cdn (because they match the *.js glob). For example: https://cdn.babylonjs.com/webpack.config.js. @docEdub - we should probably try to figure out how to remove all these webpack.config.js files from the cdn. For now I'm making this PR draft so that I can verify the snapshot cdn functionality before merging, and also I don't want to touch any cdn publishing related stuff on a Friday afternoon. :)
1 parent a9bbac1 commit 0af55f1

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

packages/dev/buildTools/src/packageMapping.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export type DevPackageName =
1111
| "loaders"
1212
| "serializers"
1313
| "inspector"
14+
| "inspector-v2"
1415
| "post-processes"
1516
| "procedural-textures"
1617
| "node-editor"
@@ -33,6 +34,7 @@ export type UMDPackageName =
3334
| "babylonjs-materials"
3435
| "babylonjs-procedural-textures"
3536
| "babylonjs-inspector"
37+
| "babylonjs-inspector-v2"
3638
| "babylonjs-node-editor"
3739
| "babylonjs-node-geometry-editor"
3840
| "babylonjs-node-render-graph-editor"
@@ -124,6 +126,11 @@ export const umdPackageMapping: { [key in UMDPackageName]: { baseDir: string; ba
124126
baseFilename: "babylon.inspector",
125127
isBundle: true,
126128
},
129+
"babylonjs-inspector-v2": {
130+
baseDir: "inspector",
131+
baseFilename: "babylon.inspector-v2",
132+
isBundle: true,
133+
},
127134
"babylonjs-node-editor": {
128135
baseDir: "nodeEditor",
129136
baseFilename: "babylon.nodeEditor",
@@ -197,6 +204,7 @@ const packageMapping: {
197204
loaders: "babylonjs-loaders",
198205
serializers: "babylonjs-serializers",
199206
inspector: "babylonjs-inspector",
207+
"inspector-v2": "babylonjs-inspector-v2",
200208
"node-editor": (_filePath?: string) => {
201209
// if (filePath && filePath.indexOf("sharedUiComponents") !== -1) {
202210
// return "babylonjs-shared-ui-components";
@@ -244,6 +252,7 @@ const packageMapping: {
244252
loaders: "@babylonjs/loaders",
245253
serializers: "@babylonjs/serializers",
246254
inspector: "@babylonjs/inspector",
255+
"inspector-v2": "@babylonjs/inspector",
247256
"node-editor": "@babylonjs/node-editor",
248257
"node-geometry-editor": "@babylonjs/node-geometry-editor",
249258
"node-render-graph-editor": "@babylonjs/node-render-graph-editor",
@@ -266,6 +275,7 @@ const packageMapping: {
266275
loaders: "@babylonjs/esm",
267276
serializers: "@babylonjs/esm",
268277
inspector: "@babylonjs/esm",
278+
"inspector-v2": "@babylonjs/esm",
269279
"node-editor": "@babylonjs/esm",
270280
"node-geometry-editor": "@babylonjs/esm",
271281
"node-render-graph-editor": "@babylonjs/esm",
@@ -333,6 +343,18 @@ const packageMapping: {
333343
}
334344
return "INSPECTOR";
335345
},
346+
"inspector-v2": (filePath?: string) => {
347+
filePath = filePath?.replaceAll("\\", "/");
348+
if (filePath) {
349+
if (filePath.includes("shared-ui-components/") || filePath.includes("/sharedUiComponents/")) {
350+
// was .endsWith
351+
return "INSPECTOR.SharedUIComponents";
352+
} else if (filePath.includes("babylonjs-gltf2interface")) {
353+
return "BABYLON.GLTF2";
354+
}
355+
}
356+
return "INSPECTOR";
357+
},
336358
"node-editor": (filePath?: string) => {
337359
filePath = filePath?.replaceAll("\\", "/");
338360
if (filePath) {

packages/dev/buildTools/src/prepareSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const prepareSnapshot = () => {
1212
Object.keys(umdPackageMapping).forEach((packageName) => {
1313
const metadata = umdPackageMapping[packageName as UMDPackageName];
1414
const corePath = path.join(baseDirectory, "packages", "public", "umd", packageName);
15-
const coreUmd = globSync(`${corePath}/*+(.js|.d.ts|.map)`);
15+
const coreUmd = globSync(`${corePath}/*+(.js|.d.ts|.map)`).filter((file) => path.basename(file) !== "webpack.config.js");
1616
for (const file of coreUmd) {
1717
copyFile(file, path.join(snapshotDirectory, metadata.baseDir, path.basename(file)), true);
1818
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as inspector from "inspector/legacy/legacy";
1+
import * as inspector from "inspector-v2/legacy/legacy";
22
export { inspector };
33
export default inspector;

packages/public/umd/babylonjs-inspector-v2/tsconfig.build.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"compilerOptions": {
55
"outDir": "./dist",
66
"rootDir": "./src",
7-
"declaration": false,
8-
"paths": {
9-
"inspector/*": ["dev/inspector-v2/dist/*"]
10-
}
7+
"declaration": false
118
},
129
"include": ["./src/**/*"]
1310
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
{
2-
"extends": "../../../../tsconfig.json",
3-
"compilerOptions": {
4-
"paths": {
5-
"inspector/*": ["dev/inspector-v2/src/*"]
6-
}
7-
}
2+
"extends": "../../../../tsconfig.json"
83
}

packages/public/umd/babylonjs-inspector-v2/webpack.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module.exports = (env) => {
55
const commonConfig = commonConfigGenerator({
66
mode: env.production ? "production" : "development",
77
devPackageAliasPath: `../../../dev/inspector-v2/dist`,
8-
devPackageName: "inspector",
9-
overrideFilename: "babylon.inspector-v2",
8+
devPackageName: "inspector-v2",
109
namespace: "INSPECTOR",
1110
outputPath: path.resolve(__dirname),
1211
maxMode: true,

0 commit comments

Comments
 (0)