Skip to content

Commit c483b98

Browse files
authored
[WTF-2697]: Widget Bundler 11.11.0 does not copy (all) files on windows (#185)
Checklist Contains unit tests ✅ Contains breaking changes ❌ Compatible with: MX 9️⃣ (11.x) Did you update version and changelog? ✅ changelog / ❌ version PR title properly formatted? ✅ This PR contains Bug fix What is the purpose of this PR? Fix Windows builds producing an .mpk missing the widget's .xml files and icon/tile PNGs. Relevant changes The copy step used absolute drive-letter globs that fast-glob returns empty for on Windows, so the widget files were silently skipped; switched both rollup configs to relative globs and added an assertion in command-tests so an incomplete .mpk What should be covered while testing? Build on Windows and Linux; confirm the .mpk contains package.xml and .xml (and PNGs when present in src).
2 parents 869952b + f651e90 commit c483b98

4 files changed

Lines changed: 27 additions & 23 deletions

File tree

packages/command-tests/commands.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -218,31 +218,31 @@ async function main() {
218218

219219
async function testBuild() {
220220
await execAsync("npm run build", workDir, logger);
221-
if (
222-
!existsSync(
223-
join(
224-
workDir,
225-
`/dist/${widgetPackageJson.version}/${widgetPackageJson.packagePath}.${widgetPackageJson.widgetName}.mpk`
226-
)
227-
)
228-
) {
229-
throw new Error("Expected mpk file to be generated, but it wasn't.");
230-
}
221+
checkWidgetBundleFiles();
231222
}
232223

233224
async function testRelease() {
234225
rm("-rf", join(workDir, "dist"));
235226
await execAsync("npm run release", workDir, logger);
227+
checkWidgetBundleFiles();
228+
}
236229

237-
if (
238-
!existsSync(
239-
join(
240-
workDir,
241-
`/dist/${widgetPackageJson.version}/${widgetPackageJson.packagePath}.${widgetPackageJson.widgetName}.mpk`
242-
)
243-
)
244-
) {
245-
throw new Error("Expected mpk file to be generated, but it wasn't.");
230+
function checkWidgetBundleFiles() {
231+
const stagingDir = join(workDir, "dist", "tmp", "widgets");
232+
const mpkFile = join(
233+
workDir,
234+
"dist",
235+
widgetPackageJson.version,
236+
`${widgetPackageJson.packagePath}.${widgetPackageJson.widgetName}.mpk`
237+
);
238+
const requiredFiles = [
239+
mpkFile,
240+
join(stagingDir, "package.xml"),
241+
join(stagingDir, `${widgetPackageJson.widgetName}.xml`)
242+
];
243+
const missing = requiredFiles.filter(f => !existsSync(f));
244+
if (missing.length) {
245+
throw new Error(`Expected widget bundle files in mpk, but missing: ${missing.join(", ")}.`);
246246
}
247247
}
248248

packages/pluggable-widgets-tools/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed an issue on Windows where the generated `.mpk` was missing the widget's `.xml` files and icon/tile PNGs.
12+
913
### Changed
1014

1115
- We replaced `ts-jest` with `@swc/jest` as the Jest transform (3–5× faster for TSX-heavy test suites) and switched the test runner from `jest-jasmine2` to `jest-circus`.

packages/pluggable-widgets-tools/configs/rollup.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ export default async args => {
320320
clear({ targets: [outDir, mpkDir] }),
321321
command([
322322
() => {
323-
cp(join(sourcePath, "src/**/*.xml"), outDir);
323+
cp("src/**/*.xml", outDir);
324324
if (existsSync(`src/${widgetName}.icon.png`) || existsSync(`src/${widgetName}.tile.png`)) {
325-
cp(join(sourcePath, `src/${widgetName}.@(tile|icon)?(.dark).png`), outDir);
325+
cp(`src/${widgetName}.@(tile|icon)?(.dark).png`, outDir);
326326
}
327327
}
328328
]),

packages/pluggable-widgets-tools/configs/rollup.config.native.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ export default async args => {
257257
clear({ targets: [outDir, mpkDir] }),
258258
command([
259259
() => {
260-
cp(join(sourcePath, "src/**/*.xml"), outDir);
260+
cp("src/**/*.xml", outDir);
261261
if (existsSync(`src/${widgetName}.icon.png`) || existsSync(`src/${widgetName}.tile.png`)) {
262-
cp(join(sourcePath, `src/${widgetName}.@(tile|icon)?(.dark).png`), outDir);
262+
cp(`src/${widgetName}.@(tile|icon)?(.dark).png`, outDir);
263263
}
264264
}
265265
])

0 commit comments

Comments
 (0)