@ionify/ionify 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+ const { parentPort } = require("worker_threads");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+ const { transform } = require("@swc/core");
5
+ const postcss = require("postcss");
6
+ const postcssLoadConfig = require("postcss-load-config");
7
+ const postcssModules = require("postcss-modules");
8
+
9
+ let cachedPostcssConfig = null;
10
+ let postcssConfigFailed = false;
11
+
12
+ async function loadPostcssConfig(rootDir) {
13
+ if (cachedPostcssConfig) return cachedPostcssConfig;
14
+ if (postcssConfigFailed) return { plugins: [], options: {} };
15
+ try {
16
+ const { plugins, options } = await postcssLoadConfig({}, rootDir);
17
+ cachedPostcssConfig = {
18
+ plugins: Array.isArray(plugins) ? plugins : [],
19
+ options: options ?? {},
20
+ };
21
+ } catch {
22
+ postcssConfigFailed = true;
23
+ cachedPostcssConfig = { plugins: [], options: {} };
24
+ }
25
+ return cachedPostcssConfig;
26
+ }
27
+
28
+ const enableSourceMaps = process.env.IONIFY_SOURCEMAPS === "true";
29
+
30
+ function parseMode() {
31
+ const mode = (process.env.IONIFY_PARSER || "hybrid").toLowerCase();
32
+ if (mode === "swc") return "swc";
33
+ if (mode === "oxc") return "oxc";
34
+ return "hybrid";
35
+ }
36
+
37
+ function resolveNativeBinding() {
38
+ // Minimal loader to avoid importing TS helpers in worker context.
39
+ const cwd = process.cwd();
40
+ const candidates = [
41
+ path.join(cwd, "native", "ionify_core.node"),
42
+ path.join(cwd, "target", "release", "ionify_core.node"),
43
+ path.join(cwd, "target", "debug", "ionify_core.node"),
44
+ ];
45
+ for (const candidate of candidates) {
46
+ try {
47
+ if (fs.existsSync(candidate)) {
48
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
49
+ return require(candidate);
50
+ }
51
+ } catch {
52
+ // ignore and try next
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+
58
+ const native = resolveNativeBinding();
59
+
60
+ async function runSwcTransform(job) {
61
+ const isTs = job.ext === ".ts" || job.ext === ".tsx";
62
+ const isTsx = job.ext === ".tsx";
63
+ const isJsx = job.ext === ".jsx";
64
+
65
+ const result = await transform(job.code, {
66
+ filename: job.filePath,
67
+ sourceMaps: enableSourceMaps ? "inline" : false,
68
+ minify: true,
69
+ module: { type: "es6" },
70
+ jsc: {
71
+ target: "es2022",
72
+ minify: {
73
+ compress: true,
74
+ mangle: true,
75
+ },
76
+ parser: isTs
77
+ ? {
78
+ syntax: "typescript",
79
+ tsx: isTsx,
80
+ decorators: true,
81
+ dynamicImport: true,
82
+ }
83
+ : {
84
+ syntax: "ecmascript",
85
+ jsx: isJsx,
86
+ decorators: true,
87
+ dynamicImport: true,
88
+ },
89
+ transform: isTsx || isJsx
90
+ ? {
91
+ react: {
92
+ development: false,
93
+ runtime: "automatic",
94
+ },
95
+ }
96
+ : undefined,
97
+ },
98
+ });
99
+
100
+ return { code: result.code, map: result.map || undefined, type: "js" };
101
+ }
102
+
103
+ async function runCssTransform(job) {
104
+ const rootDir = process.cwd();
105
+ const { plugins, options } = await loadPostcssConfig(rootDir);
106
+ const isModule = /\.module\.css$/i.test(job.filePath);
107
+
108
+ const pipeline = [...plugins];
109
+ if (isModule) {
110
+ pipeline.push(
111
+ postcssModules({
112
+ generateScopedName: (name, filename) => {
113
+ const base = path.basename(filename).replace(/\.[^.]+$/, "");
114
+ return `${base}__${name}`;
115
+ },
116
+ })
117
+ );
118
+ }
119
+
120
+ const runner = postcss(pipeline);
121
+ const result = await runner.process(job.code, {
122
+ ...options,
123
+ from: job.filePath,
124
+ map: false,
125
+ });
126
+
127
+ return { code: result.css, type: "css" };
128
+ }
129
+
130
+ function runNativeOxcTransform(job) {
131
+ if (!native?.parseAndTransformOxc) {
132
+ throw new Error("Native oxc transform not available");
133
+ }
134
+
135
+ const result = native.parseAndTransformOxc(job.code, {
136
+ filename: job.filePath,
137
+ jsx: job.ext === ".jsx" || job.ext === ".tsx",
138
+ typescript: job.ext === ".ts" || job.ext === ".tsx",
139
+ react_refresh: false, // Production build - no refresh
140
+ });
141
+
142
+ return { code: result.code, map: result.map || undefined, type: "js" };
143
+ }
144
+
145
+ function runNativeSwcTransform(job) {
146
+ if (!native?.parseAndTransformSwc) {
147
+ throw new Error("Native SWC transform not available");
148
+ }
149
+
150
+ const result = native.parseAndTransformSwc(job.code, {
151
+ filename: job.filePath,
152
+ jsx: job.ext === ".jsx" || job.ext === ".tsx",
153
+ typescript: job.ext === ".ts" || job.ext === ".tsx",
154
+ react_refresh: false, // Production build - no refresh
155
+ });
156
+
157
+ return { code: result.code, map: result.map || undefined, type: "js" };
158
+ }
159
+
160
+ async function handleJob(job) {
161
+ const mode = parseMode();
162
+ const ext = job.ext.toLowerCase();
163
+ if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
164
+ if (mode === "swc") {
165
+ // Force SWC via native or fallback
166
+ if (native?.parseAndTransformSwc) {
167
+ return runNativeSwcTransform(job);
168
+ }
169
+ return runSwcTransform(job);
170
+ }
171
+ if (mode === "oxc") {
172
+ // Force oxc via native (fail if unavailable)
173
+ if (!native?.parseAndTransformOxc) {
174
+ throw new Error("parser=oxc requires native binding");
175
+ }
176
+ return runNativeOxcTransform(job);
177
+ }
178
+ // hybrid: try native oxc, silent fallback to native swc or JS swc
179
+ if (native?.parseAndTransformOxc) {
180
+ try {
181
+ return runNativeOxcTransform(job);
182
+ } catch {
183
+ // Silent fallback
184
+ }
185
+ }
186
+ if (native?.parseAndTransformSwc) {
187
+ return runNativeSwcTransform(job);
188
+ }
189
+ // Last resort: JS-side SWC
190
+ return runSwcTransform(job);
191
+ }
192
+ if (ext === ".css") {
193
+ return runCssTransform(job);
194
+ }
195
+ return { code: job.code, type: "asset" };
196
+ }
197
+
198
+ parentPort.on("message", async (job) => {
199
+ try {
200
+ const result = await handleJob(job);
201
+ parentPort.postMessage({
202
+ id: job.id,
203
+ filePath: job.filePath,
204
+ code: result.code,
205
+ map: result.map,
206
+ type: result.type,
207
+ });
208
+ } catch (err) {
209
+ parentPort.postMessage({
210
+ id: job.id,
211
+ filePath: job.filePath,
212
+ code: job.code,
213
+ type: "asset",
214
+ error: err instanceof Error ? err.message : String(err),
215
+ });
216
+ }
217
+ });
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Ionify HMR client (SSE + Fetch handshake).
3
+ * Listens for graph-diff updates over SSE, then POSTs to fetch the payload.
4
+ * For now, reloads the page when a module is deleted or update fails.
5
+ */
6
+ import { showErrorOverlay, clearErrorOverlay } from "/__ionify_overlay.js";
7
+
8
+ const SSE_URL = "/__ionify_hmr";
9
+ const APPLY_URL = "/__ionify_hmr/apply";
10
+ const ERROR_URL = "/__ionify_hmr/error";
11
+
12
+ const log = (...args) => console.log("[Ionify HMR]", ...args);
13
+ const warn = (...args) => console.warn("[Ionify HMR]", ...args);
14
+
15
+ // Establish SSE channel used to notify about pending graph diffs.
16
+ const source = new EventSource(SSE_URL);
17
+
18
+ source.addEventListener("ready", () => {
19
+ log("connected");
20
+ });
21
+
22
+ source.addEventListener("error", (e) => {
23
+ warn("SSE error", e);
24
+ // Show overlay if server streamed a structured error payload.
25
+ if (e?.data) {
26
+ try {
27
+ const payload = JSON.parse(e.data);
28
+ if (payload?.message) {
29
+ showErrorOverlay(payload.message, payload.id ? `Update ${payload.id}` : undefined);
30
+ }
31
+ } catch {
32
+ showErrorOverlay(String(e.data || "HMR connection error"));
33
+ }
34
+ }
35
+ });
36
+
37
+ source.addEventListener("update", async (event) => {
38
+ let summary;
39
+ try {
40
+ summary = JSON.parse(event.data);
41
+ } catch (err) {
42
+ warn("invalid update payload", err);
43
+ return;
44
+ }
45
+ if (!summary || summary.type !== "update" || typeof summary.id !== "string") {
46
+ return;
47
+ }
48
+
49
+ log(`update ${summary.id} received (${summary.modules?.length ?? 0} modules)`);
50
+ clearErrorOverlay();
51
+
52
+ try {
53
+ const response = await fetch(APPLY_URL, {
54
+ method: "POST",
55
+ headers: { "Content-Type": "application/json" },
56
+ body: JSON.stringify({ id: summary.id }),
57
+ });
58
+ if (!response.ok) {
59
+ const text = await response.text();
60
+ throw new Error(text || `apply status ${response.status}`);
61
+ }
62
+ const payload = await response.json();
63
+ await applyUpdate(payload);
64
+ clearErrorOverlay();
65
+ } catch (err) {
66
+ await reportError(summary.id, err);
67
+ const message = err instanceof Error ? err.message : String(err);
68
+ showErrorOverlay("Failed to apply update", message);
69
+ warn("apply failed", err);
70
+ }
71
+ });
72
+
73
+ async function reportError(id, err) {
74
+ const message = err instanceof Error ? err.message : String(err);
75
+ try {
76
+ await fetch(ERROR_URL, {
77
+ method: "POST",
78
+ headers: { "Content-Type": "application/json" },
79
+ body: JSON.stringify({ id, message }),
80
+ });
81
+ } catch (_) {
82
+ // swallow network errors
83
+ }
84
+ }
85
+
86
+ async function applyUpdate(payload) {
87
+ const modules = Array.isArray(payload?.modules) ? payload.modules : [];
88
+ if (!modules.length) {
89
+ log(`update ${payload?.id ?? "unknown"} had no modules`);
90
+ return;
91
+ }
92
+
93
+ // if any module deleted, fallback to hard reload
94
+ if (modules.some((m) => m.status === "deleted")) {
95
+ warn("module deleted, reloading page");
96
+ location.reload();
97
+ return;
98
+ }
99
+
100
+ const timestamp = Date.now();
101
+ for (const mod of modules) {
102
+ if (!mod || typeof mod.url !== "string") continue;
103
+ // HTML imports still force reload until we add declarative overlays.
104
+ if (/\.(html)(\?|$)/.test(mod.url)) {
105
+ warn(`${mod.url} requires full reload`);
106
+ location.reload();
107
+ return;
108
+ }
109
+ const separator = mod.url.includes("?") ? "&" : "?";
110
+ const target = `${mod.url}${separator}ionify-hmr=${timestamp}`;
111
+ try {
112
+ await import(/* @vite-ignore */ target);
113
+ log(`refreshed ${mod.url}`);
114
+ } catch (err) {
115
+ await reportError(payload?.id, err);
116
+ const message = err instanceof Error ? err.message : String(err);
117
+ showErrorOverlay(`Failed to refresh ${mod.url}`, message);
118
+ warn(`failed to refresh ${mod.url}`, err);
119
+ return;
120
+ }
121
+ }
122
+ log(`update ${payload?.id ?? "unknown"} applied`);
123
+ clearErrorOverlay();
124
+ }
@@ -0,0 +1,43 @@
1
+ // Basic DOM overlay used to surface build/transform errors during HMR.
2
+ const OVERLAY_ID = "ionify-error-overlay";
3
+
4
+ function ensureOverlay() {
5
+ let overlay = document.getElementById(OVERLAY_ID);
6
+ if (!overlay) {
7
+ overlay = document.createElement("div");
8
+ overlay.id = OVERLAY_ID;
9
+ overlay.style.position = "fixed";
10
+ overlay.style.inset = "0";
11
+ overlay.style.background = "rgba(0,0,0,0.8)";
12
+ overlay.style.color = "#f87171";
13
+ overlay.style.fontFamily = "Menlo, Consolas, monospace";
14
+ overlay.style.fontSize = "14px";
15
+ overlay.style.padding = "32px";
16
+ overlay.style.zIndex = "2147483647";
17
+ overlay.style.overflowY = "auto";
18
+ overlay.style.whiteSpace = "pre-wrap";
19
+ document.body.appendChild(overlay);
20
+ }
21
+ return overlay;
22
+ }
23
+
24
+ export function showErrorOverlay(message, details) {
25
+ if (typeof document === "undefined") return;
26
+ const overlay = ensureOverlay();
27
+ const header = "Ionify Build Error";
28
+ overlay.innerHTML = `
29
+ <div style="font-weight:600;font-size:16px;margin-bottom:16px;">
30
+ ${header}
31
+ </div>
32
+ <div>${message ?? "Unknown error"}</div>
33
+ ${details ? `<pre style="margin-top:16px;color:#fca5a5;">${details}</pre>` : ""}
34
+ `;
35
+ }
36
+
37
+ export function clearErrorOverlay() {
38
+ if (typeof document === "undefined") return;
39
+ const overlay = document.getElementById(OVERLAY_ID);
40
+ if (overlay && overlay.parentElement) {
41
+ overlay.parentElement.removeChild(overlay);
42
+ }
43
+ }
@@ -0,0 +1,72 @@
1
+ import RefreshRuntime from "react-refresh/runtime";
2
+
3
+ let installed = false;
4
+ const moduleInfo = new Map();
5
+ const warnedClassModules = new Set();
6
+
7
+ function ensureRuntime() {
8
+ if (installed) return RefreshRuntime;
9
+ RefreshRuntime.injectIntoGlobalHook(window);
10
+ window.$RefreshReg$ = () => {};
11
+ window.$RefreshSig$ = () => (type) => type;
12
+ window.__IONIFY_REACT_REFRESH__ = RefreshRuntime;
13
+ installed = true;
14
+ return RefreshRuntime;
15
+ }
16
+
17
+ export function setupReactRefresh(importMetaHot, moduleId) {
18
+ if (!importMetaHot) return null;
19
+ const runtime = ensureRuntime();
20
+
21
+ // Track metadata for this module so we can make refresh decisions later.
22
+ const record = {
23
+ hasReactExport: false,
24
+ hasClassComponent: false,
25
+ };
26
+ moduleInfo.set(moduleId, record);
27
+
28
+ const prevReg = window.$RefreshReg$;
29
+ const prevSig = window.$RefreshSig$;
30
+
31
+ window.$RefreshReg$ = (type, id) => {
32
+ runtime.register(type, moduleId + " " + id);
33
+ if (type) {
34
+ record.hasReactExport = true;
35
+ if (type.prototype && type.prototype.isReactComponent) {
36
+ record.hasClassComponent = true;
37
+ }
38
+ }
39
+ };
40
+ window.$RefreshSig$ = runtime.createSignatureFunctionForTransform;
41
+
42
+ const finalize = () => {
43
+ window.$RefreshReg$ = prevReg;
44
+ window.$RefreshSig$ = prevSig;
45
+ };
46
+
47
+ const dispose = () => {
48
+ moduleInfo.delete(moduleId);
49
+ };
50
+
51
+ const refresh = () => {
52
+ if (!record.hasReactExport) return false;
53
+ if (record.hasClassComponent && !warnedClassModules.has(moduleId)) {
54
+ console.warn(
55
+ `[Ionify] React Fast Refresh cannot preserve state for class components (module: ${moduleId}). State will reset after edits.`
56
+ );
57
+ warnedClassModules.add(moduleId);
58
+ }
59
+ queueMicrotask(() => {
60
+ runtime.performReactRefresh();
61
+ });
62
+ return true;
63
+ };
64
+
65
+ return {
66
+ finalize,
67
+ refresh,
68
+ dispose,
69
+ hasReactExports: () => record.hasReactExport,
70
+ hasClassComponent: () => record.hasClassComponent,
71
+ };
72
+ }
@@ -0,0 +1,217 @@
1
+ const { parentPort } = require("worker_threads");
2
+ const path = require("path");
3
+ const fs = require("fs");
4
+ const { transform } = require("@swc/core");
5
+ const postcss = require("postcss");
6
+ const postcssLoadConfig = require("postcss-load-config");
7
+ const postcssModules = require("postcss-modules");
8
+
9
+ let cachedPostcssConfig = null;
10
+ let postcssConfigFailed = false;
11
+
12
+ async function loadPostcssConfig(rootDir) {
13
+ if (cachedPostcssConfig) return cachedPostcssConfig;
14
+ if (postcssConfigFailed) return { plugins: [], options: {} };
15
+ try {
16
+ const { plugins, options } = await postcssLoadConfig({}, rootDir);
17
+ cachedPostcssConfig = {
18
+ plugins: Array.isArray(plugins) ? plugins : [],
19
+ options: options ?? {},
20
+ };
21
+ } catch {
22
+ postcssConfigFailed = true;
23
+ cachedPostcssConfig = { plugins: [], options: {} };
24
+ }
25
+ return cachedPostcssConfig;
26
+ }
27
+
28
+ const enableSourceMaps = process.env.IONIFY_SOURCEMAPS === "true";
29
+
30
+ function parseMode() {
31
+ const mode = (process.env.IONIFY_PARSER || "hybrid").toLowerCase();
32
+ if (mode === "swc") return "swc";
33
+ if (mode === "oxc") return "oxc";
34
+ return "hybrid";
35
+ }
36
+
37
+ function resolveNativeBinding() {
38
+ // Minimal loader to avoid importing TS helpers in worker context.
39
+ const cwd = process.cwd();
40
+ const candidates = [
41
+ path.join(cwd, "native", "ionify_core.node"),
42
+ path.join(cwd, "target", "release", "ionify_core.node"),
43
+ path.join(cwd, "target", "debug", "ionify_core.node"),
44
+ ];
45
+ for (const candidate of candidates) {
46
+ try {
47
+ if (fs.existsSync(candidate)) {
48
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
49
+ return require(candidate);
50
+ }
51
+ } catch {
52
+ // ignore and try next
53
+ }
54
+ }
55
+ return null;
56
+ }
57
+
58
+ const native = resolveNativeBinding();
59
+
60
+ async function runSwcTransform(job) {
61
+ const isTs = job.ext === ".ts" || job.ext === ".tsx";
62
+ const isTsx = job.ext === ".tsx";
63
+ const isJsx = job.ext === ".jsx";
64
+
65
+ const result = await transform(job.code, {
66
+ filename: job.filePath,
67
+ sourceMaps: enableSourceMaps ? "inline" : false,
68
+ minify: true,
69
+ module: { type: "es6" },
70
+ jsc: {
71
+ target: "es2022",
72
+ minify: {
73
+ compress: true,
74
+ mangle: true,
75
+ },
76
+ parser: isTs
77
+ ? {
78
+ syntax: "typescript",
79
+ tsx: isTsx,
80
+ decorators: true,
81
+ dynamicImport: true,
82
+ }
83
+ : {
84
+ syntax: "ecmascript",
85
+ jsx: isJsx,
86
+ decorators: true,
87
+ dynamicImport: true,
88
+ },
89
+ transform: isTsx || isJsx
90
+ ? {
91
+ react: {
92
+ development: false,
93
+ runtime: "automatic",
94
+ },
95
+ }
96
+ : undefined,
97
+ },
98
+ });
99
+
100
+ return { code: result.code, map: result.map || undefined, type: "js" };
101
+ }
102
+
103
+ async function runCssTransform(job) {
104
+ const rootDir = process.cwd();
105
+ const { plugins, options } = await loadPostcssConfig(rootDir);
106
+ const isModule = /\.module\.css$/i.test(job.filePath);
107
+
108
+ const pipeline = [...plugins];
109
+ if (isModule) {
110
+ pipeline.push(
111
+ postcssModules({
112
+ generateScopedName: (name, filename) => {
113
+ const base = path.basename(filename).replace(/\.[^.]+$/, "");
114
+ return `${base}__${name}`;
115
+ },
116
+ })
117
+ );
118
+ }
119
+
120
+ const runner = postcss(pipeline);
121
+ const result = await runner.process(job.code, {
122
+ ...options,
123
+ from: job.filePath,
124
+ map: false,
125
+ });
126
+
127
+ return { code: result.css, type: "css" };
128
+ }
129
+
130
+ function runNativeOxcTransform(job) {
131
+ if (!native?.parseAndTransformOxc) {
132
+ throw new Error("Native oxc transform not available");
133
+ }
134
+
135
+ const result = native.parseAndTransformOxc(job.code, {
136
+ filename: job.filePath,
137
+ jsx: job.ext === ".jsx" || job.ext === ".tsx",
138
+ typescript: job.ext === ".ts" || job.ext === ".tsx",
139
+ react_refresh: false, // Production build - no refresh
140
+ });
141
+
142
+ return { code: result.code, map: result.map || undefined, type: "js" };
143
+ }
144
+
145
+ function runNativeSwcTransform(job) {
146
+ if (!native?.parseAndTransformSwc) {
147
+ throw new Error("Native SWC transform not available");
148
+ }
149
+
150
+ const result = native.parseAndTransformSwc(job.code, {
151
+ filename: job.filePath,
152
+ jsx: job.ext === ".jsx" || job.ext === ".tsx",
153
+ typescript: job.ext === ".ts" || job.ext === ".tsx",
154
+ react_refresh: false, // Production build - no refresh
155
+ });
156
+
157
+ return { code: result.code, map: result.map || undefined, type: "js" };
158
+ }
159
+
160
+ async function handleJob(job) {
161
+ const mode = parseMode();
162
+ const ext = job.ext.toLowerCase();
163
+ if ([".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"].includes(ext)) {
164
+ if (mode === "swc") {
165
+ // Force SWC via native or fallback
166
+ if (native?.parseAndTransformSwc) {
167
+ return runNativeSwcTransform(job);
168
+ }
169
+ return runSwcTransform(job);
170
+ }
171
+ if (mode === "oxc") {
172
+ // Force oxc via native (fail if unavailable)
173
+ if (!native?.parseAndTransformOxc) {
174
+ throw new Error("parser=oxc requires native binding");
175
+ }
176
+ return runNativeOxcTransform(job);
177
+ }
178
+ // hybrid: try native oxc, silent fallback to native swc or JS swc
179
+ if (native?.parseAndTransformOxc) {
180
+ try {
181
+ return runNativeOxcTransform(job);
182
+ } catch {
183
+ // Silent fallback
184
+ }
185
+ }
186
+ if (native?.parseAndTransformSwc) {
187
+ return runNativeSwcTransform(job);
188
+ }
189
+ // Last resort: JS-side SWC
190
+ return runSwcTransform(job);
191
+ }
192
+ if (ext === ".css") {
193
+ return runCssTransform(job);
194
+ }
195
+ return { code: job.code, type: "asset" };
196
+ }
197
+
198
+ parentPort.on("message", async (job) => {
199
+ try {
200
+ const result = await handleJob(job);
201
+ parentPort.postMessage({
202
+ id: job.id,
203
+ filePath: job.filePath,
204
+ code: result.code,
205
+ map: result.map,
206
+ type: result.type,
207
+ });
208
+ } catch (err) {
209
+ parentPort.postMessage({
210
+ id: job.id,
211
+ filePath: job.filePath,
212
+ code: job.code,
213
+ type: "asset",
214
+ error: err instanceof Error ? err.message : String(err),
215
+ });
216
+ }
217
+ });
package/dist/index.cjs ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ defineConfig: () => defineConfig
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/types.ts
29
+ function defineConfig(config) {
30
+ if (typeof config === "function") {
31
+ return config({ mode: process.env.NODE_ENV || "development" });
32
+ }
33
+ return config;
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ defineConfig
38
+ });