mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove webpack.*.ts importing values from src/ (#4992)
This commit is contained in:
1 parent
d5528eb9fe
commit
e977890677
21 files changed
+149
-168
No files matched your search
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import esbuild from "esbuild";
|
||||
import type { Options as TSLoaderOptions } from "ts-loader";
|
||||
|
||||
/**
|
||||
* A function returning webpack ts/tsx loader
|
||||
* depends on env LENS_DEV_USE_ESBUILD_LOADER to use esbuild-loader (faster) or good-old ts-loader
|
||||
* @returns ts/tsx webpack loader configuration object
|
||||
*/
|
||||
const getTSLoader = (options: Partial<TSLoaderOptions> = {}, testRegExp?: RegExp) => {
|
||||
testRegExp ??= /\.tsx?$/; // by default covers react/jsx-stuff
|
||||
options.transpileOnly ??= true;
|
||||
|
||||
if (process.env.LENS_DEV_USE_ESBUILD_LOADER === "true") {
|
||||
console.info(`\n🚀 using esbuild-loader for ts(x)`);
|
||||
|
||||
return {
|
||||
test: testRegExp,
|
||||
loader: "esbuild-loader",
|
||||
options: {
|
||||
loader: "tsx",
|
||||
target: "ES2019", // supported by >= electron@14
|
||||
implementation: esbuild,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
test: testRegExp,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: "ts-loader",
|
||||
options,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default getTSLoader;
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
// Setup variable in global scope (top-level object)
|
||||
// Global type definition must be added separately to `mocks.d.ts` in form:
|
||||
// declare const __globalName: any;
|
||||
|
||||
export function defineGlobal(propName: string, descriptor: PropertyDescriptor) {
|
||||
const scope = typeof global !== "undefined" ? global : window;
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(scope, propName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object.defineProperty(scope, propName, descriptor);
|
||||
}
|
||||
@@ -20,7 +20,6 @@ export * from "./collection-functions";
|
||||
export * from "./convertCpu";
|
||||
export * from "./convertMemory";
|
||||
export * from "./debouncePromise";
|
||||
export * from "./defineGlobal";
|
||||
export * from "./delay";
|
||||
export * from "./disposer";
|
||||
export * from "./downloadFile";
|
||||
|
||||
+6
-23
@@ -7,7 +7,6 @@
|
||||
import path from "path";
|
||||
import { SemVer } from "semver";
|
||||
import packageInfo from "../../package.json";
|
||||
import { defineGlobal } from "./utils/defineGlobal";
|
||||
import { lazyInitialized } from "./utils/lazy-initialized";
|
||||
|
||||
export const isMac = process.platform === "darwin";
|
||||
@@ -101,26 +100,12 @@ export const kubectlBinaryName = getBinaryName("kubectl");
|
||||
* @deprecated for being explicit side effect.
|
||||
*/
|
||||
export const kubectlBinaryPath = lazyInitialized(() => path.join(baseBinariesDir.get(), kubectlBinaryName));
|
||||
|
||||
// Webpack build paths
|
||||
export const contextDir = process.cwd();
|
||||
export const buildDir = path.join(contextDir, "static", publicPath);
|
||||
export const preloadEntrypoint = path.join(contextDir, "src/preload.ts");
|
||||
export const mainDir = path.join(contextDir, "src/main");
|
||||
export const rendererDir = path.join(contextDir, "src/renderer");
|
||||
export const htmlTemplate = path.resolve(rendererDir, "template.html");
|
||||
export const sassCommonVars = path.resolve(rendererDir, "components/vars.scss");
|
||||
|
||||
// Special runtime paths
|
||||
defineGlobal("__static", {
|
||||
get() {
|
||||
const root = isDevelopment
|
||||
? contextDir
|
||||
: (process.resourcesPath ?? contextDir);
|
||||
|
||||
return path.resolve(root, "static");
|
||||
},
|
||||
});
|
||||
export const staticFilesDirectory = path.resolve(
|
||||
!isProduction
|
||||
? process.cwd()
|
||||
: process.resourcesPath,
|
||||
"static",
|
||||
);
|
||||
|
||||
// Apis
|
||||
export const apiPrefix = "/api" as string; // local router apis
|
||||
@@ -142,5 +127,3 @@ export const appSemVer = new SemVer(packageInfo.version);
|
||||
export const docsUrl = "https://docs.k8slens.dev/main/" as string;
|
||||
|
||||
export const sentryDsn = packageInfo.config?.sentryDsn ?? "";
|
||||
|
||||
export const webpackDevServerPort: number = Number(process.env.WEBPACK_DEV_SERVER_PORT) || 9191;
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { contextDir } from "../vars";
|
||||
|
||||
const contextDirInjectable = getInjectable({
|
||||
id: "context-dir",
|
||||
instantiate: () => contextDir,
|
||||
});
|
||||
|
||||
export default contextDirInjectable;
|
||||
Reference in new issue
Block a user