@bamboocss/node 1.56.0 → 1.56.2
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 +83 -13
- package/dist/index.d.cts +25 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +84 -14
- package/dist/native/darwin-arm64.node +0 -0
- package/dist/native/darwin-x64.node +0 -0
- package/dist/native/linux-arm64-gnu.node +0 -0
- package/dist/native/linux-x64-gnu.node +0 -0
- package/dist/native/win32-x64-msvc.node +0 -0
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -2175,6 +2175,8 @@ var SourceProject = class {
|
|
|
2175
2175
|
options;
|
|
2176
2176
|
/** Bytes explicitly supplied by a caller rather than read from disk, by normalized path. */
|
|
2177
2177
|
overlays = /* @__PURE__ */ new Map();
|
|
2178
|
+
/** Bumped whenever an overlay is set or removed, so a reader can tell its copy is current. */
|
|
2179
|
+
overlayRevision = 0;
|
|
2178
2180
|
compilerOptions;
|
|
2179
2181
|
constructor(options) {
|
|
2180
2182
|
this.options = options;
|
|
@@ -2210,7 +2212,10 @@ var SourceProject = class {
|
|
|
2210
2212
|
getOverriddenSources = () => [...this.overlays.keys()];
|
|
2211
2213
|
/** Supply the bytes for a path. */
|
|
2212
2214
|
overlaySource = (filePath, content) => {
|
|
2213
|
-
this.
|
|
2215
|
+
const key = this.normalizePath(filePath);
|
|
2216
|
+
if (this.overlays.get(key) === content) return;
|
|
2217
|
+
this.overlays.set(key, content);
|
|
2218
|
+
this.overlayRevision++;
|
|
2214
2219
|
};
|
|
2215
2220
|
/**
|
|
2216
2221
|
* Supply the bytes for a module, under the path extraction will ask for.
|
|
@@ -2223,7 +2228,11 @@ var SourceProject = class {
|
|
|
2223
2228
|
};
|
|
2224
2229
|
absolute = (filePath) => (0, node_path.isAbsolute)(filePath) ? filePath : (0, node_path.join)(this.options.cwd ?? process.cwd(), filePath);
|
|
2225
2230
|
/** Forget bytes supplied through `overlaySource`. Returns whether there were any. */
|
|
2226
|
-
removeOverlay = (filePath) =>
|
|
2231
|
+
removeOverlay = (filePath) => {
|
|
2232
|
+
const removed = this.overlays.delete(this.normalizePath(filePath));
|
|
2233
|
+
if (removed) this.overlayRevision++;
|
|
2234
|
+
return removed;
|
|
2235
|
+
};
|
|
2227
2236
|
/**
|
|
2228
2237
|
* A watched file changed on disk. Disk is now the truth for it, so an overlay that
|
|
2229
2238
|
* stood in for it goes.
|
|
@@ -2792,18 +2801,12 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
2792
2801
|
const { baseUrl, paths = {} } = this.project.resolutionOptions;
|
|
2793
2802
|
const own = new Set(sources.map((source) => source.filename.replaceAll("\\", "/")));
|
|
2794
2803
|
const auxiliary = [];
|
|
2795
|
-
|
|
2804
|
+
const candidates = this.runtime === nodeRuntime ? [...this.hookedAuxiliaryFiles(), ...this.project.getOverriddenSources()] : [...this.nativeAuxiliaryFiles, ...this.project.getOverriddenSources()];
|
|
2805
|
+
for (const filePath of new Set(candidates)) {
|
|
2796
2806
|
const filename = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2797
2807
|
if (own.has(filename.replaceAll("\\", "/"))) continue;
|
|
2798
|
-
const
|
|
2799
|
-
if (
|
|
2800
|
-
const original = this.project.getSourceText(filename);
|
|
2801
|
-
if (original === void 0) continue;
|
|
2802
|
-
const prepared = this.prepareNativeSource(filename, original);
|
|
2803
|
-
if (prepared.source !== original || overridden || this.runtime !== nodeRuntime) auxiliary.push({
|
|
2804
|
-
filename,
|
|
2805
|
-
source: prepared.source
|
|
2806
|
-
});
|
|
2808
|
+
const prepared = this.auxiliarySource(filename, this.project.sourceIsOverridden(filename));
|
|
2809
|
+
if (prepared) auxiliary.push(prepared);
|
|
2807
2810
|
}
|
|
2808
2811
|
return this.loadNativeExtractor().compileModules(sources, auxiliary, {
|
|
2809
2812
|
cwd: this.config.cwd,
|
|
@@ -2838,6 +2841,61 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
2838
2841
|
return this.nativeTokenTable;
|
|
2839
2842
|
}
|
|
2840
2843
|
nativeTokenTable;
|
|
2844
|
+
/**
|
|
2845
|
+
* One auxiliary module as the native engine has to be handed it, or `undefined` when the
|
|
2846
|
+
* Rust resolver can read it off disk itself.
|
|
2847
|
+
*
|
|
2848
|
+
* Remembered across calls. `compileModules` runs once per transformed module, and a project
|
|
2849
|
+
* with any `parser:before` hook — every project, since the framework converters are built in
|
|
2850
|
+
* — used to read and hook every auxiliary file on each call: 3,615 files per transform on one
|
|
2851
|
+
* app, which made its production build spend 99% of 25 minutes in `readFileSync`. An entry is
|
|
2852
|
+
* reused while the file's size and modification time stand still and no overlay has moved.
|
|
2853
|
+
*/
|
|
2854
|
+
auxiliarySource = (filename, overridden) => {
|
|
2855
|
+
const key = filename.replaceAll("\\", "/");
|
|
2856
|
+
let stamp;
|
|
2857
|
+
if (overridden) stamp = `overlay:${this.project.overlayRevision}`;
|
|
2858
|
+
else try {
|
|
2859
|
+
const stat = (0, node_fs.statSync)(filename);
|
|
2860
|
+
stamp = `${stat.mtimeMs}:${stat.size}`;
|
|
2861
|
+
} catch {
|
|
2862
|
+
stamp = "missing";
|
|
2863
|
+
}
|
|
2864
|
+
const cached = this.auxiliarySources.get(key);
|
|
2865
|
+
if (cached && cached.stamp === stamp) return cached.source;
|
|
2866
|
+
const original = this.project.getSourceText(filename);
|
|
2867
|
+
let source;
|
|
2868
|
+
if (original !== void 0) {
|
|
2869
|
+
const prepared = this.prepareNativeSource(filename, original);
|
|
2870
|
+
if (prepared.source !== original || overridden || this.runtime !== nodeRuntime) source = {
|
|
2871
|
+
filename,
|
|
2872
|
+
source: prepared.source
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
this.auxiliarySources.set(key, {
|
|
2876
|
+
stamp,
|
|
2877
|
+
source
|
|
2878
|
+
});
|
|
2879
|
+
return source;
|
|
2880
|
+
};
|
|
2881
|
+
auxiliarySources = /* @__PURE__ */ new Map();
|
|
2882
|
+
/**
|
|
2883
|
+
* The auxiliary files a `parser:before` hook rewrites — the only ones the native resolver
|
|
2884
|
+
* cannot read off disk itself. Decided once per inventory rather than per call: asking every
|
|
2885
|
+
* auxiliary file on each transform cost a `stat` of all 3,615 of them per module on one app.
|
|
2886
|
+
* A file event clears the entry for that path through `forgetNativeFile`, and a new
|
|
2887
|
+
* inventory recomputes the list.
|
|
2888
|
+
*/
|
|
2889
|
+
hookedAuxiliaryFiles = () => {
|
|
2890
|
+
if (this.hookedAuxiliary) return this.hookedAuxiliary;
|
|
2891
|
+
if (!this.parserHooks["parser:before"]) return this.hookedAuxiliary = [];
|
|
2892
|
+
this.hookedAuxiliary = this.nativeAuxiliaryFiles.filter((filePath) => {
|
|
2893
|
+
const filename = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2894
|
+
return this.auxiliarySource(filename, false) !== void 0;
|
|
2895
|
+
});
|
|
2896
|
+
return this.hookedAuxiliary;
|
|
2897
|
+
};
|
|
2898
|
+
hookedAuxiliary;
|
|
2841
2899
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
2842
2900
|
loadNativeExtractor = () => {
|
|
2843
2901
|
const nativeRequire = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
@@ -2995,8 +3053,15 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
2995
3053
|
};
|
|
2996
3054
|
/** @internal Native dependency edges, from dependency to extraction owner. */
|
|
2997
3055
|
getNativeDependencyLedger = () => [...this.nativeDependencies].flatMap(([owner, dependencies]) => dependencies.map((dependency) => [dependency.replaceAll("\\", "/"), owner]));
|
|
3056
|
+
/** An edited file's hooked source, which the next compile has to prepare again. */
|
|
3057
|
+
forgetAuxiliarySource = (filePath) => {
|
|
3058
|
+
this.auxiliarySources.delete(this.runtime.path.abs(this.config.cwd, filePath).replaceAll("\\", "/"));
|
|
3059
|
+
this.hookedAuxiliary = void 0;
|
|
3060
|
+
};
|
|
2998
3061
|
forgetNativeFile = (filePath) => {
|
|
2999
3062
|
const file = this.runtime.path.abs(this.config.cwd, filePath).replaceAll("\\", "/");
|
|
3063
|
+
this.auxiliarySources.delete(file);
|
|
3064
|
+
this.hookedAuxiliary = void 0;
|
|
3000
3065
|
this.nativeDependencies.delete(file);
|
|
3001
3066
|
this.nativePendingCandidates.delete(file);
|
|
3002
3067
|
this.nativeConfigurationFiles.delete(file);
|
|
@@ -3160,6 +3225,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
3160
3225
|
}
|
|
3161
3226
|
});
|
|
3162
3227
|
this.nativeAuxiliaryFiles = auxiliary;
|
|
3228
|
+
this.hookedAuxiliary = void 0;
|
|
3163
3229
|
_bamboocss_logger.logger.debug("file:extract", `${extractable.length} of ${files.length} file(s) can reach a bamboo entrypoint; ${files.length - extractable.length} cannot and are not parsed; ${auxiliary.length} local import target(s) sit outside the inventory`);
|
|
3164
3230
|
measure();
|
|
3165
3231
|
return extractable;
|
|
@@ -3969,6 +4035,7 @@ var Builder = class {
|
|
|
3969
4035
|
const ctx = this.getContextOrThrow();
|
|
3970
4036
|
this.captureResolutionLedger(ctx, filePath);
|
|
3971
4037
|
ctx.project.reloadSourceFile(filePath);
|
|
4038
|
+
ctx.forgetAuxiliarySource(filePath);
|
|
3972
4039
|
};
|
|
3973
4040
|
/** The deletion half of `reloadSource`, with the same snapshot obligation. */
|
|
3974
4041
|
removeSource = (filePath) => {
|
|
@@ -4227,7 +4294,10 @@ var Builder = class {
|
|
|
4227
4294
|
ctx.project.removeSourceFile(file);
|
|
4228
4295
|
ctx.forgetNativeFile(file);
|
|
4229
4296
|
fileModifiedMap.set(file, -Infinity);
|
|
4230
|
-
} else
|
|
4297
|
+
} else {
|
|
4298
|
+
ctx.project.reloadSourceFile(file);
|
|
4299
|
+
ctx.forgetAuxiliarySource(file);
|
|
4300
|
+
}
|
|
4231
4301
|
ctx.encoder?.reconcileFileOwnerOrder("extract", inventory);
|
|
4232
4302
|
this.extractionOrder = this.orderAffectedFiles(inventory, affected, ledger);
|
|
4233
4303
|
this.affectedFiles = new Set(this.extractionOrder.map(this.sourcePath));
|
package/dist/index.d.cts
CHANGED
|
@@ -280,6 +280,8 @@ declare class SourceProject {
|
|
|
280
280
|
private readonly options;
|
|
281
281
|
/** Bytes explicitly supplied by a caller rather than read from disk, by normalized path. */
|
|
282
282
|
private overlays;
|
|
283
|
+
/** Bumped whenever an overlay is set or removed, so a reader can tell its copy is current. */
|
|
284
|
+
overlayRevision: number;
|
|
283
285
|
private compilerOptions;
|
|
284
286
|
constructor(options: SourceProjectOptions);
|
|
285
287
|
private normalizePath;
|
|
@@ -549,6 +551,27 @@ declare class BambooContext extends Generator {
|
|
|
549
551
|
*/
|
|
550
552
|
private get nativeTokens();
|
|
551
553
|
private nativeTokenTable;
|
|
554
|
+
/**
|
|
555
|
+
* One auxiliary module as the native engine has to be handed it, or `undefined` when the
|
|
556
|
+
* Rust resolver can read it off disk itself.
|
|
557
|
+
*
|
|
558
|
+
* Remembered across calls. `compileModules` runs once per transformed module, and a project
|
|
559
|
+
* with any `parser:before` hook — every project, since the framework converters are built in
|
|
560
|
+
* — used to read and hook every auxiliary file on each call: 3,615 files per transform on one
|
|
561
|
+
* app, which made its production build spend 99% of 25 minutes in `readFileSync`. An entry is
|
|
562
|
+
* reused while the file's size and modification time stand still and no overlay has moved.
|
|
563
|
+
*/
|
|
564
|
+
private auxiliarySource;
|
|
565
|
+
private auxiliarySources;
|
|
566
|
+
/**
|
|
567
|
+
* The auxiliary files a `parser:before` hook rewrites — the only ones the native resolver
|
|
568
|
+
* cannot read off disk itself. Decided once per inventory rather than per call: asking every
|
|
569
|
+
* auxiliary file on each transform cost a `stat` of all 3,615 of them per module on one app.
|
|
570
|
+
* A file event clears the entry for that path through `forgetNativeFile`, and a new
|
|
571
|
+
* inventory recomputes the list.
|
|
572
|
+
*/
|
|
573
|
+
private hookedAuxiliaryFiles;
|
|
574
|
+
private hookedAuxiliary;
|
|
552
575
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
553
576
|
private loadNativeExtractor;
|
|
554
577
|
private prepareNativeSource;
|
|
@@ -558,6 +581,8 @@ declare class BambooContext extends Generator {
|
|
|
558
581
|
getNativeDependents: (filePath: string) => string[];
|
|
559
582
|
/** @internal Native dependency edges, from dependency to extraction owner. */
|
|
560
583
|
getNativeDependencyLedger: () => Array<readonly [string, string]>;
|
|
584
|
+
/** An edited file's hooked source, which the next compile has to prepare again. */
|
|
585
|
+
forgetAuxiliarySource: (filePath: string) => void;
|
|
561
586
|
forgetNativeFile: (filePath: string) => void;
|
|
562
587
|
private parseNativeFile;
|
|
563
588
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
package/dist/index.d.mts
CHANGED
|
@@ -280,6 +280,8 @@ declare class SourceProject {
|
|
|
280
280
|
private readonly options;
|
|
281
281
|
/** Bytes explicitly supplied by a caller rather than read from disk, by normalized path. */
|
|
282
282
|
private overlays;
|
|
283
|
+
/** Bumped whenever an overlay is set or removed, so a reader can tell its copy is current. */
|
|
284
|
+
overlayRevision: number;
|
|
283
285
|
private compilerOptions;
|
|
284
286
|
constructor(options: SourceProjectOptions);
|
|
285
287
|
private normalizePath;
|
|
@@ -549,6 +551,27 @@ declare class BambooContext extends Generator {
|
|
|
549
551
|
*/
|
|
550
552
|
private get nativeTokens();
|
|
551
553
|
private nativeTokenTable;
|
|
554
|
+
/**
|
|
555
|
+
* One auxiliary module as the native engine has to be handed it, or `undefined` when the
|
|
556
|
+
* Rust resolver can read it off disk itself.
|
|
557
|
+
*
|
|
558
|
+
* Remembered across calls. `compileModules` runs once per transformed module, and a project
|
|
559
|
+
* with any `parser:before` hook — every project, since the framework converters are built in
|
|
560
|
+
* — used to read and hook every auxiliary file on each call: 3,615 files per transform on one
|
|
561
|
+
* app, which made its production build spend 99% of 25 minutes in `readFileSync`. An entry is
|
|
562
|
+
* reused while the file's size and modification time stand still and no overlay has moved.
|
|
563
|
+
*/
|
|
564
|
+
private auxiliarySource;
|
|
565
|
+
private auxiliarySources;
|
|
566
|
+
/**
|
|
567
|
+
* The auxiliary files a `parser:before` hook rewrites — the only ones the native resolver
|
|
568
|
+
* cannot read off disk itself. Decided once per inventory rather than per call: asking every
|
|
569
|
+
* auxiliary file on each transform cost a `stat` of all 3,615 of them per module on one app.
|
|
570
|
+
* A file event clears the entry for that path through `forgetNativeFile`, and a new
|
|
571
|
+
* inventory recomputes the list.
|
|
572
|
+
*/
|
|
573
|
+
private hookedAuxiliaryFiles;
|
|
574
|
+
private hookedAuxiliary;
|
|
552
575
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
553
576
|
private loadNativeExtractor;
|
|
554
577
|
private prepareNativeSource;
|
|
@@ -558,6 +581,8 @@ declare class BambooContext extends Generator {
|
|
|
558
581
|
getNativeDependents: (filePath: string) => string[];
|
|
559
582
|
/** @internal Native dependency edges, from dependency to extraction owner. */
|
|
560
583
|
getNativeDependencyLedger: () => Array<readonly [string, string]>;
|
|
584
|
+
/** An edited file's hooked source, which the next compile has to prepare again. */
|
|
585
|
+
forgetAuxiliarySource: (filePath: string) => void;
|
|
561
586
|
forgetNativeFile: (filePath: string) => void;
|
|
562
587
|
private parseNativeFile;
|
|
563
588
|
parseFile: (filePath: string, styleEncoder?: StyleEncoder) => ParserResult | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { pluginSvelte } from "@bamboocss/plugin-svelte";
|
|
|
10
10
|
import { pluginVue } from "@bamboocss/plugin-vue";
|
|
11
11
|
import { checkNamingAgreement, formatNamingDisagreement, messages, prunesPreflight } from "@bamboocss/core";
|
|
12
12
|
import { Generator, generatePackageExports } from "@bamboocss/generator";
|
|
13
|
-
import fs, { existsSync as existsSync$1, promises } from "node:fs";
|
|
13
|
+
import fs, { existsSync as existsSync$1, promises, statSync as statSync$1 } from "node:fs";
|
|
14
14
|
import path, { dirname as dirname$1, isAbsolute as isAbsolute$1, join as join$1, resolve as resolve$1 } from "node:path";
|
|
15
15
|
import { debounce } from "perfect-debounce";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
@@ -2163,6 +2163,8 @@ var SourceProject = class {
|
|
|
2163
2163
|
options;
|
|
2164
2164
|
/** Bytes explicitly supplied by a caller rather than read from disk, by normalized path. */
|
|
2165
2165
|
overlays = /* @__PURE__ */ new Map();
|
|
2166
|
+
/** Bumped whenever an overlay is set or removed, so a reader can tell its copy is current. */
|
|
2167
|
+
overlayRevision = 0;
|
|
2166
2168
|
compilerOptions;
|
|
2167
2169
|
constructor(options) {
|
|
2168
2170
|
this.options = options;
|
|
@@ -2198,7 +2200,10 @@ var SourceProject = class {
|
|
|
2198
2200
|
getOverriddenSources = () => [...this.overlays.keys()];
|
|
2199
2201
|
/** Supply the bytes for a path. */
|
|
2200
2202
|
overlaySource = (filePath, content) => {
|
|
2201
|
-
this.
|
|
2203
|
+
const key = this.normalizePath(filePath);
|
|
2204
|
+
if (this.overlays.get(key) === content) return;
|
|
2205
|
+
this.overlays.set(key, content);
|
|
2206
|
+
this.overlayRevision++;
|
|
2202
2207
|
};
|
|
2203
2208
|
/**
|
|
2204
2209
|
* Supply the bytes for a module, under the path extraction will ask for.
|
|
@@ -2211,7 +2216,11 @@ var SourceProject = class {
|
|
|
2211
2216
|
};
|
|
2212
2217
|
absolute = (filePath) => isAbsolute$1(filePath) ? filePath : join$1(this.options.cwd ?? process.cwd(), filePath);
|
|
2213
2218
|
/** Forget bytes supplied through `overlaySource`. Returns whether there were any. */
|
|
2214
|
-
removeOverlay = (filePath) =>
|
|
2219
|
+
removeOverlay = (filePath) => {
|
|
2220
|
+
const removed = this.overlays.delete(this.normalizePath(filePath));
|
|
2221
|
+
if (removed) this.overlayRevision++;
|
|
2222
|
+
return removed;
|
|
2223
|
+
};
|
|
2215
2224
|
/**
|
|
2216
2225
|
* A watched file changed on disk. Disk is now the truth for it, so an overlay that
|
|
2217
2226
|
* stood in for it goes.
|
|
@@ -2780,18 +2789,12 @@ var BambooContext = class extends Generator {
|
|
|
2780
2789
|
const { baseUrl, paths = {} } = this.project.resolutionOptions;
|
|
2781
2790
|
const own = new Set(sources.map((source) => source.filename.replaceAll("\\", "/")));
|
|
2782
2791
|
const auxiliary = [];
|
|
2783
|
-
|
|
2792
|
+
const candidates = this.runtime === nodeRuntime ? [...this.hookedAuxiliaryFiles(), ...this.project.getOverriddenSources()] : [...this.nativeAuxiliaryFiles, ...this.project.getOverriddenSources()];
|
|
2793
|
+
for (const filePath of new Set(candidates)) {
|
|
2784
2794
|
const filename = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2785
2795
|
if (own.has(filename.replaceAll("\\", "/"))) continue;
|
|
2786
|
-
const
|
|
2787
|
-
if (
|
|
2788
|
-
const original = this.project.getSourceText(filename);
|
|
2789
|
-
if (original === void 0) continue;
|
|
2790
|
-
const prepared = this.prepareNativeSource(filename, original);
|
|
2791
|
-
if (prepared.source !== original || overridden || this.runtime !== nodeRuntime) auxiliary.push({
|
|
2792
|
-
filename,
|
|
2793
|
-
source: prepared.source
|
|
2794
|
-
});
|
|
2796
|
+
const prepared = this.auxiliarySource(filename, this.project.sourceIsOverridden(filename));
|
|
2797
|
+
if (prepared) auxiliary.push(prepared);
|
|
2795
2798
|
}
|
|
2796
2799
|
return this.loadNativeExtractor().compileModules(sources, auxiliary, {
|
|
2797
2800
|
cwd: this.config.cwd,
|
|
@@ -2826,6 +2829,61 @@ var BambooContext = class extends Generator {
|
|
|
2826
2829
|
return this.nativeTokenTable;
|
|
2827
2830
|
}
|
|
2828
2831
|
nativeTokenTable;
|
|
2832
|
+
/**
|
|
2833
|
+
* One auxiliary module as the native engine has to be handed it, or `undefined` when the
|
|
2834
|
+
* Rust resolver can read it off disk itself.
|
|
2835
|
+
*
|
|
2836
|
+
* Remembered across calls. `compileModules` runs once per transformed module, and a project
|
|
2837
|
+
* with any `parser:before` hook — every project, since the framework converters are built in
|
|
2838
|
+
* — used to read and hook every auxiliary file on each call: 3,615 files per transform on one
|
|
2839
|
+
* app, which made its production build spend 99% of 25 minutes in `readFileSync`. An entry is
|
|
2840
|
+
* reused while the file's size and modification time stand still and no overlay has moved.
|
|
2841
|
+
*/
|
|
2842
|
+
auxiliarySource = (filename, overridden) => {
|
|
2843
|
+
const key = filename.replaceAll("\\", "/");
|
|
2844
|
+
let stamp;
|
|
2845
|
+
if (overridden) stamp = `overlay:${this.project.overlayRevision}`;
|
|
2846
|
+
else try {
|
|
2847
|
+
const stat = statSync$1(filename);
|
|
2848
|
+
stamp = `${stat.mtimeMs}:${stat.size}`;
|
|
2849
|
+
} catch {
|
|
2850
|
+
stamp = "missing";
|
|
2851
|
+
}
|
|
2852
|
+
const cached = this.auxiliarySources.get(key);
|
|
2853
|
+
if (cached && cached.stamp === stamp) return cached.source;
|
|
2854
|
+
const original = this.project.getSourceText(filename);
|
|
2855
|
+
let source;
|
|
2856
|
+
if (original !== void 0) {
|
|
2857
|
+
const prepared = this.prepareNativeSource(filename, original);
|
|
2858
|
+
if (prepared.source !== original || overridden || this.runtime !== nodeRuntime) source = {
|
|
2859
|
+
filename,
|
|
2860
|
+
source: prepared.source
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
this.auxiliarySources.set(key, {
|
|
2864
|
+
stamp,
|
|
2865
|
+
source
|
|
2866
|
+
});
|
|
2867
|
+
return source;
|
|
2868
|
+
};
|
|
2869
|
+
auxiliarySources = /* @__PURE__ */ new Map();
|
|
2870
|
+
/**
|
|
2871
|
+
* The auxiliary files a `parser:before` hook rewrites — the only ones the native resolver
|
|
2872
|
+
* cannot read off disk itself. Decided once per inventory rather than per call: asking every
|
|
2873
|
+
* auxiliary file on each transform cost a `stat` of all 3,615 of them per module on one app.
|
|
2874
|
+
* A file event clears the entry for that path through `forgetNativeFile`, and a new
|
|
2875
|
+
* inventory recomputes the list.
|
|
2876
|
+
*/
|
|
2877
|
+
hookedAuxiliaryFiles = () => {
|
|
2878
|
+
if (this.hookedAuxiliary) return this.hookedAuxiliary;
|
|
2879
|
+
if (!this.parserHooks["parser:before"]) return this.hookedAuxiliary = [];
|
|
2880
|
+
this.hookedAuxiliary = this.nativeAuxiliaryFiles.filter((filePath) => {
|
|
2881
|
+
const filename = this.runtime.path.abs(this.config.cwd, filePath);
|
|
2882
|
+
return this.auxiliarySource(filename, false) !== void 0;
|
|
2883
|
+
});
|
|
2884
|
+
return this.hookedAuxiliary;
|
|
2885
|
+
};
|
|
2886
|
+
hookedAuxiliary;
|
|
2829
2887
|
/** Load the required Rust extractor from the workspace or the published prebuild directory. */
|
|
2830
2888
|
loadNativeExtractor = () => {
|
|
2831
2889
|
const nativeRequire = createRequire(import.meta.url);
|
|
@@ -2983,8 +3041,15 @@ var BambooContext = class extends Generator {
|
|
|
2983
3041
|
};
|
|
2984
3042
|
/** @internal Native dependency edges, from dependency to extraction owner. */
|
|
2985
3043
|
getNativeDependencyLedger = () => [...this.nativeDependencies].flatMap(([owner, dependencies]) => dependencies.map((dependency) => [dependency.replaceAll("\\", "/"), owner]));
|
|
3044
|
+
/** An edited file's hooked source, which the next compile has to prepare again. */
|
|
3045
|
+
forgetAuxiliarySource = (filePath) => {
|
|
3046
|
+
this.auxiliarySources.delete(this.runtime.path.abs(this.config.cwd, filePath).replaceAll("\\", "/"));
|
|
3047
|
+
this.hookedAuxiliary = void 0;
|
|
3048
|
+
};
|
|
2986
3049
|
forgetNativeFile = (filePath) => {
|
|
2987
3050
|
const file = this.runtime.path.abs(this.config.cwd, filePath).replaceAll("\\", "/");
|
|
3051
|
+
this.auxiliarySources.delete(file);
|
|
3052
|
+
this.hookedAuxiliary = void 0;
|
|
2988
3053
|
this.nativeDependencies.delete(file);
|
|
2989
3054
|
this.nativePendingCandidates.delete(file);
|
|
2990
3055
|
this.nativeConfigurationFiles.delete(file);
|
|
@@ -3148,6 +3213,7 @@ var BambooContext = class extends Generator {
|
|
|
3148
3213
|
}
|
|
3149
3214
|
});
|
|
3150
3215
|
this.nativeAuxiliaryFiles = auxiliary;
|
|
3216
|
+
this.hookedAuxiliary = void 0;
|
|
3151
3217
|
logger.debug("file:extract", `${extractable.length} of ${files.length} file(s) can reach a bamboo entrypoint; ${files.length - extractable.length} cannot and are not parsed; ${auxiliary.length} local import target(s) sit outside the inventory`);
|
|
3152
3218
|
measure();
|
|
3153
3219
|
return extractable;
|
|
@@ -3957,6 +4023,7 @@ var Builder = class {
|
|
|
3957
4023
|
const ctx = this.getContextOrThrow();
|
|
3958
4024
|
this.captureResolutionLedger(ctx, filePath);
|
|
3959
4025
|
ctx.project.reloadSourceFile(filePath);
|
|
4026
|
+
ctx.forgetAuxiliarySource(filePath);
|
|
3960
4027
|
};
|
|
3961
4028
|
/** The deletion half of `reloadSource`, with the same snapshot obligation. */
|
|
3962
4029
|
removeSource = (filePath) => {
|
|
@@ -4215,7 +4282,10 @@ var Builder = class {
|
|
|
4215
4282
|
ctx.project.removeSourceFile(file);
|
|
4216
4283
|
ctx.forgetNativeFile(file);
|
|
4217
4284
|
fileModifiedMap.set(file, -Infinity);
|
|
4218
|
-
} else
|
|
4285
|
+
} else {
|
|
4286
|
+
ctx.project.reloadSourceFile(file);
|
|
4287
|
+
ctx.forgetAuxiliarySource(file);
|
|
4288
|
+
}
|
|
4219
4289
|
ctx.encoder?.reconcileFileOwnerOrder("extract", inventory);
|
|
4220
4290
|
this.extractionOrder = this.orderAffectedFiles(inventory, affected, ledger);
|
|
4221
4291
|
this.affectedFiles = new Set(this.extractionOrder.map(this.sourcePath));
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/node",
|
|
3
|
-
"version": "1.56.
|
|
3
|
+
"version": "1.56.2",
|
|
4
4
|
"description": "The core css bamboo library",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,23 +61,23 @@
|
|
|
61
61
|
"pkg-types": "2.3.0",
|
|
62
62
|
"pluralize": "8.0.0",
|
|
63
63
|
"ts-pattern": "5.9.0",
|
|
64
|
-
"@bamboocss/config": "1.56.
|
|
65
|
-
"@bamboocss/core": "1.56.
|
|
66
|
-
"@bamboocss/generator": "1.56.
|
|
67
|
-
"@bamboocss/logger": "1.56.
|
|
68
|
-
"@bamboocss/plugin-svelte": "1.56.
|
|
69
|
-
"@bamboocss/plugin-vue": "1.56.
|
|
70
|
-
"@bamboocss/reporter": "1.56.
|
|
71
|
-
"@bamboocss/shared": "1.56.
|
|
72
|
-
"@bamboocss/token-dictionary": "1.56.
|
|
73
|
-
"@bamboocss/types": "1.56.
|
|
64
|
+
"@bamboocss/config": "1.56.2",
|
|
65
|
+
"@bamboocss/core": "1.56.2",
|
|
66
|
+
"@bamboocss/generator": "1.56.2",
|
|
67
|
+
"@bamboocss/logger": "1.56.2",
|
|
68
|
+
"@bamboocss/plugin-svelte": "1.56.2",
|
|
69
|
+
"@bamboocss/plugin-vue": "1.56.2",
|
|
70
|
+
"@bamboocss/reporter": "1.56.2",
|
|
71
|
+
"@bamboocss/shared": "1.56.2",
|
|
72
|
+
"@bamboocss/token-dictionary": "1.56.2",
|
|
73
|
+
"@bamboocss/types": "1.56.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@astrojs/compiler": "3.0.1",
|
|
77
77
|
"@types/fs-extra": "11.0.4",
|
|
78
78
|
"@types/picomatch": "4.0.2",
|
|
79
79
|
"boxen": "8.0.1",
|
|
80
|
-
"@bamboocss/native-extractor": "1.56.
|
|
80
|
+
"@bamboocss/native-extractor": "1.56.2"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@astrojs/compiler": ">=2"
|