Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: explicitly mark fns to improve tree-shaking #130

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export default defineBuildConfig({
rollup: {
emitCJS: true,
esbuild: {
minify: true,
minifySyntax: true,
minifyIdentifiers: true,
},
},
entries: ["src/index"],
Expand Down
4 changes: 2 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export type EnvObject = Record<string, string | undefined>;
const _getEnv = (useShim?: boolean) =>
globalThis.process?.env ||
import.meta.env ||
globalThis.Deno?.env.toObject() ||
/* @__PURE__ */ globalThis.Deno?.env.toObject() ||
globalThis.__env__ ||
(useShim ? _envShim : globalThis);

export const env = new Proxy<EnvObject>(_envShim, {
export const env = /* @__PURE__ */ new Proxy<EnvObject>(_envShim, {
get(_, prop) {
const env = _getEnv();
return env[prop as any] ?? _envShim[prop];
Expand Down
5 changes: 4 additions & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ export const isColorSupported =

/** Node.js versions */
export const nodeVersion =
(globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
/* @__PURE__ */ (globalThis.process?.versions?.node || "").replace(
/^v/,
"",
) || null;
export const nodeMajorVersion = Number(nodeVersion?.split(".")[0]) || null;
2 changes: 1 addition & 1 deletion src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const processShims: Partial<Process> = {
versions: {},
};

export const process = new Proxy<Process>(_process, {
export const process = /* @__PURE__ */ new Proxy<Process>(_process, {
get(target, prop: keyof Process) {
if (prop === "env") {
return env;
Expand Down
2 changes: 1 addition & 1 deletion src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ function _detectProvider(): ProviderInfo {
}

/** Current provider info */
export const providerInfo = _detectProvider();
export const providerInfo = /* @__PURE__ */ _detectProvider();
export const provider: ProviderName = providerInfo.name;
2 changes: 1 addition & 1 deletion src/runtimes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ function _detectRuntime(): RuntimeInfo | undefined {
}
}

export const runtimeInfo = _detectRuntime();
export const runtimeInfo = /* @__PURE__ */ _detectRuntime();

export const runtime: RuntimeName = runtimeInfo?.name || "";
Loading