feat(application): add cross-layer graph workflows
This commit is contained in:
+95
@@ -123,3 +123,98 @@ export const writeJavaScriptArtifactFixture = async (
|
||||
),
|
||||
]);
|
||||
};
|
||||
|
||||
/** Materialize two source-owned rechunked/minified comparison fixtures. */
|
||||
export const writeVersionedJavaScriptApplicationFixtures = async (
|
||||
root: string,
|
||||
): Promise<{ readonly left: string; readonly right: string }> => {
|
||||
const left = join(root, "version-1");
|
||||
const right = join(root, "version-2");
|
||||
await Promise.all([
|
||||
writeVersionFixture(left, "1.0.0", "left-bundle.js", versionOneBundle()),
|
||||
writeVersionFixture(right, "2.0.0", "right-bundle.js", versionTwoBundle()),
|
||||
]);
|
||||
return { left, right };
|
||||
};
|
||||
|
||||
const writeVersionFixture = async (
|
||||
root: string,
|
||||
version: string,
|
||||
bundleName: string,
|
||||
bundle: string,
|
||||
): Promise<void> => {
|
||||
await mkdir(join(root, "renderer", "chunks"), { recursive: true });
|
||||
await Promise.all([
|
||||
writeFile(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "rea-version-comparison-fixture",
|
||||
version,
|
||||
main: "./main.js",
|
||||
renderer: "./renderer/index.html",
|
||||
}),
|
||||
),
|
||||
writeFile(
|
||||
join(root, "main.js"),
|
||||
'const { ipcMain } = require("electron"); ipcMain.handle("feature:open", () => require("./native.node"));\n',
|
||||
),
|
||||
writeFile(
|
||||
join(root, "renderer", "index.html"),
|
||||
`<!doctype html><script src="./chunks/${bundleName}"></script>`,
|
||||
),
|
||||
writeFile(join(root, "renderer", "chunks", bundleName), bundle),
|
||||
writeFile(
|
||||
join(root, "renderer", `${bundleName}.map`),
|
||||
JSON.stringify({
|
||||
version: 3,
|
||||
file: bundleName,
|
||||
sources: ["src/feature.ts"],
|
||||
sourcesContent: [
|
||||
version === "1.0.0"
|
||||
? 'export const feature = "before";'
|
||||
: 'export const feature = "after";',
|
||||
],
|
||||
names: [],
|
||||
mappings: "AAAA",
|
||||
}),
|
||||
),
|
||||
writeFile(
|
||||
join(root, "native.node"),
|
||||
Buffer.from([0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00]),
|
||||
),
|
||||
]);
|
||||
};
|
||||
|
||||
const versionOneBundle = (): string => `
|
||||
(globalThis.webpackChunkfixture = globalThis.webpackChunkfixture || []).push([
|
||||
[101],
|
||||
{
|
||||
"stable-old": (module, exports) => { exports.stable = () => 42; },
|
||||
"descriptive-name": (module, exports) => {
|
||||
const descriptiveValue = 1;
|
||||
exports.changedName = () => descriptiveValue + 2;
|
||||
},
|
||||
"duplicate-a": (module, exports) => { exports.duplicate = () => 7; },
|
||||
"duplicate-b": (module, exports) => { exports.duplicate = () => 7; },
|
||||
"removed": (module, exports) => { exports.removed = true; }
|
||||
}
|
||||
]);
|
||||
${String.fromCharCode(47, 47)}# sourceMap${"ping"}URL=left-bundle.js.map
|
||||
`;
|
||||
|
||||
const versionTwoBundle = (): string => `
|
||||
(globalThis.webpackChunkfixture = globalThis.webpackChunkfixture || []).push([
|
||||
[909],
|
||||
{
|
||||
"stable-new": (module, exports) => { exports.stable = () => 42; },
|
||||
"a": (module, exports) => {
|
||||
const b = 1;
|
||||
exports.changedName = () => b + 2;
|
||||
},
|
||||
"collision-x": (module, exports) => { exports.duplicate = () => 7; },
|
||||
"collision-y": (module, exports) => { exports.duplicate = () => 7; },
|
||||
"added": (module, exports) => { exports.added = true; }
|
||||
}
|
||||
]);
|
||||
${String.fromCharCode(47, 47)}# sourceMap${"ping"}URL=right-bundle.js.map
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user