@atlaspack/core 2.30.2 → 2.31.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/CHANGELOG.md +29 -0
- package/dist/Atlaspack.js +2 -0
- package/dist/Transformation.js +24 -1
- package/dist/atlaspack-v3/AtlaspackV3.js +3 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +10 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +10 -22
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +15 -0
- package/dist/atlaspack-v3/worker/side-effect-detector.js +243 -0
- package/dist/atlaspack-v3/worker/worker.js +140 -66
- package/dist/requests/ConfigRequest.js +24 -0
- package/lib/Atlaspack.js +5 -1
- package/lib/Transformation.js +31 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +3 -0
- package/lib/atlaspack-v3/NapiWorkerPool.js +10 -0
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -27
- package/lib/atlaspack-v3/worker/compat/plugin-options.js +15 -0
- package/lib/atlaspack-v3/worker/side-effect-detector.js +215 -0
- package/lib/atlaspack-v3/worker/worker.js +152 -72
- package/lib/requests/ConfigRequest.js +25 -0
- package/lib/types/InternalConfig.d.ts +1 -2
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +2 -1
- package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +1 -0
- package/lib/types/atlaspack-v3/index.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +3 -11
- package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +1 -0
- package/lib/types/atlaspack-v3/worker/side-effect-detector.d.ts +76 -0
- package/lib/types/atlaspack-v3/worker/worker.d.ts +26 -6
- package/lib/types/requests/ConfigRequest.d.ts +9 -1
- package/package.json +14 -14
- package/src/Atlaspack.ts +2 -0
- package/src/InternalConfig.ts +1 -1
- package/src/Transformation.ts +37 -2
- package/src/atlaspack-v3/AtlaspackV3.ts +8 -0
- package/src/atlaspack-v3/NapiWorkerPool.ts +17 -0
- package/src/atlaspack-v3/index.ts +1 -0
- package/src/atlaspack-v3/worker/compat/plugin-config.ts +8 -40
- package/src/atlaspack-v3/worker/compat/plugin-options.ts +15 -0
- package/src/atlaspack-v3/worker/side-effect-detector.ts +298 -0
- package/src/atlaspack-v3/worker/worker.ts +288 -172
- package/src/requests/ConfigRequest.ts +39 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { Async } from '@atlaspack/types';
|
|
2
|
+
export interface FsUsage {
|
|
3
|
+
method: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface EnvUsage {
|
|
7
|
+
vars: Set<string>;
|
|
8
|
+
didEnumerate: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface SideEffects {
|
|
11
|
+
fsUsage: FsUsage[];
|
|
12
|
+
envUsage: EnvUsage;
|
|
13
|
+
packageName: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Side effect detector using AsyncLocalStorage to track filesystem and environment variable
|
|
17
|
+
* access across concurrent async operations in a Node.js worker thread.
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* const detector = new SideEffectDetector();
|
|
21
|
+
* detector.install();
|
|
22
|
+
*
|
|
23
|
+
* const [result, sideEffects] = await detector.monitorSideEffects(async () => {
|
|
24
|
+
* return await someOperation();
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* console.log(sideEffects.fsUsage); // Array of filesystem accesses
|
|
28
|
+
* console.log(sideEffects.envUsage); // Array of environment variable accesses
|
|
29
|
+
*/
|
|
30
|
+
export declare class SideEffectDetector {
|
|
31
|
+
private asyncStorage;
|
|
32
|
+
private patchesInstalled;
|
|
33
|
+
private originalMethods;
|
|
34
|
+
constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Install global patches for filesystem and environment variable monitoring.
|
|
37
|
+
* This should be called once when the worker starts up.
|
|
38
|
+
*/
|
|
39
|
+
install(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Monitor side effects for an async operation.
|
|
42
|
+
*
|
|
43
|
+
* @param {Function} fn - Async function to monitor
|
|
44
|
+
* @param {Object} options - Optional configuration
|
|
45
|
+
* @param {string} options.label - Optional label for debugging
|
|
46
|
+
* @returns {Promise<[any, SideEffects]>} Tuple of [result, sideEffects]
|
|
47
|
+
*/
|
|
48
|
+
monitorSideEffects<T>(packageName: string, fn: () => Async<T>): Async<[T, SideEffects]>;
|
|
49
|
+
/**
|
|
50
|
+
* Get the current monitoring context, if any.
|
|
51
|
+
* Useful for debugging or custom instrumentation.
|
|
52
|
+
*
|
|
53
|
+
* @returns {Object|null} Current context or null if not monitoring
|
|
54
|
+
*/
|
|
55
|
+
getCurrentContext(): SideEffects | null;
|
|
56
|
+
/**
|
|
57
|
+
* Check if currently monitoring side effects.
|
|
58
|
+
*
|
|
59
|
+
* @returns {boolean}
|
|
60
|
+
*/
|
|
61
|
+
isMonitoring(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Patch filesystem methods to record access.
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private _patchFilesystem;
|
|
67
|
+
/**
|
|
68
|
+
* Patch process.env to record environment variable access.
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private _patchProcessEnv;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Default instance for convenience. Most workers will only need one detector.
|
|
75
|
+
*/
|
|
76
|
+
export declare const defaultDetector: SideEffectDetector;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as napi from '@atlaspack/rust';
|
|
2
2
|
import type { JsCallable } from '@atlaspack/rust';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { NodePackageManager } from '@atlaspack/package-manager';
|
|
4
|
+
import type { Transformer, FilePath, FileSystem } from '@atlaspack/types';
|
|
5
|
+
import type { FeatureFlags } from '@atlaspack/feature-flags';
|
|
5
6
|
export declare class AtlaspackWorker {
|
|
6
7
|
#private;
|
|
7
8
|
constructor();
|
|
9
|
+
clearState(): void;
|
|
8
10
|
loadPlugin: JsCallable<[LoadPluginOptions], Promise<undefined>>;
|
|
9
11
|
runResolverResolve: JsCallable<[
|
|
10
12
|
RunResolverResolveOptions
|
|
@@ -14,23 +16,37 @@ export declare class AtlaspackWorker {
|
|
|
14
16
|
Buffer,
|
|
15
17
|
string | null | undefined
|
|
16
18
|
], Promise<RunTransformerTransformResult>>;
|
|
19
|
+
get options(): Options;
|
|
20
|
+
initializeTransformer(instance: Transformer<any>, specifier: string): Promise<{
|
|
21
|
+
conditions: import("@atlaspack/types-internal").TransformerConditions | undefined;
|
|
22
|
+
config: any;
|
|
23
|
+
env: {
|
|
24
|
+
[k: string]: string | undefined;
|
|
25
|
+
};
|
|
26
|
+
} | undefined>;
|
|
17
27
|
}
|
|
18
28
|
type LoadPluginOptions = {
|
|
19
29
|
kind: 'resolver' | 'transformer';
|
|
20
30
|
specifier: string;
|
|
21
31
|
resolveFrom: string;
|
|
22
|
-
|
|
32
|
+
options: RpcPluginOptions;
|
|
23
33
|
};
|
|
24
34
|
type RpcPluginOptions = {
|
|
25
35
|
projectRoot: string;
|
|
26
36
|
mode: string;
|
|
37
|
+
featureFlags: FeatureFlags;
|
|
38
|
+
};
|
|
39
|
+
type Options = RpcPluginOptions & {
|
|
40
|
+
inputFS: FileSystem;
|
|
41
|
+
outputFS: FileSystem;
|
|
42
|
+
packageManager: NodePackageManager;
|
|
43
|
+
shouldAutoInstall: boolean;
|
|
27
44
|
};
|
|
28
45
|
type RunResolverResolveOptions = {
|
|
29
46
|
key: string;
|
|
30
47
|
dependency: napi.Dependency;
|
|
31
48
|
specifier: FilePath;
|
|
32
49
|
pipeline: string | null | undefined;
|
|
33
|
-
pluginOptions: RpcPluginOptions;
|
|
34
50
|
};
|
|
35
51
|
type RunResolverResolveResult = {
|
|
36
52
|
invalidations: Array<any>;
|
|
@@ -53,8 +69,12 @@ type RunResolverResolveResult = {
|
|
|
53
69
|
type RunTransformerTransformOptions = {
|
|
54
70
|
key: string;
|
|
55
71
|
env: napi.Environment;
|
|
56
|
-
options: RpcPluginOptions;
|
|
57
72
|
asset: napi.Asset;
|
|
58
73
|
};
|
|
59
|
-
type RunTransformerTransformResult = [
|
|
74
|
+
type RunTransformerTransformResult = [
|
|
75
|
+
napi.RpcAssetResult,
|
|
76
|
+
Buffer,
|
|
77
|
+
string,
|
|
78
|
+
boolean
|
|
79
|
+
];
|
|
60
80
|
export {};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type { Async, Config as IConfig, PluginOptions as IPluginOptions, PluginLogger as IPluginLogger, PluginTracer as IPluginTracer, NamedBundle as INamedBundle, BundleGraph as IBundleGraph } from '@atlaspack/types';
|
|
1
|
+
import type { Async, Config as IConfig, PluginOptions as IPluginOptions, PluginLogger as IPluginLogger, PluginTracer as IPluginTracer, NamedBundle as INamedBundle, BundleGraph as IBundleGraph, TransformerSetup } from '@atlaspack/types';
|
|
2
2
|
import type { Config, AtlaspackOptions, InternalFileCreateInvalidation } from '../types';
|
|
3
3
|
import type { LoadedPlugin } from '../AtlaspackConfig';
|
|
4
4
|
import type { RequestResult, RunAPI } from '../RequestTracker';
|
|
5
5
|
import type { ProjectPath } from '../projectPath';
|
|
6
|
+
type Setup<T> = (arg1: {
|
|
7
|
+
config: IConfig;
|
|
8
|
+
options: IPluginOptions;
|
|
9
|
+
logger: IPluginLogger;
|
|
10
|
+
tracer: IPluginTracer;
|
|
11
|
+
}) => Async<TransformerSetup<T>>;
|
|
6
12
|
export type PluginWithLoadConfig = {
|
|
7
13
|
loadConfig?: (arg1: {
|
|
8
14
|
config: IConfig;
|
|
@@ -42,6 +48,7 @@ export type ConfigRequest = {
|
|
|
42
48
|
};
|
|
43
49
|
export type ConfigRequestResult = undefined;
|
|
44
50
|
export declare function loadPluginConfig<T extends PluginWithLoadConfig>(loadedPlugin: LoadedPlugin<T>, config: Config, options: AtlaspackOptions): Promise<void>;
|
|
51
|
+
export declare function loadPluginSetup<T>(pluginName: string, setup: Setup<T>, config: Config, options: AtlaspackOptions): Promise<void>;
|
|
45
52
|
/**
|
|
46
53
|
* Return value at a given key path within an object.
|
|
47
54
|
*
|
|
@@ -57,3 +64,4 @@ export declare function getConfigKeyContentHash(filePath: ProjectPath, configKey
|
|
|
57
64
|
export declare function runConfigRequest<TResult extends RequestResult>(api: RunAPI<TResult>, configRequest: ConfigRequest): Promise<void>;
|
|
58
65
|
export declare function getConfigHash(config: Config, pluginName: string, options: AtlaspackOptions): Promise<string>;
|
|
59
66
|
export declare function getConfigRequests(configs: Array<Config>): Array<ConfigRequest>;
|
|
67
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
26
26
|
"@atlaspack/build-cache": "2.13.6",
|
|
27
|
-
"@atlaspack/cache": "3.2.
|
|
27
|
+
"@atlaspack/cache": "3.2.41",
|
|
28
28
|
"@atlaspack/diagnostic": "2.14.4",
|
|
29
29
|
"@atlaspack/events": "2.14.4",
|
|
30
|
-
"@atlaspack/feature-flags": "2.27.
|
|
31
|
-
"@atlaspack/fs": "2.15.
|
|
32
|
-
"@atlaspack/graph": "3.6.
|
|
33
|
-
"@atlaspack/logger": "2.14.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.
|
|
35
|
-
"@atlaspack/plugin": "2.14.
|
|
36
|
-
"@atlaspack/profiler": "2.15.
|
|
37
|
-
"@atlaspack/rust": "3.
|
|
38
|
-
"@atlaspack/types": "2.15.
|
|
39
|
-
"@atlaspack/utils": "3.2.
|
|
40
|
-
"@atlaspack/workers": "2.14.
|
|
41
|
-
"@atlaspack/source-map": "3.2.
|
|
30
|
+
"@atlaspack/feature-flags": "2.27.5",
|
|
31
|
+
"@atlaspack/fs": "2.15.41",
|
|
32
|
+
"@atlaspack/graph": "3.6.8",
|
|
33
|
+
"@atlaspack/logger": "2.14.38",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.46",
|
|
35
|
+
"@atlaspack/plugin": "2.14.46",
|
|
36
|
+
"@atlaspack/profiler": "2.15.7",
|
|
37
|
+
"@atlaspack/rust": "3.16.0",
|
|
38
|
+
"@atlaspack/types": "2.15.36",
|
|
39
|
+
"@atlaspack/utils": "3.2.7",
|
|
40
|
+
"@atlaspack/workers": "2.14.46",
|
|
41
|
+
"@atlaspack/source-map": "3.2.1",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
44
44
|
"clone": "^2.1.1",
|
package/src/Atlaspack.ts
CHANGED
|
@@ -516,6 +516,7 @@ export default class Atlaspack {
|
|
|
516
516
|
return result;
|
|
517
517
|
},
|
|
518
518
|
unstable_requestStats: this.#requestTracker.flushStats(),
|
|
519
|
+
nativeCacheStats: await this.rustAtlaspack?.completeCacheSession(),
|
|
519
520
|
scopeHoistingStats,
|
|
520
521
|
};
|
|
521
522
|
|
|
@@ -543,6 +544,7 @@ export default class Atlaspack {
|
|
|
543
544
|
type: 'buildFailure',
|
|
544
545
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
545
546
|
unstable_requestStats: this.#requestTracker.flushStats(),
|
|
547
|
+
nativeCacheStats: await this.rustAtlaspack?.completeCacheSession(),
|
|
546
548
|
};
|
|
547
549
|
|
|
548
550
|
// @ts-expect-error TS2345
|
package/src/InternalConfig.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {identifierRegistry} from './IdentifierRegistry';
|
|
|
13
13
|
import type {EnvironmentRef} from './EnvironmentManager';
|
|
14
14
|
import {toEnvironmentId} from './EnvironmentManager';
|
|
15
15
|
|
|
16
|
-
type ConfigOpts = {
|
|
16
|
+
export type ConfigOpts = {
|
|
17
17
|
plugin: PackageName;
|
|
18
18
|
searchPath: ProjectPath;
|
|
19
19
|
isSource?: boolean;
|
package/src/Transformation.ts
CHANGED
|
@@ -46,13 +46,13 @@ import UncommittedAsset from './UncommittedAsset';
|
|
|
46
46
|
import {createAsset} from './assetUtils';
|
|
47
47
|
import summarizeRequest from './summarizeRequest';
|
|
48
48
|
import PluginOptions from './public/PluginOptions';
|
|
49
|
-
import {fromEnvironmentId} from './EnvironmentManager';
|
|
50
49
|
import {optionsProxy} from './utils';
|
|
51
50
|
import {createConfig} from './InternalConfig';
|
|
52
51
|
import {
|
|
53
52
|
loadPluginConfig,
|
|
54
53
|
getConfigRequests,
|
|
55
54
|
ConfigRequest,
|
|
55
|
+
loadPluginSetup,
|
|
56
56
|
} from './requests/ConfigRequest';
|
|
57
57
|
import {
|
|
58
58
|
createDevDependency,
|
|
@@ -71,6 +71,7 @@ import invariant from 'assert';
|
|
|
71
71
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
72
72
|
import SourceMap from '@atlaspack/source-map';
|
|
73
73
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
74
|
+
import {createBuildCache} from '@atlaspack/build-cache';
|
|
74
75
|
|
|
75
76
|
type GenerateFunc = (input: UncommittedAsset) => Promise<GenerateOutput>;
|
|
76
77
|
|
|
@@ -93,6 +94,10 @@ export type TransformationResult = {
|
|
|
93
94
|
devDepRequests: Array<DevDepRequest | DevDepRequestRef>;
|
|
94
95
|
};
|
|
95
96
|
|
|
97
|
+
// Global setup config are not file-specific, so we only need to
|
|
98
|
+
// load them once per build.
|
|
99
|
+
const setupConfig = createBuildCache<string, Config>();
|
|
100
|
+
|
|
96
101
|
export default class Transformation {
|
|
97
102
|
request: TransformationRequest;
|
|
98
103
|
configs: Map<string, Config>;
|
|
@@ -540,12 +545,42 @@ export default class Transformation {
|
|
|
540
545
|
transformer: LoadedPlugin<Transformer<unknown>>,
|
|
541
546
|
isSource: boolean,
|
|
542
547
|
): Promise<Config | null | undefined> {
|
|
548
|
+
// Only load setup config for a transformer once per build.
|
|
549
|
+
let config = setupConfig.get(transformer.name);
|
|
550
|
+
|
|
551
|
+
if (config == null && transformer.plugin.setup != null) {
|
|
552
|
+
config = createConfig({
|
|
553
|
+
plugin: transformer.name,
|
|
554
|
+
searchPath: toProjectPathUnsafe('index'),
|
|
555
|
+
// Consider project setup config as source
|
|
556
|
+
isSource: true,
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
await loadPluginSetup(
|
|
560
|
+
transformer.name,
|
|
561
|
+
transformer.plugin.setup,
|
|
562
|
+
config,
|
|
563
|
+
this.options,
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
setupConfig.set(transformer.name, config);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (config != null) {
|
|
570
|
+
for (let devDep of config.devDeps) {
|
|
571
|
+
await this.addDevDependency(devDep);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// `loadConfig` is not called for setup configs
|
|
575
|
+
return config;
|
|
576
|
+
}
|
|
577
|
+
|
|
543
578
|
let loadConfig = transformer.plugin.loadConfig;
|
|
544
579
|
if (!loadConfig) {
|
|
545
580
|
return;
|
|
546
581
|
}
|
|
547
582
|
|
|
548
|
-
|
|
583
|
+
config = createConfig({
|
|
549
584
|
plugin: transformer.name,
|
|
550
585
|
isSource,
|
|
551
586
|
// @ts-expect-error TS2322
|
|
@@ -2,9 +2,11 @@ import {
|
|
|
2
2
|
atlaspackNapiCreate,
|
|
3
3
|
atlaspackNapiBuildAssetGraph,
|
|
4
4
|
atlaspackNapiRespondToFsEvents,
|
|
5
|
+
atlaspackNapiCompleteSession,
|
|
5
6
|
AtlaspackNapi,
|
|
6
7
|
Lmdb,
|
|
7
8
|
AtlaspackNapiOptions,
|
|
9
|
+
CacheStats,
|
|
8
10
|
} from '@atlaspack/rust';
|
|
9
11
|
import {NapiWorkerPool} from './NapiWorkerPool';
|
|
10
12
|
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
|
@@ -108,4 +110,10 @@ export class AtlaspackV3 {
|
|
|
108
110
|
|
|
109
111
|
return needsRebuild;
|
|
110
112
|
}
|
|
113
|
+
|
|
114
|
+
async completeCacheSession(): Promise<CacheStats> {
|
|
115
|
+
return (await atlaspackNapiCompleteSession(
|
|
116
|
+
this._atlaspack_napi,
|
|
117
|
+
)) as CacheStats;
|
|
118
|
+
}
|
|
111
119
|
}
|
|
@@ -46,6 +46,23 @@ export class NapiWorkerPool implements INapiWorkerPool {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
clearAllWorkerState(): Promise<void[]> {
|
|
50
|
+
return Promise.all(
|
|
51
|
+
this.#workers.map(
|
|
52
|
+
(worker) =>
|
|
53
|
+
new Promise<void>((res) => {
|
|
54
|
+
worker.postMessage('clearState');
|
|
55
|
+
|
|
56
|
+
worker.once('message', (message) => {
|
|
57
|
+
if (message == 'stateCleared') {
|
|
58
|
+
res();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
workerCount(): number {
|
|
50
67
|
return this.#workerCount;
|
|
51
68
|
}
|
|
@@ -6,57 +6,25 @@ import type {
|
|
|
6
6
|
FileCreateInvalidation,
|
|
7
7
|
ConfigResultWithFilePath,
|
|
8
8
|
PackageJSON,
|
|
9
|
-
PackageManager as IPackageManager,
|
|
10
9
|
} from '@atlaspack/types';
|
|
11
10
|
|
|
12
|
-
import type {FileSystem as IFileSystem} from '@atlaspack/fs';
|
|
13
11
|
import ClassicPublicConfig from '../../../public/Config';
|
|
14
|
-
|
|
15
|
-
export type PluginConfigOptions = {
|
|
16
|
-
isSource: boolean;
|
|
17
|
-
searchPath: FilePath;
|
|
18
|
-
projectRoot: FilePath;
|
|
19
|
-
env: Environment;
|
|
20
|
-
fs: IFileSystem;
|
|
21
|
-
packageManager: IPackageManager;
|
|
22
|
-
};
|
|
12
|
+
import {type ConfigOpts, createConfig} from '../../../InternalConfig';
|
|
23
13
|
|
|
24
14
|
export class PluginConfig implements IPluginConfig {
|
|
25
15
|
isSource: boolean;
|
|
26
16
|
searchPath: FilePath;
|
|
27
|
-
// @ts-expect-error TS2564
|
|
28
|
-
#projectRoot: FilePath;
|
|
29
17
|
env: Environment;
|
|
30
18
|
#inner: ClassicPublicConfig;
|
|
31
19
|
|
|
32
|
-
constructor({
|
|
33
|
-
|
|
34
|
-
isSource,
|
|
35
|
-
searchPath,
|
|
36
|
-
projectRoot,
|
|
37
|
-
fs,
|
|
38
|
-
packageManager,
|
|
39
|
-
}: PluginConfigOptions) {
|
|
40
|
-
this.env = env;
|
|
41
|
-
this.isSource = isSource;
|
|
42
|
-
this.searchPath = searchPath;
|
|
20
|
+
constructor(configOpts: ConfigOpts, options: any) {
|
|
21
|
+
let internalConfig = createConfig(configOpts);
|
|
43
22
|
|
|
44
|
-
this
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
invalidateOnFileChange: new Set(),
|
|
50
|
-
devDeps: [],
|
|
51
|
-
searchPath: searchPath.replace(projectRoot + '/', ''),
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
projectRoot,
|
|
55
|
-
inputFS: fs,
|
|
56
|
-
outputFS: fs,
|
|
57
|
-
packageManager,
|
|
58
|
-
},
|
|
59
|
-
);
|
|
23
|
+
this.isSource = internalConfig.isSource;
|
|
24
|
+
this.searchPath = internalConfig.searchPath;
|
|
25
|
+
// @ts-expect-error TS2564
|
|
26
|
+
this.env = internalConfig.env;
|
|
27
|
+
this.#inner = new ClassicPublicConfig(internalConfig, options);
|
|
60
28
|
}
|
|
61
29
|
|
|
62
30
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -14,6 +14,7 @@ import type {FeatureFlags} from '@atlaspack/feature-flags';
|
|
|
14
14
|
|
|
15
15
|
export class PluginOptions implements IPluginOptions {
|
|
16
16
|
#options: IPluginOptions;
|
|
17
|
+
used = false;
|
|
17
18
|
|
|
18
19
|
get env(): EnvMap {
|
|
19
20
|
if (!('env' in this.#options)) {
|
|
@@ -27,6 +28,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
27
28
|
if (!('projectRoot' in this.#options)) {
|
|
28
29
|
throw new Error('PluginOptions.projectRoot');
|
|
29
30
|
}
|
|
31
|
+
this.used = true;
|
|
30
32
|
return this.#options.projectRoot;
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -34,6 +36,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
34
36
|
if (!('packageManager' in this.#options)) {
|
|
35
37
|
throw new Error('PluginOptions.packageManager');
|
|
36
38
|
}
|
|
39
|
+
this.used = true;
|
|
37
40
|
return this.#options.packageManager;
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -41,6 +44,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
41
44
|
if (!('mode' in this.#options)) {
|
|
42
45
|
throw new Error('PluginOptions.mode');
|
|
43
46
|
}
|
|
47
|
+
this.used = true;
|
|
44
48
|
return this.#options.mode;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -49,6 +53,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
49
53
|
return 'UNKNOWN VERSION';
|
|
50
54
|
// throw new Error('PluginOptions.parcelVersion');
|
|
51
55
|
}
|
|
56
|
+
this.used = true;
|
|
52
57
|
return this.#options.parcelVersion;
|
|
53
58
|
}
|
|
54
59
|
|
|
@@ -56,6 +61,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
56
61
|
if (!('hmrOptions' in this.#options)) {
|
|
57
62
|
throw new Error('PluginOptions.hmrOptions');
|
|
58
63
|
}
|
|
64
|
+
this.used = true;
|
|
59
65
|
return this.#options.hmrOptions;
|
|
60
66
|
}
|
|
61
67
|
|
|
@@ -63,6 +69,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
63
69
|
if (!('serveOptions' in this.#options)) {
|
|
64
70
|
throw new Error('PluginOptions.serveOptions');
|
|
65
71
|
}
|
|
72
|
+
this.used = true;
|
|
66
73
|
return this.#options.serveOptions;
|
|
67
74
|
}
|
|
68
75
|
|
|
@@ -70,6 +77,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
70
77
|
if (!('shouldBuildLazily' in this.#options)) {
|
|
71
78
|
throw new Error('PluginOptions.shouldBuildLazily');
|
|
72
79
|
}
|
|
80
|
+
this.used = true;
|
|
73
81
|
return this.#options.shouldBuildLazily;
|
|
74
82
|
}
|
|
75
83
|
|
|
@@ -77,6 +85,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
77
85
|
if (!('shouldAutoInstall' in this.#options)) {
|
|
78
86
|
throw new Error('PluginOptions.shouldAutoInstall');
|
|
79
87
|
}
|
|
88
|
+
this.used = true;
|
|
80
89
|
return this.#options.shouldAutoInstall;
|
|
81
90
|
}
|
|
82
91
|
|
|
@@ -91,6 +100,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
91
100
|
if (!('cacheDir' in this.#options)) {
|
|
92
101
|
throw new Error('PluginOptions.cacheDir');
|
|
93
102
|
}
|
|
103
|
+
this.used = true;
|
|
94
104
|
return this.#options.cacheDir;
|
|
95
105
|
}
|
|
96
106
|
|
|
@@ -98,6 +108,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
98
108
|
if (!('inputFS' in this.#options)) {
|
|
99
109
|
throw new Error('PluginOptions.inputFS');
|
|
100
110
|
}
|
|
111
|
+
this.used = true;
|
|
101
112
|
return this.#options.inputFS;
|
|
102
113
|
}
|
|
103
114
|
|
|
@@ -105,6 +116,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
105
116
|
if (!('outputFS' in this.#options)) {
|
|
106
117
|
throw new Error('PluginOptions.outputFS');
|
|
107
118
|
}
|
|
119
|
+
this.used = true;
|
|
108
120
|
return this.#options.outputFS;
|
|
109
121
|
}
|
|
110
122
|
|
|
@@ -112,6 +124,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
112
124
|
if (!('instanceId' in this.#options)) {
|
|
113
125
|
throw new Error('PluginOptions.instanceId');
|
|
114
126
|
}
|
|
127
|
+
this.used = true;
|
|
115
128
|
return this.#options.instanceId;
|
|
116
129
|
}
|
|
117
130
|
|
|
@@ -119,6 +132,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
119
132
|
if (!('detailedReport' in this.#options)) {
|
|
120
133
|
throw new Error('PluginOptions.detailedReport');
|
|
121
134
|
}
|
|
135
|
+
this.used = true;
|
|
122
136
|
return this.#options.detailedReport;
|
|
123
137
|
}
|
|
124
138
|
|
|
@@ -126,6 +140,7 @@ export class PluginOptions implements IPluginOptions {
|
|
|
126
140
|
if (!('featureFlags' in this.#options)) {
|
|
127
141
|
throw new Error('PluginOptions.featureFlags');
|
|
128
142
|
}
|
|
143
|
+
this.used = true;
|
|
129
144
|
return this.#options.featureFlags;
|
|
130
145
|
}
|
|
131
146
|
|