@bamboocss/config 1.45.5 → 1.46.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.
- package/dist/index.cjs +63 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +63 -4
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -34,8 +34,7 @@ let microdiff = require("microdiff");
|
|
|
34
34
|
microdiff = __toESM(microdiff);
|
|
35
35
|
let fs = require("fs");
|
|
36
36
|
fs = __toESM(fs);
|
|
37
|
-
let
|
|
38
|
-
typescript = __toESM(typescript);
|
|
37
|
+
let node_module = require("node:module");
|
|
39
38
|
//#region src/is-bamboo-config.ts
|
|
40
39
|
const configName = "bamboo";
|
|
41
40
|
const bambooConfigFiles = new Set([
|
|
@@ -293,6 +292,16 @@ function escapeStringRegexp(string) {
|
|
|
293
292
|
}
|
|
294
293
|
//#endregion
|
|
295
294
|
//#region src/get-mod-deps.ts
|
|
295
|
+
/**
|
|
296
|
+
* The compiler, loaded the first time a bare specifier in a config file needs resolving.
|
|
297
|
+
*
|
|
298
|
+
* This module is re-exported from the package entrypoint, so a static import made every
|
|
299
|
+
* consumer of `@bamboocss/config` load a second full TypeScript — 155ms, on top of the copy
|
|
300
|
+
* ts-morph already bundles — for one `resolveModuleName` call that a config with only relative
|
|
301
|
+
* imports never reaches. `getConfigDependencies` is synchronous, so this is a lazy `require`.
|
|
302
|
+
*/
|
|
303
|
+
let compiler;
|
|
304
|
+
const ts = () => compiler ??= (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("typescript");
|
|
296
305
|
const jsExtensions = [
|
|
297
306
|
".js",
|
|
298
307
|
".cjs",
|
|
@@ -366,7 +375,8 @@ function getDeps(opts, fromAlias) {
|
|
|
366
375
|
return;
|
|
367
376
|
}
|
|
368
377
|
try {
|
|
369
|
-
const
|
|
378
|
+
const compiler = ts();
|
|
379
|
+
const found = compiler.resolveModuleName(mod, absoluteFile, compilerOptions, compiler.sys).resolvedModule;
|
|
370
380
|
if (found && found.extension.endsWith("ts")) {
|
|
371
381
|
getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
|
|
372
382
|
return;
|
|
@@ -715,6 +725,36 @@ function mergeConfigs(configs) {
|
|
|
715
725
|
return withoutEmpty;
|
|
716
726
|
}
|
|
717
727
|
//#endregion
|
|
728
|
+
//#region src/resolution-provenance.ts
|
|
729
|
+
/**
|
|
730
|
+
* Private provenance carried from config evaluation to the Node extraction policy.
|
|
731
|
+
*
|
|
732
|
+
* It is deliberately absent from the package entrypoint and from `LoadConfigResult`'s public
|
|
733
|
+
* shape. A non-enumerable registered symbol survives the config package's ESM/CJS boundary
|
|
734
|
+
* without changing serialization, hook arguments, object spreads, or documented API keys.
|
|
735
|
+
*/
|
|
736
|
+
const CONFIG_RESOLUTION_PROVENANCE = Symbol.for("@bamboocss/config-resolution-provenance/v1");
|
|
737
|
+
const presetProvenance = /* @__PURE__ */ new WeakMap();
|
|
738
|
+
const rememberExternalPreset = (config, externalPresets) => {
|
|
739
|
+
presetProvenance.set(config, externalPresets);
|
|
740
|
+
};
|
|
741
|
+
const takeExternalPresets = (config) => presetProvenance.get(config) ?? [];
|
|
742
|
+
const attachConfigResolutionProvenance = (target, value) => {
|
|
743
|
+
Object.defineProperty(target, CONFIG_RESOLUTION_PROVENANCE, {
|
|
744
|
+
configurable: false,
|
|
745
|
+
enumerable: false,
|
|
746
|
+
value: Object.freeze({
|
|
747
|
+
baseline: Object.freeze({ ...value.baseline }),
|
|
748
|
+
bundleDependencies: Object.freeze([...value.bundleDependencies]),
|
|
749
|
+
externalPresets: Object.freeze(value.externalPresets.map((entry) => Object.freeze({
|
|
750
|
+
...entry,
|
|
751
|
+
dependencies: Object.freeze([...entry.dependencies])
|
|
752
|
+
})))
|
|
753
|
+
}),
|
|
754
|
+
writable: false
|
|
755
|
+
});
|
|
756
|
+
};
|
|
757
|
+
//#endregion
|
|
718
758
|
//#region src/get-resolved-config.ts
|
|
719
759
|
const hookUtils$1 = {
|
|
720
760
|
omit: _bamboocss_shared.omit,
|
|
@@ -727,6 +767,7 @@ const hookUtils$1 = {
|
|
|
727
767
|
async function getResolvedConfig(config, cwd, hooks) {
|
|
728
768
|
const stack = [config];
|
|
729
769
|
const configs = [];
|
|
770
|
+
const externalPresets = [];
|
|
730
771
|
while (stack.length > 0) {
|
|
731
772
|
const current = stack.pop();
|
|
732
773
|
const subPresets = current.presets ?? [];
|
|
@@ -734,8 +775,14 @@ async function getResolvedConfig(config, cwd, hooks) {
|
|
|
734
775
|
let presetConfig;
|
|
735
776
|
let presetName;
|
|
736
777
|
if (typeof subPreset === "string") {
|
|
737
|
-
|
|
778
|
+
const presetModule = await bundle(subPreset, cwd);
|
|
779
|
+
presetConfig = presetModule.config;
|
|
738
780
|
presetName = subPreset;
|
|
781
|
+
externalPresets.push({
|
|
782
|
+
dependencies: [...presetModule.dependencies],
|
|
783
|
+
index: externalPresets.length,
|
|
784
|
+
specifier: subPreset
|
|
785
|
+
});
|
|
739
786
|
} else {
|
|
740
787
|
presetConfig = await subPreset;
|
|
741
788
|
presetName = presetConfig.name || "unknown-preset";
|
|
@@ -754,6 +801,7 @@ async function getResolvedConfig(config, cwd, hooks) {
|
|
|
754
801
|
}
|
|
755
802
|
const merged = mergeConfigs(configs);
|
|
756
803
|
merged.presets = configs.slice(0, -1);
|
|
804
|
+
rememberExternalPreset(merged, externalPresets);
|
|
757
805
|
return merged;
|
|
758
806
|
}
|
|
759
807
|
//#endregion
|
|
@@ -1225,6 +1273,7 @@ async function resolveConfig(result, cwd) {
|
|
|
1225
1273
|
warnIfBaseDropped(listed, result.config.presets);
|
|
1226
1274
|
const hooks = mergeHooks(result.config.plugins ?? []);
|
|
1227
1275
|
const mergedConfig = await getResolvedConfig(result.config, cwd, hooks);
|
|
1276
|
+
const externalPresets = takeExternalPresets(mergedConfig);
|
|
1228
1277
|
if (mergedConfig.logLevel) _bamboocss_logger.logger.level = mergedConfig.logLevel;
|
|
1229
1278
|
if (mergedConfig.logFilter) _bamboocss_logger.logger.filter = mergedConfig.logFilter;
|
|
1230
1279
|
validateConfig(mergedConfig);
|
|
@@ -1246,12 +1295,21 @@ async function resolveConfig(result, cwd) {
|
|
|
1246
1295
|
presets: []
|
|
1247
1296
|
}));
|
|
1248
1297
|
const deserialize = () => (0, _bamboocss_shared.parseJson)(serialized);
|
|
1249
|
-
|
|
1298
|
+
const resolved = {
|
|
1250
1299
|
...loadConfigResult,
|
|
1251
1300
|
serialized,
|
|
1252
1301
|
deserialize,
|
|
1253
1302
|
hooks
|
|
1254
1303
|
};
|
|
1304
|
+
attachConfigResolutionProvenance(resolved, {
|
|
1305
|
+
baseline: {
|
|
1306
|
+
deserialize,
|
|
1307
|
+
serialized
|
|
1308
|
+
},
|
|
1309
|
+
bundleDependencies: result.dependencies,
|
|
1310
|
+
externalPresets
|
|
1311
|
+
});
|
|
1312
|
+
return resolved;
|
|
1255
1313
|
}
|
|
1256
1314
|
//#endregion
|
|
1257
1315
|
//#region src/load-config.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { preset as presetBase } from "@bamboocss/preset-base";
|
|
2
2
|
import { preset as presetBamboo } from "@bamboocss/preset-bamboo";
|
|
3
|
-
import { CompilerOptions, TypeAcquisition } from "typescript";
|
|
4
3
|
import { BambooHooks as BambooHooks$1, BambooPlugin, Config, ConfigTsOptions, DiffConfigResult, LoadConfigResult as LoadConfigResult$1 } from "@bamboocss/types";
|
|
4
|
+
import { CompilerOptions, TypeAcquisition } from "typescript";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
7
|
interface ConfigFileOptions {
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { logger } from "@bamboocss/logger";
|
|
2
3
|
import { BAMBOO_CONFIG_NAME, BambooError, assign, dashCase, isObject, isString, mergeAndConcat, mergeWith, omit, parseJson, pick, stringifyJson, traverse, walkObject } from "@bamboocss/shared";
|
|
3
4
|
import { bundleNRequire } from "bundle-n-require";
|
|
@@ -7,7 +8,6 @@ import { preset as presetBase } from "@bamboocss/preset-base";
|
|
|
7
8
|
import { preset as presetBamboo } from "@bamboocss/preset-bamboo";
|
|
8
9
|
import microdiff from "microdiff";
|
|
9
10
|
import fs from "fs";
|
|
10
|
-
import ts from "typescript";
|
|
11
11
|
//#region src/is-bamboo-config.ts
|
|
12
12
|
const configName = "bamboo";
|
|
13
13
|
const bambooConfigFiles = new Set([
|
|
@@ -265,6 +265,16 @@ function escapeStringRegexp(string) {
|
|
|
265
265
|
}
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/get-mod-deps.ts
|
|
268
|
+
/**
|
|
269
|
+
* The compiler, loaded the first time a bare specifier in a config file needs resolving.
|
|
270
|
+
*
|
|
271
|
+
* This module is re-exported from the package entrypoint, so a static import made every
|
|
272
|
+
* consumer of `@bamboocss/config` load a second full TypeScript — 155ms, on top of the copy
|
|
273
|
+
* ts-morph already bundles — for one `resolveModuleName` call that a config with only relative
|
|
274
|
+
* imports never reaches. `getConfigDependencies` is synchronous, so this is a lazy `require`.
|
|
275
|
+
*/
|
|
276
|
+
let compiler;
|
|
277
|
+
const ts = () => compiler ??= createRequire(import.meta.url)("typescript");
|
|
268
278
|
const jsExtensions = [
|
|
269
279
|
".js",
|
|
270
280
|
".cjs",
|
|
@@ -338,7 +348,8 @@ function getDeps(opts, fromAlias) {
|
|
|
338
348
|
return;
|
|
339
349
|
}
|
|
340
350
|
try {
|
|
341
|
-
const
|
|
351
|
+
const compiler = ts();
|
|
352
|
+
const found = compiler.resolveModuleName(mod, absoluteFile, compilerOptions, compiler.sys).resolvedModule;
|
|
342
353
|
if (found && found.extension.endsWith("ts")) {
|
|
343
354
|
getDeps(Object.assign({}, nextOpts, { filename: found.resolvedFileName }));
|
|
344
355
|
return;
|
|
@@ -687,6 +698,36 @@ function mergeConfigs(configs) {
|
|
|
687
698
|
return withoutEmpty;
|
|
688
699
|
}
|
|
689
700
|
//#endregion
|
|
701
|
+
//#region src/resolution-provenance.ts
|
|
702
|
+
/**
|
|
703
|
+
* Private provenance carried from config evaluation to the Node extraction policy.
|
|
704
|
+
*
|
|
705
|
+
* It is deliberately absent from the package entrypoint and from `LoadConfigResult`'s public
|
|
706
|
+
* shape. A non-enumerable registered symbol survives the config package's ESM/CJS boundary
|
|
707
|
+
* without changing serialization, hook arguments, object spreads, or documented API keys.
|
|
708
|
+
*/
|
|
709
|
+
const CONFIG_RESOLUTION_PROVENANCE = Symbol.for("@bamboocss/config-resolution-provenance/v1");
|
|
710
|
+
const presetProvenance = /* @__PURE__ */ new WeakMap();
|
|
711
|
+
const rememberExternalPreset = (config, externalPresets) => {
|
|
712
|
+
presetProvenance.set(config, externalPresets);
|
|
713
|
+
};
|
|
714
|
+
const takeExternalPresets = (config) => presetProvenance.get(config) ?? [];
|
|
715
|
+
const attachConfigResolutionProvenance = (target, value) => {
|
|
716
|
+
Object.defineProperty(target, CONFIG_RESOLUTION_PROVENANCE, {
|
|
717
|
+
configurable: false,
|
|
718
|
+
enumerable: false,
|
|
719
|
+
value: Object.freeze({
|
|
720
|
+
baseline: Object.freeze({ ...value.baseline }),
|
|
721
|
+
bundleDependencies: Object.freeze([...value.bundleDependencies]),
|
|
722
|
+
externalPresets: Object.freeze(value.externalPresets.map((entry) => Object.freeze({
|
|
723
|
+
...entry,
|
|
724
|
+
dependencies: Object.freeze([...entry.dependencies])
|
|
725
|
+
})))
|
|
726
|
+
}),
|
|
727
|
+
writable: false
|
|
728
|
+
});
|
|
729
|
+
};
|
|
730
|
+
//#endregion
|
|
690
731
|
//#region src/get-resolved-config.ts
|
|
691
732
|
const hookUtils$1 = {
|
|
692
733
|
omit,
|
|
@@ -699,6 +740,7 @@ const hookUtils$1 = {
|
|
|
699
740
|
async function getResolvedConfig(config, cwd, hooks) {
|
|
700
741
|
const stack = [config];
|
|
701
742
|
const configs = [];
|
|
743
|
+
const externalPresets = [];
|
|
702
744
|
while (stack.length > 0) {
|
|
703
745
|
const current = stack.pop();
|
|
704
746
|
const subPresets = current.presets ?? [];
|
|
@@ -706,8 +748,14 @@ async function getResolvedConfig(config, cwd, hooks) {
|
|
|
706
748
|
let presetConfig;
|
|
707
749
|
let presetName;
|
|
708
750
|
if (typeof subPreset === "string") {
|
|
709
|
-
|
|
751
|
+
const presetModule = await bundle(subPreset, cwd);
|
|
752
|
+
presetConfig = presetModule.config;
|
|
710
753
|
presetName = subPreset;
|
|
754
|
+
externalPresets.push({
|
|
755
|
+
dependencies: [...presetModule.dependencies],
|
|
756
|
+
index: externalPresets.length,
|
|
757
|
+
specifier: subPreset
|
|
758
|
+
});
|
|
711
759
|
} else {
|
|
712
760
|
presetConfig = await subPreset;
|
|
713
761
|
presetName = presetConfig.name || "unknown-preset";
|
|
@@ -726,6 +774,7 @@ async function getResolvedConfig(config, cwd, hooks) {
|
|
|
726
774
|
}
|
|
727
775
|
const merged = mergeConfigs(configs);
|
|
728
776
|
merged.presets = configs.slice(0, -1);
|
|
777
|
+
rememberExternalPreset(merged, externalPresets);
|
|
729
778
|
return merged;
|
|
730
779
|
}
|
|
731
780
|
//#endregion
|
|
@@ -1197,6 +1246,7 @@ async function resolveConfig(result, cwd) {
|
|
|
1197
1246
|
warnIfBaseDropped(listed, result.config.presets);
|
|
1198
1247
|
const hooks = mergeHooks(result.config.plugins ?? []);
|
|
1199
1248
|
const mergedConfig = await getResolvedConfig(result.config, cwd, hooks);
|
|
1249
|
+
const externalPresets = takeExternalPresets(mergedConfig);
|
|
1200
1250
|
if (mergedConfig.logLevel) logger.level = mergedConfig.logLevel;
|
|
1201
1251
|
if (mergedConfig.logFilter) logger.filter = mergedConfig.logFilter;
|
|
1202
1252
|
validateConfig(mergedConfig);
|
|
@@ -1218,12 +1268,21 @@ async function resolveConfig(result, cwd) {
|
|
|
1218
1268
|
presets: []
|
|
1219
1269
|
}));
|
|
1220
1270
|
const deserialize = () => parseJson(serialized);
|
|
1221
|
-
|
|
1271
|
+
const resolved = {
|
|
1222
1272
|
...loadConfigResult,
|
|
1223
1273
|
serialized,
|
|
1224
1274
|
deserialize,
|
|
1225
1275
|
hooks
|
|
1226
1276
|
};
|
|
1277
|
+
attachConfigResolutionProvenance(resolved, {
|
|
1278
|
+
baseline: {
|
|
1279
|
+
deserialize,
|
|
1280
|
+
serialized
|
|
1281
|
+
},
|
|
1282
|
+
bundleDependencies: result.dependencies,
|
|
1283
|
+
externalPresets
|
|
1284
|
+
});
|
|
1285
|
+
return resolved;
|
|
1227
1286
|
}
|
|
1228
1287
|
//#endregion
|
|
1229
1288
|
//#region src/load-config.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.0",
|
|
4
4
|
"description": "Find and load bamboo config",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"bundle-n-require": "1.1.2",
|
|
64
64
|
"escalade": "3.2.0",
|
|
65
65
|
"microdiff": "1.5.0",
|
|
66
|
-
"typescript": "6.0.2",
|
|
67
|
-
"@bamboocss/logger": "1.
|
|
68
|
-
"@bamboocss/preset-bamboo": "1.
|
|
69
|
-
"@bamboocss/preset-base": "1.
|
|
70
|
-
"@bamboocss/shared": "1.
|
|
71
|
-
"@bamboocss/types": "1.
|
|
66
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
67
|
+
"@bamboocss/logger": "1.46.0",
|
|
68
|
+
"@bamboocss/preset-bamboo": "1.46.0",
|
|
69
|
+
"@bamboocss/preset-base": "1.46.0",
|
|
70
|
+
"@bamboocss/shared": "1.46.0",
|
|
71
|
+
"@bamboocss/types": "1.46.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"pkg-types": "2.3.0"
|