@atlaspack/core 2.24.1 → 2.24.2-dev-ts-project-refs-d30e9754f.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/LICENSE +201 -0
- package/dist/AssetGraph.js +591 -0
- package/dist/Atlaspack.js +656 -0
- package/dist/AtlaspackConfig.js +324 -0
- package/dist/AtlaspackConfig.schema.js +108 -0
- package/dist/BundleGraph.js +1628 -0
- package/dist/CommittedAsset.js +142 -0
- package/dist/Dependency.js +125 -0
- package/dist/Environment.js +132 -0
- package/dist/EnvironmentManager.js +108 -0
- package/dist/IdentifierRegistry.js +38 -0
- package/dist/InternalConfig.js +37 -0
- package/dist/PackagerRunner.js +531 -0
- package/dist/ReporterRunner.js +151 -0
- package/dist/RequestTracker.js +1368 -0
- package/dist/SymbolPropagation.js +620 -0
- package/dist/TargetDescriptor.schema.js +143 -0
- package/dist/Transformation.js +487 -0
- package/dist/UncommittedAsset.js +315 -0
- package/dist/Validation.js +196 -0
- package/dist/applyRuntimes.js +305 -0
- package/dist/assetUtils.js +168 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
- package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
- package/dist/atlaspack-v3/fs.js +52 -0
- package/dist/atlaspack-v3/index.js +25 -0
- package/dist/atlaspack-v3/jsCallable.js +16 -0
- package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
- package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
- package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
- package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
- package/dist/atlaspack-v3/worker/compat/index.js +25 -0
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
- package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
- package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
- package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
- package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
- package/dist/atlaspack-v3/worker/compat/target.js +14 -0
- package/dist/atlaspack-v3/worker/worker.js +292 -0
- package/dist/constants.js +17 -0
- package/dist/dumpGraphToGraphViz.js +281 -0
- package/dist/index.js +62 -0
- package/dist/loadAtlaspackPlugin.js +128 -0
- package/dist/loadDotEnv.js +41 -0
- package/dist/projectPath.js +83 -0
- package/dist/public/Asset.js +279 -0
- package/dist/public/Bundle.js +224 -0
- package/dist/public/BundleGraph.js +359 -0
- package/dist/public/BundleGroup.js +53 -0
- package/dist/public/Config.js +286 -0
- package/dist/public/Dependency.js +138 -0
- package/dist/public/Environment.js +278 -0
- package/dist/public/MutableBundleGraph.js +277 -0
- package/dist/public/PluginOptions.js +80 -0
- package/dist/public/Symbols.js +248 -0
- package/dist/public/Target.js +69 -0
- package/dist/registerCoreWithSerializer.js +38 -0
- package/dist/requests/AssetGraphRequest.js +429 -0
- package/dist/requests/AssetGraphRequestRust.js +246 -0
- package/dist/requests/AssetRequest.js +130 -0
- package/dist/requests/AtlaspackBuildRequest.js +60 -0
- package/dist/requests/AtlaspackConfigRequest.js +490 -0
- package/dist/requests/BundleGraphRequest.js +441 -0
- package/dist/requests/ConfigRequest.js +222 -0
- package/dist/requests/DevDepRequest.js +204 -0
- package/dist/requests/EntryRequest.js +314 -0
- package/dist/requests/PackageRequest.js +65 -0
- package/dist/requests/PathRequest.js +349 -0
- package/dist/requests/TargetRequest.js +1310 -0
- package/dist/requests/ValidationRequest.js +49 -0
- package/dist/requests/WriteBundleRequest.js +254 -0
- package/dist/requests/WriteBundlesRequest.js +165 -0
- package/dist/requests/asset-graph-diff.js +126 -0
- package/dist/requests/asset-graph-dot.js +131 -0
- package/dist/resolveOptions.js +268 -0
- package/dist/rustWorkerThreadDylibHack.js +19 -0
- package/dist/serializerCore.browser.js +43 -0
- package/dist/summarizeRequest.js +39 -0
- package/dist/types.js +31 -0
- package/dist/utils.js +172 -0
- package/dist/worker.js +130 -0
- package/lib/AssetGraph.js +1 -0
- package/package.json +22 -22
- package/src/AssetGraph.ts +1 -0
- package/tsconfig.json +55 -2
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _PublicConfig_config, _PublicConfig_pkg, _PublicConfig_pkgFilePath, _PublicConfig_options;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.makeConfigProxy = makeConfigProxy;
|
|
19
|
+
const assert_1 = __importDefault(require("assert"));
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const utils_1 = require("@atlaspack/utils");
|
|
22
|
+
const Environment_1 = __importDefault(require("./Environment"));
|
|
23
|
+
const projectPath_1 = require("../projectPath");
|
|
24
|
+
const EnvironmentManager_1 = require("../EnvironmentManager");
|
|
25
|
+
const internalConfigToConfig = new utils_1.DefaultWeakMap(() => new WeakMap());
|
|
26
|
+
/**
|
|
27
|
+
* Implements read tracking over an object.
|
|
28
|
+
*
|
|
29
|
+
* Calling this function with a non-trivial object like a class instance will fail to work.
|
|
30
|
+
*
|
|
31
|
+
* We track reads to fields that resolve to:
|
|
32
|
+
*
|
|
33
|
+
* - primitive values
|
|
34
|
+
* - arrays
|
|
35
|
+
*
|
|
36
|
+
* That is, reading a nested field `a.b.c` will make a single call to `onRead` with the path
|
|
37
|
+
* `['a', 'b', 'c']`.
|
|
38
|
+
*
|
|
39
|
+
* In case the value is null or an array, we will track the read as well.
|
|
40
|
+
*
|
|
41
|
+
* Iterating over `Object.keys(obj.field)` will register a read for the `['field']` path.
|
|
42
|
+
* Other reads work normally.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
*
|
|
46
|
+
* const usedPaths = new Set();
|
|
47
|
+
* const onRead = (path) => {
|
|
48
|
+
* usedPaths.add(path);
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* const config = makeConfigProxy(onRead, {a: {b: {c: 'd'}}})
|
|
52
|
+
* console.log(config.a.b.c);
|
|
53
|
+
* console.log(Array.from(usedPaths));
|
|
54
|
+
* // We get a single read for the path
|
|
55
|
+
* // ['a', 'b', 'c']
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
function makeConfigProxy(onRead, config) {
|
|
59
|
+
const reportedPaths = new Set();
|
|
60
|
+
const reportPath = (path) => {
|
|
61
|
+
if (reportedPaths.has(path)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
reportedPaths.add(path);
|
|
65
|
+
onRead(path);
|
|
66
|
+
};
|
|
67
|
+
const makeProxy = (target, path) => {
|
|
68
|
+
// @ts-expect-error TS2345
|
|
69
|
+
return new Proxy(target, {
|
|
70
|
+
ownKeys(target) {
|
|
71
|
+
reportPath(path);
|
|
72
|
+
return Object.getOwnPropertyNames(target);
|
|
73
|
+
},
|
|
74
|
+
get(target, prop) {
|
|
75
|
+
// @ts-expect-error TS7053
|
|
76
|
+
const value = target[prop];
|
|
77
|
+
if (typeof value === 'object' &&
|
|
78
|
+
value != null &&
|
|
79
|
+
!Array.isArray(value)) {
|
|
80
|
+
return makeProxy(value, [...path, prop]);
|
|
81
|
+
}
|
|
82
|
+
reportPath([...path, prop]);
|
|
83
|
+
return value;
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
// @ts-expect-error TS2322
|
|
88
|
+
return makeProxy(config, []);
|
|
89
|
+
}
|
|
90
|
+
class PublicConfig {
|
|
91
|
+
constructor(config, options) {
|
|
92
|
+
// @ts-expect-error TS2564
|
|
93
|
+
_PublicConfig_config.set(this, void 0);
|
|
94
|
+
_PublicConfig_pkg.set(this, void 0);
|
|
95
|
+
_PublicConfig_pkgFilePath.set(this, void 0);
|
|
96
|
+
// @ts-expect-error TS2564
|
|
97
|
+
_PublicConfig_options.set(this, void 0);
|
|
98
|
+
let existing = internalConfigToConfig.get(options).get(config);
|
|
99
|
+
if (existing != null) {
|
|
100
|
+
return existing;
|
|
101
|
+
}
|
|
102
|
+
__classPrivateFieldSet(this, _PublicConfig_config, config, "f");
|
|
103
|
+
__classPrivateFieldSet(this, _PublicConfig_options, options, "f");
|
|
104
|
+
internalConfigToConfig.get(options).set(config, this);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
get env() {
|
|
108
|
+
return new Environment_1.default((0, EnvironmentManager_1.fromEnvironmentId)(__classPrivateFieldGet(this, _PublicConfig_config, "f").env), __classPrivateFieldGet(this, _PublicConfig_options, "f"));
|
|
109
|
+
}
|
|
110
|
+
get searchPath() {
|
|
111
|
+
return (0, projectPath_1.fromProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot, __classPrivateFieldGet(this, _PublicConfig_config, "f").searchPath);
|
|
112
|
+
}
|
|
113
|
+
get result() {
|
|
114
|
+
return __classPrivateFieldGet(this, _PublicConfig_config, "f").result;
|
|
115
|
+
}
|
|
116
|
+
get isSource() {
|
|
117
|
+
return __classPrivateFieldGet(this, _PublicConfig_config, "f").isSource;
|
|
118
|
+
}
|
|
119
|
+
setResult(result) {
|
|
120
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").result = result;
|
|
121
|
+
}
|
|
122
|
+
setCacheKey(cacheKey) {
|
|
123
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").cacheKey = cacheKey;
|
|
124
|
+
}
|
|
125
|
+
invalidateOnFileChange(filePath) {
|
|
126
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnFileChange.add((0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot, filePath));
|
|
127
|
+
}
|
|
128
|
+
invalidateOnConfigKeyChange(filePath, configKey) {
|
|
129
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnConfigKeyChange.push({
|
|
130
|
+
filePath: (0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot, filePath),
|
|
131
|
+
configKey,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
addDevDependency(devDep) {
|
|
135
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").devDeps.push({
|
|
136
|
+
...devDep,
|
|
137
|
+
resolveFrom: (0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot, devDep.resolveFrom),
|
|
138
|
+
additionalInvalidations: devDep.additionalInvalidations?.map((i) => ({
|
|
139
|
+
...i,
|
|
140
|
+
resolveFrom: (0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot, i.resolveFrom),
|
|
141
|
+
})),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
invalidateOnFileCreate(invalidation) {
|
|
145
|
+
// @ts-expect-error TS2339
|
|
146
|
+
if (invalidation.glob != null) {
|
|
147
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnFileCreate.push(invalidation);
|
|
148
|
+
// @ts-expect-error TS2339
|
|
149
|
+
}
|
|
150
|
+
else if (invalidation.filePath != null) {
|
|
151
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnFileCreate.push({
|
|
152
|
+
filePath: (0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot,
|
|
153
|
+
// @ts-expect-error TS2339
|
|
154
|
+
invalidation.filePath),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// @ts-expect-error TS2339
|
|
159
|
+
(0, assert_1.default)(invalidation.aboveFilePath != null);
|
|
160
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnFileCreate.push({
|
|
161
|
+
// @ts-expect-error TS2339
|
|
162
|
+
fileName: invalidation.fileName,
|
|
163
|
+
aboveFilePath: (0, projectPath_1.toProjectPath)(__classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot,
|
|
164
|
+
// @ts-expect-error TS2339
|
|
165
|
+
invalidation.aboveFilePath),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
invalidateOnEnvChange(env) {
|
|
170
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnEnvChange.add(env);
|
|
171
|
+
}
|
|
172
|
+
invalidateOnStartup() {
|
|
173
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnStartup = true;
|
|
174
|
+
}
|
|
175
|
+
invalidateOnBuild() {
|
|
176
|
+
__classPrivateFieldGet(this, _PublicConfig_config, "f").invalidateOnBuild = true;
|
|
177
|
+
}
|
|
178
|
+
async getConfigFrom(searchPath, fileNames, options) {
|
|
179
|
+
// @ts-expect-error TS2339
|
|
180
|
+
let packageKey = options?.packageKey;
|
|
181
|
+
if (packageKey != null) {
|
|
182
|
+
let pkg = await this.getConfigFrom(searchPath, ['package.json'], {
|
|
183
|
+
exclude: true,
|
|
184
|
+
});
|
|
185
|
+
// @ts-expect-error TS18046
|
|
186
|
+
if (pkg && pkg.contents[packageKey]) {
|
|
187
|
+
// Invalidate only when the package key changes
|
|
188
|
+
this.invalidateOnConfigKeyChange(pkg.filePath, [packageKey]);
|
|
189
|
+
return {
|
|
190
|
+
// @ts-expect-error TS18046
|
|
191
|
+
contents: pkg.contents[packageKey],
|
|
192
|
+
filePath: pkg.filePath,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// @ts-expect-error TS2339
|
|
197
|
+
const readTracking = options?.readTracking;
|
|
198
|
+
if (readTracking === true) {
|
|
199
|
+
for (let fileName of fileNames) {
|
|
200
|
+
const config = await this.getConfigFrom(searchPath, [fileName], {
|
|
201
|
+
exclude: true,
|
|
202
|
+
});
|
|
203
|
+
if (config != null) {
|
|
204
|
+
// @ts-expect-error TS2322
|
|
205
|
+
return Promise.resolve({
|
|
206
|
+
contents: makeConfigProxy((keyPath) => {
|
|
207
|
+
this.invalidateOnConfigKeyChange(config.filePath, keyPath);
|
|
208
|
+
}, config.contents),
|
|
209
|
+
filePath: config.filePath,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// fall through so that file above invalidations are registered
|
|
214
|
+
}
|
|
215
|
+
if (fileNames.length === 0) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
// Invalidate when any of the file names are created above the search path.
|
|
219
|
+
for (let fileName of fileNames) {
|
|
220
|
+
this.invalidateOnFileCreate({
|
|
221
|
+
fileName,
|
|
222
|
+
aboveFilePath: searchPath,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// @ts-expect-error TS2339
|
|
226
|
+
let parse = options && options.parse;
|
|
227
|
+
let configFilePath = await (0, utils_1.resolveConfig)(__classPrivateFieldGet(this, _PublicConfig_options, "f").inputFS, searchPath, fileNames, __classPrivateFieldGet(this, _PublicConfig_options, "f").projectRoot);
|
|
228
|
+
if (configFilePath == null) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
// @ts-expect-error TS2339
|
|
232
|
+
if (!options || !options.exclude) {
|
|
233
|
+
this.invalidateOnFileChange(configFilePath);
|
|
234
|
+
}
|
|
235
|
+
// If this is a JavaScript file, load it with the package manager.
|
|
236
|
+
let extname = path_1.default.extname(configFilePath);
|
|
237
|
+
if (extname === '.js' || extname === '.cjs' || extname === '.mjs') {
|
|
238
|
+
let specifier = (0, utils_1.relativePath)(path_1.default.dirname(searchPath), configFilePath);
|
|
239
|
+
// Add dev dependency so we reload the config and any dependencies in watch mode.
|
|
240
|
+
this.addDevDependency({
|
|
241
|
+
specifier,
|
|
242
|
+
resolveFrom: searchPath,
|
|
243
|
+
});
|
|
244
|
+
// Invalidate on startup in case the config is non-deterministic,
|
|
245
|
+
// e.g. uses unknown environment variables, reads from the filesystem, etc.
|
|
246
|
+
this.invalidateOnStartup();
|
|
247
|
+
let config = await __classPrivateFieldGet(this, _PublicConfig_options, "f").packageManager.require(specifier, searchPath);
|
|
248
|
+
if (Object.prototype.toString.call(config) === '[object Module]' &&
|
|
249
|
+
config.default != null) {
|
|
250
|
+
// Native ESM config. Try to use a default export, otherwise fall back to the whole namespace.
|
|
251
|
+
config = config.default;
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
contents: config,
|
|
255
|
+
filePath: configFilePath,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
let conf = await (0, utils_1.readConfig)(__classPrivateFieldGet(this, _PublicConfig_options, "f").inputFS, configFilePath, parse == null ? null : { parse });
|
|
259
|
+
if (conf == null) {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
contents: conf.config,
|
|
264
|
+
filePath: configFilePath,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
getConfig(filePaths, options) {
|
|
268
|
+
return this.getConfigFrom(this.searchPath, filePaths, options);
|
|
269
|
+
}
|
|
270
|
+
async getPackage() {
|
|
271
|
+
if (__classPrivateFieldGet(this, _PublicConfig_pkg, "f")) {
|
|
272
|
+
return __classPrivateFieldGet(this, _PublicConfig_pkg, "f");
|
|
273
|
+
}
|
|
274
|
+
let pkgConfig = await this.getConfig(['package.json'], {
|
|
275
|
+
readTracking: true,
|
|
276
|
+
});
|
|
277
|
+
if (!pkgConfig) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
__classPrivateFieldSet(this, _PublicConfig_pkg, pkgConfig.contents, "f");
|
|
281
|
+
__classPrivateFieldSet(this, _PublicConfig_pkgFilePath, pkgConfig.filePath, "f");
|
|
282
|
+
return __classPrivateFieldGet(this, _PublicConfig_pkg, "f");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
_PublicConfig_config = new WeakMap(), _PublicConfig_pkg = new WeakMap(), _PublicConfig_pkgFilePath = new WeakMap(), _PublicConfig_options = new WeakMap();
|
|
286
|
+
exports.default = PublicConfig;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _Dependency_dep, _Dependency_options;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.dependencyToInternalDependency = dependencyToInternalDependency;
|
|
19
|
+
exports.getPublicDependency = getPublicDependency;
|
|
20
|
+
const types_1 = require("../types");
|
|
21
|
+
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
22
|
+
const Environment_1 = __importDefault(require("./Environment"));
|
|
23
|
+
const Target_1 = __importDefault(require("./Target"));
|
|
24
|
+
const Symbols_1 = require("./Symbols");
|
|
25
|
+
const types_2 = require("../types");
|
|
26
|
+
const projectPath_1 = require("../projectPath");
|
|
27
|
+
const utils_1 = require("../utils");
|
|
28
|
+
const EnvironmentManager_1 = require("../EnvironmentManager");
|
|
29
|
+
const SpecifierTypeNames = Object.keys(types_2.SpecifierType);
|
|
30
|
+
const PriorityNames = Object.keys(types_2.Priority);
|
|
31
|
+
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
32
|
+
const internalDependencyToDependency = new WeakMap();
|
|
33
|
+
const _dependencyToInternalDependency = new WeakMap();
|
|
34
|
+
function dependencyToInternalDependency(dependency) {
|
|
35
|
+
return (0, nullthrows_1.default)(_dependencyToInternalDependency.get(dependency));
|
|
36
|
+
}
|
|
37
|
+
function getPublicDependency(dep, options) {
|
|
38
|
+
let existing = internalDependencyToDependency.get(dep);
|
|
39
|
+
if (existing != null) {
|
|
40
|
+
return existing;
|
|
41
|
+
}
|
|
42
|
+
return new Dependency(dep, options);
|
|
43
|
+
}
|
|
44
|
+
class Dependency {
|
|
45
|
+
constructor(dep, options) {
|
|
46
|
+
_Dependency_dep.set(this, void 0);
|
|
47
|
+
_Dependency_options.set(this, void 0);
|
|
48
|
+
__classPrivateFieldSet(this, _Dependency_dep, dep, "f");
|
|
49
|
+
__classPrivateFieldSet(this, _Dependency_options, options, "f");
|
|
50
|
+
_dependencyToInternalDependency.set(this, dep);
|
|
51
|
+
internalDependencyToDependency.set(dep, this);
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
[(_Dependency_dep = new WeakMap(), _Dependency_options = new WeakMap(), inspect)]() {
|
|
55
|
+
return `Dependency(${String(this.sourcePath)} -> ${this.specifier})`;
|
|
56
|
+
}
|
|
57
|
+
get id() {
|
|
58
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").id;
|
|
59
|
+
}
|
|
60
|
+
get specifier() {
|
|
61
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").specifier;
|
|
62
|
+
}
|
|
63
|
+
get specifierType() {
|
|
64
|
+
// @ts-expect-error TS2322
|
|
65
|
+
return SpecifierTypeNames[__classPrivateFieldGet(this, _Dependency_dep, "f").specifierType];
|
|
66
|
+
}
|
|
67
|
+
get priority() {
|
|
68
|
+
// @ts-expect-error TS2322
|
|
69
|
+
return PriorityNames[__classPrivateFieldGet(this, _Dependency_dep, "f").priority];
|
|
70
|
+
}
|
|
71
|
+
get needsStableName() {
|
|
72
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").needsStableName;
|
|
73
|
+
}
|
|
74
|
+
get bundleBehavior() {
|
|
75
|
+
let bundleBehavior = __classPrivateFieldGet(this, _Dependency_dep, "f").bundleBehavior;
|
|
76
|
+
return bundleBehavior == null ? null : types_1.BundleBehaviorNames[bundleBehavior];
|
|
77
|
+
}
|
|
78
|
+
get isEntry() {
|
|
79
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").isEntry;
|
|
80
|
+
}
|
|
81
|
+
get isOptional() {
|
|
82
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").isOptional;
|
|
83
|
+
}
|
|
84
|
+
get loc() {
|
|
85
|
+
return (0, utils_1.fromInternalSourceLocation)(__classPrivateFieldGet(this, _Dependency_options, "f").projectRoot, __classPrivateFieldGet(this, _Dependency_dep, "f").loc);
|
|
86
|
+
}
|
|
87
|
+
get env() {
|
|
88
|
+
return new Environment_1.default((0, EnvironmentManager_1.fromEnvironmentId)(__classPrivateFieldGet(this, _Dependency_dep, "f").env), __classPrivateFieldGet(this, _Dependency_options, "f"));
|
|
89
|
+
}
|
|
90
|
+
get packageConditions() {
|
|
91
|
+
// Merge custom conditions with conditions stored as bitflags.
|
|
92
|
+
// Order is not important because exports conditions are resolved
|
|
93
|
+
// in the order they are declared in the package.json.
|
|
94
|
+
let conditions = __classPrivateFieldGet(this, _Dependency_dep, "f").customPackageConditions;
|
|
95
|
+
if (__classPrivateFieldGet(this, _Dependency_dep, "f").packageConditions) {
|
|
96
|
+
conditions = conditions ? [...conditions] : [];
|
|
97
|
+
for (let key in types_2.ExportsCondition) {
|
|
98
|
+
// @ts-expect-error TS7053
|
|
99
|
+
if (__classPrivateFieldGet(this, _Dependency_dep, "f").packageConditions & types_2.ExportsCondition[key]) {
|
|
100
|
+
conditions.push(key);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return conditions;
|
|
105
|
+
}
|
|
106
|
+
get meta() {
|
|
107
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").meta;
|
|
108
|
+
}
|
|
109
|
+
get symbols() {
|
|
110
|
+
// @ts-expect-error TS2322
|
|
111
|
+
return new Symbols_1.MutableDependencySymbols(__classPrivateFieldGet(this, _Dependency_options, "f"), __classPrivateFieldGet(this, _Dependency_dep, "f"));
|
|
112
|
+
}
|
|
113
|
+
get target() {
|
|
114
|
+
let target = __classPrivateFieldGet(this, _Dependency_dep, "f").target;
|
|
115
|
+
return target ? new Target_1.default(target, __classPrivateFieldGet(this, _Dependency_options, "f")) : null;
|
|
116
|
+
}
|
|
117
|
+
get sourceAssetId() {
|
|
118
|
+
// TODO: does this need to be public?
|
|
119
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").sourceAssetId;
|
|
120
|
+
}
|
|
121
|
+
get sourcePath() {
|
|
122
|
+
// TODO: does this need to be public?
|
|
123
|
+
return (0, projectPath_1.fromProjectPath)(__classPrivateFieldGet(this, _Dependency_options, "f").projectRoot, __classPrivateFieldGet(this, _Dependency_dep, "f").sourcePath);
|
|
124
|
+
}
|
|
125
|
+
get sourceAssetType() {
|
|
126
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").sourceAssetType;
|
|
127
|
+
}
|
|
128
|
+
get resolveFrom() {
|
|
129
|
+
return (0, projectPath_1.fromProjectPath)(__classPrivateFieldGet(this, _Dependency_options, "f").projectRoot, __classPrivateFieldGet(this, _Dependency_dep, "f").resolveFrom ?? __classPrivateFieldGet(this, _Dependency_dep, "f").sourcePath);
|
|
130
|
+
}
|
|
131
|
+
get range() {
|
|
132
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").range;
|
|
133
|
+
}
|
|
134
|
+
get pipeline() {
|
|
135
|
+
return __classPrivateFieldGet(this, _Dependency_dep, "f").pipeline;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.default = Dependency;
|