mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: Make webpack configuration trigger linkable-push
Previously this was done by lens-webpack-build, which is awkward for build-scripts that watch. Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
d28da8e7ac
commit
7114ee0e93
@ -25,7 +25,8 @@ exports[`get-multi-export-config given maximal package.json, when creating confi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
LinkablePushPlugin {}
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: '/some-working-directory/dist',
|
path: '/some-working-directory/dist',
|
||||||
@ -59,7 +60,8 @@ exports[`get-multi-export-config given maximal package.json, when creating confi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
LinkablePushPlugin {}
|
||||||
],
|
],
|
||||||
output: {
|
output: {
|
||||||
path: '/some-working-directory/dist/some-entrypoint',
|
path: '/some-working-directory/dist/some-entrypoint',
|
||||||
@ -94,6 +96,7 @@ exports[`get-multi-export-config given maximal package.json, when creating confi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
LinkablePushPlugin {},
|
||||||
MiniCssExtractPlugin {
|
MiniCssExtractPlugin {
|
||||||
_sortedModulesCache: WeakMap { <items unknown> },
|
_sortedModulesCache: WeakMap { <items unknown> },
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
|
|||||||
import type { Configuration } from "webpack";
|
import type { Configuration } from "webpack";
|
||||||
import { MakePeerDependenciesExternalPlugin } from "./plugins/make-peer-dependencies-external";
|
import { MakePeerDependenciesExternalPlugin } from "./plugins/make-peer-dependencies-external";
|
||||||
import { ProtectFromImportingNonDependencies } from "./plugins/protect-from-importing-non-dependencies";
|
import { ProtectFromImportingNonDependencies } from "./plugins/protect-from-importing-non-dependencies";
|
||||||
|
import { LinkablePushPlugin } from "./plugins/linkable-push-plugin";
|
||||||
|
|
||||||
export type Paths = {
|
export type Paths = {
|
||||||
entrypointFilePath: string;
|
entrypointFilePath: string;
|
||||||
@ -44,6 +45,8 @@ export const getNodeConfig = ({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
new LinkablePushPlugin(),
|
||||||
],
|
],
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { pushLink } from "@ogre-tools/linkable";
|
||||||
|
import type { Compiler } from "webpack";
|
||||||
|
|
||||||
|
export class LinkablePushPlugin {
|
||||||
|
apply(compiler: Compiler) {
|
||||||
|
compiler.hooks.afterEmit.tap("LinkablePushPlugin", async () => {
|
||||||
|
await pushLink();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -51,68 +51,10 @@ describe("do-webpack-build", () => {
|
|||||||
expect(logSuccessMock).toHaveBeenCalledWith("some-stdout");
|
expect(logSuccessMock).toHaveBeenCalledWith("some-stdout");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("makes the built package available for local packages in development that link to it", () => {
|
it("script is done", async () => {
|
||||||
expect(execMock).toHaveBeenCalledWith("linkable-push");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not finish script yet", async () => {
|
|
||||||
const promiseStatus = await getPromiseStatus(actualPromise);
|
const promiseStatus = await getPromiseStatus(actualPromise);
|
||||||
|
|
||||||
expect(promiseStatus.fulfilled).toBe(false);
|
expect(promiseStatus.fulfilled).toBe(true);
|
||||||
});
|
|
||||||
|
|
||||||
describe("when linking resolves with stdout", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
logSuccessMock.mockClear();
|
|
||||||
|
|
||||||
await execMock.resolve({ stdout: "some-other-stdout", stderr: "" });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("logs the stdout", () => {
|
|
||||||
expect(logSuccessMock).toHaveBeenCalledWith("some-other-stdout");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("script finishes", async () => {
|
|
||||||
const promiseStatus = await getPromiseStatus(actualPromise);
|
|
||||||
|
|
||||||
expect(promiseStatus.fulfilled).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when linking resolves with stderr", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
logSuccessMock.mockClear();
|
|
||||||
|
|
||||||
execMock.resolve({ stdout: "", stderr: "some-other-stderr" });
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not log success", () => {
|
|
||||||
actualPromise.catch(() => {});
|
|
||||||
|
|
||||||
expect(logSuccessMock).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("logs a warning", () => {
|
|
||||||
expect(logWarningMock).toBeCalledWith("Warning while executing \"linkable-push\": some-other-stderr");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when linking rejects", () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
logSuccessMock.mockClear();
|
|
||||||
|
|
||||||
execMock.reject(new Error("some-other-error"));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not log success", () => {
|
|
||||||
actualPromise.catch(() => {});
|
|
||||||
|
|
||||||
expect(logSuccessMock).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("throws", () => {
|
|
||||||
return expect(actualPromise).rejects.toThrow("some-other-error");
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -25,8 +25,6 @@ export const doWebpackBuildInjectable = getInjectable({
|
|||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
await execWithResultHandling("webpack");
|
await execWithResultHandling("webpack");
|
||||||
|
|
||||||
await execWithResultHandling("linkable-push");
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user