@cms0/cms0 0.1.0 → 0.1.1
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.
|
@@ -120,10 +120,14 @@ async function loadUserConfig(configPath) {
|
|
|
120
120
|
const isEsmPkg = pkgType === "module";
|
|
121
121
|
if (isEsmPkg) {
|
|
122
122
|
const compiledHref = await transpileTsModuleToTemp(resolvedPath);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
try {
|
|
124
|
+
const imported = (await importByHref(compiledHref));
|
|
125
|
+
const config = imported?.default ?? imported?.config ?? imported ?? {};
|
|
126
|
+
return { path: resolvedPath, config };
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
cleanupTempModule(compiledHref);
|
|
130
|
+
}
|
|
127
131
|
}
|
|
128
132
|
const previous = process.env.TS_NODE_COMPILER_OPTIONS;
|
|
129
133
|
// register ts-node on demand so TypeScript configs can be required
|
|
@@ -144,10 +148,15 @@ async function loadUserConfig(configPath) {
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
|
-
const imported = (await
|
|
151
|
+
const imported = (await importByHref((0, url_1.pathToFileURL)(resolvedPath).href));
|
|
148
152
|
const config = imported?.default ?? imported?.config ?? imported ?? {};
|
|
149
153
|
return { path: resolvedPath, config };
|
|
150
154
|
}
|
|
155
|
+
async function importByHref(href) {
|
|
156
|
+
// Keep runtime import() intact in both ESM and CJS outputs.
|
|
157
|
+
const runImport = new Function("specifier", "return import(specifier);");
|
|
158
|
+
return runImport(href);
|
|
159
|
+
}
|
|
151
160
|
function resolvePaths(cfgPath, config) {
|
|
152
161
|
if (!config.entry) {
|
|
153
162
|
throw new Error("cms0: config.entry is required");
|
|
@@ -76,10 +76,14 @@ async function loadUserConfig(configPath) {
|
|
|
76
76
|
const isEsmPkg = pkgType === "module";
|
|
77
77
|
if (isEsmPkg) {
|
|
78
78
|
const compiledHref = await transpileTsModuleToTemp(resolvedPath);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
try {
|
|
80
|
+
const imported = (await importByHref(compiledHref));
|
|
81
|
+
const config = imported?.default ?? imported?.config ?? imported ?? {};
|
|
82
|
+
return { path: resolvedPath, config };
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
cleanupTempModule(compiledHref);
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
const previous = process.env.TS_NODE_COMPILER_OPTIONS;
|
|
85
89
|
// register ts-node on demand so TypeScript configs can be required
|
|
@@ -100,10 +104,15 @@ async function loadUserConfig(configPath) {
|
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
|
-
const imported = (await
|
|
107
|
+
const imported = (await importByHref(pathToFileURL(resolvedPath).href));
|
|
104
108
|
const config = imported?.default ?? imported?.config ?? imported ?? {};
|
|
105
109
|
return { path: resolvedPath, config };
|
|
106
110
|
}
|
|
111
|
+
async function importByHref(href) {
|
|
112
|
+
// Keep runtime import() intact in both ESM and CJS outputs.
|
|
113
|
+
const runImport = new Function("specifier", "return import(specifier);");
|
|
114
|
+
return runImport(href);
|
|
115
|
+
}
|
|
107
116
|
function resolvePaths(cfgPath, config) {
|
|
108
117
|
if (!config.entry) {
|
|
109
118
|
throw new Error("cms0: config.entry is required");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Cms0Config } from "@cms0/cms0/config";
|
|
2
|
-
import { ResolvedConfig } from "./types.js";
|
|
1
|
+
import type { Cms0Config } from "@cms0/cms0/config";
|
|
2
|
+
import type { ResolvedConfig } from "./types.js";
|
|
3
3
|
declare const DEFAULT_CONFIG_BASENAMES: string[];
|
|
4
4
|
declare function findConfigPath(provided?: string): string | undefined;
|
|
5
5
|
declare function loadUserConfig(configPath?: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/config-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../../../src/libs/cli/config-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,QAAA,MAAM,wBAAwB,UAM7B,CAAC;AAEF,iBAAS,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAmB7D;AA8BD,iBAAe,cAAc,CAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,SAAS,CAAC,CAsD3D;AAWD,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,CAkBzE;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAY3D;AA+BD,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,GACb,CAAC"}
|