@atlaspack/core 2.23.6-dev-export-func-opt-67f87c28a.0 → 2.24.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 +30 -0
- package/lib/AssetGraph.js +2 -8
- package/lib/BundleGraph.js +2 -17
- package/lib/SymbolPropagation.js +4 -32
- package/lib/atlaspack-v3/worker/compat/asset-symbols.js +4 -3
- package/lib/public/Symbols.js +3 -52
- package/lib/types/BundleGraph.d.ts +6 -6
- package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +19 -19
- package/lib/types/public/BundleGraph.d.ts +3 -3
- package/lib/types/public/Symbols.d.ts +6 -6
- package/lib/types/types.d.ts +9 -9
- package/package.json +20 -21
- package/src/AssetGraph.ts +0 -4
- package/src/BundleGraph.ts +8 -18
- package/src/SymbolPropagation.ts +22 -43
- package/src/atlaspack-v3/worker/compat/asset-symbols.ts +38 -31
- package/src/public/BundleGraph.ts +3 -2
- package/src/public/Symbols.ts +2 -36
- package/src/types.ts +9 -8
- package/LICENSE +0 -201
package/lib/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContentKey } from '@atlaspack/graph';
|
|
2
|
-
import type { ASTGenerator, BuildMode, Engines, EnvironmentContext, EnvMap, FilePath, Glob, LogLevel, Meta, DependencySpecifier, PackageName, ReporterEvent, SemverRange, ServerOptions, SourceType, Stats, TargetSourceMapOptions, ConfigResult, OutputFormat, TargetDescriptor, HMROptions, DetailedReportOptions } from '@atlaspack/types';
|
|
2
|
+
import type { ASTGenerator, BuildMode, Engines, EnvironmentContext, EnvMap, FilePath, Glob, LogLevel, Meta, DependencySpecifier, PackageName, ReporterEvent, SemverRange, ServerOptions, SourceType, Stats, TargetSourceMapOptions, ConfigResult, OutputFormat, TargetDescriptor, HMROptions, DetailedReportOptions, Symbol } from '@atlaspack/types';
|
|
3
3
|
import type { SharedReference } from '@atlaspack/workers';
|
|
4
4
|
import type { FileSystem } from '@atlaspack/fs';
|
|
5
5
|
import type { Cache } from '@atlaspack/cache';
|
|
@@ -113,8 +113,8 @@ export type Dependency = {
|
|
|
113
113
|
sourceAssetType?: string | null | undefined;
|
|
114
114
|
resolveFrom: ProjectPath | null | undefined;
|
|
115
115
|
range: SemverRange | null | undefined;
|
|
116
|
-
symbols: Map<
|
|
117
|
-
local:
|
|
116
|
+
symbols: Map<Symbol, {
|
|
117
|
+
local: Symbol;
|
|
118
118
|
loc: InternalSourceLocation | null | undefined;
|
|
119
119
|
isWeak: boolean;
|
|
120
120
|
meta?: Meta | null | undefined;
|
|
@@ -146,8 +146,8 @@ export type Asset = {
|
|
|
146
146
|
pipeline: string | null | undefined;
|
|
147
147
|
astKey: string | null | undefined;
|
|
148
148
|
astGenerator: ASTGenerator | null | undefined;
|
|
149
|
-
symbols: Map<
|
|
150
|
-
local:
|
|
149
|
+
symbols: Map<Symbol, {
|
|
150
|
+
local: Symbol;
|
|
151
151
|
loc: InternalSourceLocation | null | undefined;
|
|
152
152
|
meta?: Meta | null | undefined;
|
|
153
153
|
}> | null | undefined;
|
|
@@ -271,7 +271,7 @@ export type AssetNode = {
|
|
|
271
271
|
id: ContentKey;
|
|
272
272
|
readonly type: 'asset';
|
|
273
273
|
value: Asset;
|
|
274
|
-
usedSymbols: Set<
|
|
274
|
+
usedSymbols: Set<Symbol>;
|
|
275
275
|
hasDeferred?: boolean;
|
|
276
276
|
usedSymbolsDownDirty: boolean;
|
|
277
277
|
usedSymbolsUpDirty: boolean;
|
|
@@ -286,16 +286,16 @@ export type DependencyNode = {
|
|
|
286
286
|
deferred: boolean;
|
|
287
287
|
/** dependency was deferred (= no used symbols (in immediate parents) & side-effect free) */
|
|
288
288
|
hasDeferred?: boolean;
|
|
289
|
-
usedSymbolsDown: Set<
|
|
289
|
+
usedSymbolsDown: Set<Symbol>;
|
|
290
290
|
/**
|
|
291
291
|
* a requested symbol -> either
|
|
292
292
|
* - if ambiguous (e.g. dependency to asset group with both CSS modules and JS asset): undefined
|
|
293
293
|
* - if external: null
|
|
294
294
|
* - the asset it resolved to, and the potentially renamed export name
|
|
295
295
|
*/
|
|
296
|
-
usedSymbolsUp: Map<
|
|
296
|
+
usedSymbolsUp: Map<Symbol, {
|
|
297
297
|
asset: ContentKey;
|
|
298
|
-
symbol:
|
|
298
|
+
symbol: Symbol | null | undefined;
|
|
299
299
|
} | undefined | null>;
|
|
300
300
|
usedSymbolsDownDirty: boolean;
|
|
301
301
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.24.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@atlaspack/build-cache": "2.13.6-dev-export-func-opt-67f87c28a.0",
|
|
27
|
-
"@atlaspack/cache": "3.2.25-dev-export-func-opt-67f87c28a.0",
|
|
28
|
-
"@atlaspack/diagnostic": "2.14.4-dev-export-func-opt-67f87c28a.0",
|
|
29
|
-
"@atlaspack/events": "2.14.4-dev-export-func-opt-67f87c28a.0",
|
|
30
|
-
"@atlaspack/feature-flags": "2.24.2-dev-export-func-opt-67f87c28a.0",
|
|
31
|
-
"@atlaspack/fs": "2.15.25-dev-export-func-opt-67f87c28a.0",
|
|
32
|
-
"@atlaspack/graph": "3.5.19-dev-export-func-opt-67f87c28a.0",
|
|
33
|
-
"@atlaspack/logger": "2.14.22-dev-export-func-opt-67f87c28a.0",
|
|
34
|
-
"@atlaspack/package-manager": "2.14.30-dev-export-func-opt-67f87c28a.0",
|
|
35
|
-
"@atlaspack/plugin": "2.14.30-dev-export-func-opt-67f87c28a.0",
|
|
36
|
-
"@atlaspack/profiler": "2.14.27-dev-export-func-opt-67f87c28a.0",
|
|
37
|
-
"@atlaspack/rust": "3.7.1-dev-export-func-opt-67f87c28a.0",
|
|
38
|
-
"@atlaspack/types": "2.15.20-dev-export-func-opt-67f87c28a.0",
|
|
39
|
-
"@atlaspack/utils": "2.19.2-dev-export-func-opt-67f87c28a.0",
|
|
40
|
-
"@atlaspack/workers": "2.14.30-dev-export-func-opt-67f87c28a.0",
|
|
41
26
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
27
|
+
"@atlaspack/build-cache": "2.13.5",
|
|
28
|
+
"@atlaspack/cache": "3.2.25",
|
|
29
|
+
"@atlaspack/diagnostic": "2.14.3",
|
|
30
|
+
"@atlaspack/events": "2.14.3",
|
|
31
|
+
"@atlaspack/feature-flags": "2.25.0",
|
|
32
|
+
"@atlaspack/fs": "2.15.25",
|
|
33
|
+
"@atlaspack/graph": "3.5.19",
|
|
34
|
+
"@atlaspack/logger": "2.14.22",
|
|
35
|
+
"@atlaspack/package-manager": "2.14.30",
|
|
36
|
+
"@atlaspack/plugin": "2.14.30",
|
|
37
|
+
"@atlaspack/profiler": "2.14.27",
|
|
38
|
+
"@atlaspack/rust": "3.8.0",
|
|
39
|
+
"@atlaspack/types": "2.15.20",
|
|
40
|
+
"@atlaspack/utils": "2.19.2",
|
|
41
|
+
"@atlaspack/workers": "2.14.30",
|
|
42
42
|
"@parcel/source-map": "^2.1.1",
|
|
43
43
|
"base-x": "^3.0.8",
|
|
44
44
|
"browserslist": "^4.6.6",
|
|
@@ -51,16 +51,15 @@
|
|
|
51
51
|
"semver": "^7.5.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@atlaspack/babel-register": "2.14.
|
|
54
|
+
"@atlaspack/babel-register": "2.14.3",
|
|
55
55
|
"@types/node": ">= 18",
|
|
56
|
-
"graphviz": "^0.0.9",
|
|
57
|
-
"jest-diff": "*",
|
|
58
56
|
"rfdc": "1",
|
|
57
|
+
"jest-diff": "*",
|
|
58
|
+
"graphviz": "^0.0.9",
|
|
59
59
|
"tempy": "^0.2.1"
|
|
60
60
|
},
|
|
61
61
|
"browser": {
|
|
62
62
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
63
63
|
},
|
|
64
|
-
"type": "commonjs"
|
|
65
|
-
"gitHead": "67f87c28a23fcf285d88a1c969de4e35956cb500"
|
|
64
|
+
"type": "commonjs"
|
|
66
65
|
}
|
package/src/AssetGraph.ts
CHANGED
|
@@ -327,9 +327,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
327
327
|
|
|
328
328
|
if (fromEnvironmentId(node.value.env).isLibrary) {
|
|
329
329
|
// in library mode, all of the entry's symbols are "used"
|
|
330
|
-
// @ts-expect-error TS2345
|
|
331
330
|
node.usedSymbolsDown.add('*');
|
|
332
|
-
// @ts-expect-error TS2345
|
|
333
331
|
node.usedSymbolsUp.set('*', undefined);
|
|
334
332
|
}
|
|
335
333
|
return node;
|
|
@@ -483,7 +481,6 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
483
481
|
[...dependencySymbols].every(([, {isWeak}]: [any, any]) => isWeak) &&
|
|
484
482
|
sideEffects === false &&
|
|
485
483
|
canDefer &&
|
|
486
|
-
// @ts-expect-error TS2345
|
|
487
484
|
!dependencySymbols.has('*');
|
|
488
485
|
|
|
489
486
|
if (!isDeferrable) {
|
|
@@ -521,7 +518,6 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
|
|
|
521
518
|
let depIsDeferrable =
|
|
522
519
|
d.symbols &&
|
|
523
520
|
!(fromEnvironmentId(d.env).isLibrary && d.isEntry) &&
|
|
524
|
-
// @ts-expect-error TS2345
|
|
525
521
|
!d.symbols.has('*') &&
|
|
526
522
|
![...d.symbols.keys()].some((symbol) => {
|
|
527
523
|
let assetSymbol = resolvedAsset.symbols?.get(symbol)?.local;
|
package/src/BundleGraph.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
TraversalActions,
|
|
5
5
|
BundleBehavior as IBundleBehavior,
|
|
6
6
|
ConditionMeta,
|
|
7
|
+
Symbol,
|
|
7
8
|
} from '@atlaspack/types';
|
|
8
9
|
import type {
|
|
9
10
|
ContentKey,
|
|
@@ -82,12 +83,12 @@ export type BundleGraphEdgeType =
|
|
|
82
83
|
type InternalSymbolResolution = {
|
|
83
84
|
asset: Asset;
|
|
84
85
|
exportSymbol: string;
|
|
85
|
-
symbol:
|
|
86
|
+
symbol: Symbol | null | undefined | false;
|
|
86
87
|
loc: InternalSourceLocation | null | undefined;
|
|
87
88
|
};
|
|
88
89
|
|
|
89
90
|
type InternalExportSymbolResolution = InternalSymbolResolution & {
|
|
90
|
-
readonly exportAs:
|
|
91
|
+
readonly exportAs: Symbol | string;
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
type BundleGraphOpts = {
|
|
@@ -286,7 +287,7 @@ export default class BundleGraph {
|
|
|
286
287
|
let nodeValueSymbols = node.value.symbols;
|
|
287
288
|
|
|
288
289
|
// asset -> symbols that should be imported directly from that asset
|
|
289
|
-
let targets = new DefaultMap<ContentKey, Map<
|
|
290
|
+
let targets = new DefaultMap<ContentKey, Map<Symbol, Symbol>>(
|
|
290
291
|
() => new Map(),
|
|
291
292
|
);
|
|
292
293
|
let externalSymbols = new Set();
|
|
@@ -316,7 +317,6 @@ export default class BundleGraph {
|
|
|
316
317
|
// It doesn't make sense to retarget dependencies where `*` is used, because the
|
|
317
318
|
// retargeting won't enable any benefits in that case (apart from potentially even more
|
|
318
319
|
// code being generated).
|
|
319
|
-
// @ts-expect-error TS2345
|
|
320
320
|
!node.usedSymbolsUp.has('*') &&
|
|
321
321
|
// TODO We currently can't rename imports in async imports, e.g. from
|
|
322
322
|
// (parcelRequire("...")).then(({ a }) => a);
|
|
@@ -333,11 +333,9 @@ export default class BundleGraph {
|
|
|
333
333
|
([, t]: [any, any]) => new Set([...t.values()]).size === t.size,
|
|
334
334
|
)
|
|
335
335
|
) {
|
|
336
|
-
// @ts-expect-error TS2367
|
|
337
336
|
let isReexportAll = nodeValueSymbols.get('*')?.local === '*';
|
|
338
337
|
let reexportAllLoc = isReexportAll
|
|
339
|
-
?
|
|
340
|
-
nullthrows(nodeValueSymbols.get('*')).loc
|
|
338
|
+
? nullthrows(nodeValueSymbols.get('*')).loc
|
|
341
339
|
: undefined;
|
|
342
340
|
|
|
343
341
|
// TODO adjust sourceAssetIdNode.value.dependencies ?
|
|
@@ -413,7 +411,6 @@ export default class BundleGraph {
|
|
|
413
411
|
invariant(!sourceAssetSymbols.has(as));
|
|
414
412
|
sourceAssetSymbols.set(as, {
|
|
415
413
|
loc: reexportAllLoc,
|
|
416
|
-
// @ts-expect-error TS2322
|
|
417
414
|
local: local,
|
|
418
415
|
});
|
|
419
416
|
}
|
|
@@ -1893,13 +1890,12 @@ export default class BundleGraph {
|
|
|
1893
1890
|
|
|
1894
1891
|
getSymbolResolution(
|
|
1895
1892
|
asset: Asset,
|
|
1896
|
-
symbol:
|
|
1893
|
+
symbol: Symbol,
|
|
1897
1894
|
boundary?: Bundle | null,
|
|
1898
1895
|
): InternalSymbolResolution {
|
|
1899
1896
|
let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
|
|
1900
1897
|
|
|
1901
1898
|
let identifier = asset.symbols?.get(symbol)?.local;
|
|
1902
|
-
// @ts-expect-error TS2367
|
|
1903
1899
|
if (symbol === '*') {
|
|
1904
1900
|
return {
|
|
1905
1901
|
asset,
|
|
@@ -1931,7 +1927,6 @@ export default class BundleGraph {
|
|
|
1931
1927
|
// External module or self-reference
|
|
1932
1928
|
return {
|
|
1933
1929
|
asset,
|
|
1934
|
-
// @ts-expect-error TS2322
|
|
1935
1930
|
exportSymbol: symbol,
|
|
1936
1931
|
symbol: identifier,
|
|
1937
1932
|
loc: asset.symbols?.get(symbol)?.loc,
|
|
@@ -1974,9 +1969,7 @@ export default class BundleGraph {
|
|
|
1974
1969
|
// Wildcard reexports are never listed in the reexporting asset's symbols.
|
|
1975
1970
|
if (
|
|
1976
1971
|
identifier == null &&
|
|
1977
|
-
// @ts-expect-error TS2367
|
|
1978
1972
|
depSymbols.get('*')?.local === '*' &&
|
|
1979
|
-
// @ts-expect-error TS2367
|
|
1980
1973
|
symbol !== 'default'
|
|
1981
1974
|
) {
|
|
1982
1975
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
@@ -2053,7 +2046,6 @@ export default class BundleGraph {
|
|
|
2053
2046
|
result = null;
|
|
2054
2047
|
} else if (result === undefined) {
|
|
2055
2048
|
// If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
|
|
2056
|
-
// @ts-expect-error TS2345
|
|
2057
2049
|
if (nonStaticDependency || asset.symbols?.has('*')) {
|
|
2058
2050
|
// ... and if there are non-statically analyzable dependencies or it's a CJS asset,
|
|
2059
2051
|
// fallback to namespace access.
|
|
@@ -2067,7 +2059,6 @@ export default class BundleGraph {
|
|
|
2067
2059
|
|
|
2068
2060
|
return {
|
|
2069
2061
|
asset,
|
|
2070
|
-
// @ts-expect-error TS2322
|
|
2071
2062
|
exportSymbol: symbol,
|
|
2072
2063
|
symbol: result,
|
|
2073
2064
|
loc: asset.symbols?.get(symbol)?.loc,
|
|
@@ -2116,7 +2107,6 @@ export default class BundleGraph {
|
|
|
2116
2107
|
let depSymbols = dep.symbols;
|
|
2117
2108
|
if (!depSymbols) continue;
|
|
2118
2109
|
|
|
2119
|
-
// @ts-expect-error TS2367
|
|
2120
2110
|
if (depSymbols.get('*')?.local === '*') {
|
|
2121
2111
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
2122
2112
|
if (!resolved) continue;
|
|
@@ -2258,7 +2248,7 @@ export default class BundleGraph {
|
|
|
2258
2248
|
}
|
|
2259
2249
|
}
|
|
2260
2250
|
|
|
2261
|
-
getUsedSymbolsAsset(asset: Asset): ReadonlySet<
|
|
2251
|
+
getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
|
|
2262
2252
|
let node = this._graph.getNodeByContentKey(asset.id);
|
|
2263
2253
|
invariant(node && node.type === 'asset');
|
|
2264
2254
|
return node.value.symbols
|
|
@@ -2268,7 +2258,7 @@ export default class BundleGraph {
|
|
|
2268
2258
|
|
|
2269
2259
|
getUsedSymbolsDependency(
|
|
2270
2260
|
dep: Dependency,
|
|
2271
|
-
): ReadonlySet<
|
|
2261
|
+
): ReadonlySet<Symbol> | null | undefined {
|
|
2272
2262
|
let node = this._graph.getNodeByContentKey(dep.id);
|
|
2273
2263
|
invariant(node && node.type === 'dependency');
|
|
2274
2264
|
return node.value.symbols
|
package/src/SymbolPropagation.ts
CHANGED
|
@@ -68,7 +68,6 @@ export function propagateSymbols({
|
|
|
68
68
|
(d) => d.value.specifierType === SpecifierType.esm,
|
|
69
69
|
)
|
|
70
70
|
) {
|
|
71
|
-
// @ts-expect-error TS2345
|
|
72
71
|
assetNode.value.symbols?.delete('*');
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -76,9 +75,9 @@ export function propagateSymbols({
|
|
|
76
75
|
// exportSymbol -> identifier
|
|
77
76
|
let assetSymbols:
|
|
78
77
|
| ReadonlyMap<
|
|
79
|
-
|
|
78
|
+
Symbol,
|
|
80
79
|
{
|
|
81
|
-
local:
|
|
80
|
+
local: Symbol;
|
|
82
81
|
loc: InternalSourceLocation | null | undefined;
|
|
83
82
|
meta?: Meta | null | undefined;
|
|
84
83
|
}
|
|
@@ -88,7 +87,7 @@ export function propagateSymbols({
|
|
|
88
87
|
// identifier -> exportSymbol
|
|
89
88
|
let assetSymbolsInverse;
|
|
90
89
|
if (assetSymbols) {
|
|
91
|
-
assetSymbolsInverse = new Map<
|
|
90
|
+
assetSymbolsInverse = new Map<Symbol, Set<Symbol>>();
|
|
92
91
|
for (let [s, {local}] of assetSymbols) {
|
|
93
92
|
let set = assetSymbolsInverse.get(local);
|
|
94
93
|
|
|
@@ -100,7 +99,6 @@ export function propagateSymbols({
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
let hasNamespaceOutgoingDeps = outgoingDeps.some(
|
|
103
|
-
// @ts-expect-error TS2367
|
|
104
102
|
(d) => d.value.symbols?.get('*')?.local === '*',
|
|
105
103
|
);
|
|
106
104
|
|
|
@@ -114,13 +112,11 @@ export function propagateSymbols({
|
|
|
114
112
|
assetNode.usedSymbols = new Set();
|
|
115
113
|
|
|
116
114
|
// Symbols that have to be namespace reexported by outgoingDeps.
|
|
117
|
-
let namespaceReexportedSymbols = new Set<
|
|
115
|
+
let namespaceReexportedSymbols = new Set<Symbol>();
|
|
118
116
|
|
|
119
117
|
if (incomingDeps.length === 0) {
|
|
120
118
|
// Root in the runtimes Graph
|
|
121
|
-
// @ts-expect-error TS2345
|
|
122
119
|
assetNode.usedSymbols.add('*');
|
|
123
|
-
// @ts-expect-error TS2345
|
|
124
120
|
namespaceReexportedSymbols.add('*');
|
|
125
121
|
} else {
|
|
126
122
|
for (let incomingDep of incomingDeps) {
|
|
@@ -139,17 +135,13 @@ export function propagateSymbols({
|
|
|
139
135
|
}
|
|
140
136
|
|
|
141
137
|
for (let exportSymbol of incomingDep.usedSymbolsDown) {
|
|
142
|
-
// @ts-expect-error TS2367
|
|
143
138
|
if (exportSymbol === '*') {
|
|
144
|
-
// @ts-expect-error TS2345
|
|
145
139
|
assetNode.usedSymbols.add('*');
|
|
146
|
-
// @ts-expect-error TS2345
|
|
147
140
|
namespaceReexportedSymbols.add('*');
|
|
148
141
|
}
|
|
149
142
|
if (
|
|
150
143
|
!assetSymbols ||
|
|
151
144
|
assetSymbols.has(exportSymbol) ||
|
|
152
|
-
// @ts-expect-error TS2345
|
|
153
145
|
assetSymbols.has('*')
|
|
154
146
|
) {
|
|
155
147
|
// An own symbol or a non-namespace reexport
|
|
@@ -159,7 +151,6 @@ export function propagateSymbols({
|
|
|
159
151
|
// (but only if we actually have namespace-exporting outgoing dependencies,
|
|
160
152
|
// This usually happens with a reexporting asset with many namespace exports which means that
|
|
161
153
|
// we cannot match up the correct asset with the used symbol at this level.)
|
|
162
|
-
// @ts-expect-error TS2367
|
|
163
154
|
else if (hasNamespaceOutgoingDeps && exportSymbol !== 'default') {
|
|
164
155
|
namespaceReexportedSymbols.add(exportSymbol);
|
|
165
156
|
}
|
|
@@ -173,10 +164,10 @@ export function propagateSymbols({
|
|
|
173
164
|
(
|
|
174
165
|
_: {
|
|
175
166
|
loc: InternalSourceLocation | null | undefined;
|
|
176
|
-
local:
|
|
167
|
+
local: Symbol;
|
|
177
168
|
meta?: Meta | null | undefined;
|
|
178
169
|
},
|
|
179
|
-
exportSymbol:
|
|
170
|
+
exportSymbol: Symbol,
|
|
180
171
|
) => assetNode.usedSymbols.add(exportSymbol),
|
|
181
172
|
);
|
|
182
173
|
}
|
|
@@ -205,7 +196,6 @@ export function propagateSymbols({
|
|
|
205
196
|
let depSymbols = dep.value.symbols;
|
|
206
197
|
if (!depSymbols) continue;
|
|
207
198
|
|
|
208
|
-
// @ts-expect-error TS2367
|
|
209
199
|
if (depSymbols.get('*')?.local === '*') {
|
|
210
200
|
if (addAll) {
|
|
211
201
|
depUsedSymbolsDown.add('*');
|
|
@@ -219,7 +209,6 @@ export function propagateSymbols({
|
|
|
219
209
|
|
|
220
210
|
for (let [symbol, {local}] of depSymbols) {
|
|
221
211
|
// Was already handled above
|
|
222
|
-
// @ts-expect-error TS2367
|
|
223
212
|
if (local === '*') continue;
|
|
224
213
|
|
|
225
214
|
if (!assetSymbolsInverse || !depSymbols.get(symbol)?.isWeak) {
|
|
@@ -230,7 +219,6 @@ export function propagateSymbols({
|
|
|
230
219
|
if (reexportedExportSymbols == null) {
|
|
231
220
|
// not reexported = used in asset itself
|
|
232
221
|
depUsedSymbolsDown.add(symbol);
|
|
233
|
-
// @ts-expect-error TS2345
|
|
234
222
|
} else if (assetNode.usedSymbols.has('*')) {
|
|
235
223
|
// we need everything
|
|
236
224
|
depUsedSymbolsDown.add(symbol);
|
|
@@ -271,7 +259,7 @@ export function propagateSymbols({
|
|
|
271
259
|
|
|
272
260
|
const logFallbackNamespaceInsertion = (
|
|
273
261
|
assetNode: AssetNode,
|
|
274
|
-
symbol:
|
|
262
|
+
symbol: Symbol,
|
|
275
263
|
depNode1: DependencyNode,
|
|
276
264
|
depNode2: DependencyNode,
|
|
277
265
|
) => {
|
|
@@ -279,7 +267,6 @@ export function propagateSymbols({
|
|
|
279
267
|
logger.warn({
|
|
280
268
|
message: `${fromProjectPathRelative(
|
|
281
269
|
assetNode.value.filePath,
|
|
282
|
-
// @ts-expect-error TS2731
|
|
283
270
|
)} reexports "${symbol}", which could be resolved either to the dependency "${
|
|
284
271
|
depNode1.value.specifier
|
|
285
272
|
}" or "${
|
|
@@ -300,9 +287,9 @@ export function propagateSymbols({
|
|
|
300
287
|
(assetNode, incomingDeps, outgoingDeps) => {
|
|
301
288
|
let assetSymbols:
|
|
302
289
|
| ReadonlyMap<
|
|
303
|
-
|
|
290
|
+
Symbol,
|
|
304
291
|
{
|
|
305
|
-
local:
|
|
292
|
+
local: Symbol;
|
|
306
293
|
loc: InternalSourceLocation | null | undefined;
|
|
307
294
|
meta?: Meta | null | undefined;
|
|
308
295
|
}
|
|
@@ -312,7 +299,7 @@ export function propagateSymbols({
|
|
|
312
299
|
|
|
313
300
|
let assetSymbolsInverse = null;
|
|
314
301
|
if (assetSymbols) {
|
|
315
|
-
assetSymbolsInverse = new Map<
|
|
302
|
+
assetSymbolsInverse = new Map<Symbol, Set<Symbol>>();
|
|
316
303
|
for (let [s, {local}] of assetSymbols) {
|
|
317
304
|
let set = assetSymbolsInverse.get(local);
|
|
318
305
|
if (!set) {
|
|
@@ -325,10 +312,10 @@ export function propagateSymbols({
|
|
|
325
312
|
|
|
326
313
|
// the symbols that are reexported (not used in `asset`) -> asset they resolved to
|
|
327
314
|
let reexportedSymbols = new Map<
|
|
328
|
-
|
|
315
|
+
Symbol,
|
|
329
316
|
| {
|
|
330
317
|
asset: ContentKey;
|
|
331
|
-
symbol:
|
|
318
|
+
symbol: Symbol | null | undefined;
|
|
332
319
|
}
|
|
333
320
|
| null
|
|
334
321
|
| undefined
|
|
@@ -336,7 +323,7 @@ export function propagateSymbols({
|
|
|
336
323
|
// the symbols that are reexported (not used in `asset`) -> the corresponding outgoingDep(s)
|
|
337
324
|
// To generate the diagnostic when there are multiple dependencies with non-statically
|
|
338
325
|
// analyzable exports
|
|
339
|
-
let reexportedSymbolsSource = new Map<
|
|
326
|
+
let reexportedSymbolsSource = new Map<Symbol, DependencyNode>();
|
|
340
327
|
for (let outgoingDep of outgoingDeps) {
|
|
341
328
|
let outgoingDepSymbols = outgoingDep.value.symbols;
|
|
342
329
|
if (!outgoingDepSymbols) continue;
|
|
@@ -352,10 +339,8 @@ export function propagateSymbols({
|
|
|
352
339
|
);
|
|
353
340
|
}
|
|
354
341
|
|
|
355
|
-
// @ts-expect-error TS2367
|
|
356
342
|
if (outgoingDepSymbols.get('*')?.local === '*') {
|
|
357
343
|
outgoingDep.usedSymbolsUp.forEach((sResolved, s) => {
|
|
358
|
-
// @ts-expect-error TS2367
|
|
359
344
|
if (s === 'default') {
|
|
360
345
|
return;
|
|
361
346
|
}
|
|
@@ -363,7 +348,6 @@ export function propagateSymbols({
|
|
|
363
348
|
// If the symbol could come from multiple assets at runtime, assetNode's
|
|
364
349
|
// namespace will be needed at runtime to perform the lookup on.
|
|
365
350
|
if (reexportedSymbols.has(s)) {
|
|
366
|
-
// @ts-expect-error TS2345
|
|
367
351
|
if (!assetNode.usedSymbols.has('*')) {
|
|
368
352
|
logFallbackNamespaceInsertion(
|
|
369
353
|
assetNode,
|
|
@@ -372,7 +356,6 @@ export function propagateSymbols({
|
|
|
372
356
|
outgoingDep,
|
|
373
357
|
);
|
|
374
358
|
}
|
|
375
|
-
// @ts-expect-error TS2345
|
|
376
359
|
assetNode.usedSymbols.add('*');
|
|
377
360
|
reexportedSymbols.set(s, {asset: assetNode.id, symbol: s});
|
|
378
361
|
} else {
|
|
@@ -400,7 +383,6 @@ export function propagateSymbols({
|
|
|
400
383
|
reexported.forEach((s) => {
|
|
401
384
|
// see same code above
|
|
402
385
|
if (reexportedSymbols.has(s)) {
|
|
403
|
-
// @ts-expect-error TS2345
|
|
404
386
|
if (!assetNode.usedSymbols.has('*')) {
|
|
405
387
|
logFallbackNamespaceInsertion(
|
|
406
388
|
assetNode,
|
|
@@ -409,7 +391,6 @@ export function propagateSymbols({
|
|
|
409
391
|
outgoingDep,
|
|
410
392
|
);
|
|
411
393
|
}
|
|
412
|
-
// @ts-expect-error TS2345
|
|
413
394
|
assetNode.usedSymbols.add('*');
|
|
414
395
|
reexportedSymbols.set(s, {asset: assetNode.id, symbol: s});
|
|
415
396
|
} else {
|
|
@@ -425,32 +406,32 @@ export function propagateSymbols({
|
|
|
425
406
|
|
|
426
407
|
function usedSymbolsUpAmbiguous(
|
|
427
408
|
old: Map<
|
|
428
|
-
|
|
409
|
+
Symbol,
|
|
429
410
|
| {
|
|
430
411
|
asset: ContentKey;
|
|
431
|
-
symbol:
|
|
412
|
+
symbol: Symbol | null | undefined;
|
|
432
413
|
}
|
|
433
414
|
| null
|
|
434
415
|
| undefined
|
|
435
416
|
>,
|
|
436
417
|
current: Map<
|
|
437
|
-
|
|
418
|
+
Symbol,
|
|
438
419
|
| {
|
|
439
420
|
asset: ContentKey;
|
|
440
|
-
symbol:
|
|
421
|
+
symbol: Symbol | null | undefined;
|
|
441
422
|
}
|
|
442
423
|
| null
|
|
443
424
|
| undefined
|
|
444
425
|
>,
|
|
445
|
-
s:
|
|
426
|
+
s: Symbol,
|
|
446
427
|
value:
|
|
447
428
|
| {
|
|
448
429
|
asset: ContentKey;
|
|
449
|
-
symbol:
|
|
430
|
+
symbol: Symbol;
|
|
450
431
|
}
|
|
451
432
|
| {
|
|
452
433
|
asset: ContentKey;
|
|
453
|
-
symbol:
|
|
434
|
+
symbol: Symbol | null | undefined;
|
|
454
435
|
},
|
|
455
436
|
) {
|
|
456
437
|
if (old.has(s)) {
|
|
@@ -476,14 +457,12 @@ export function propagateSymbols({
|
|
|
476
457
|
let incomingDepSymbols = incomingDep.value.symbols;
|
|
477
458
|
if (!incomingDepSymbols) continue;
|
|
478
459
|
|
|
479
|
-
// @ts-expect-error TS2367
|
|
480
460
|
let hasNamespaceReexport = incomingDepSymbols.get('*')?.local === '*';
|
|
481
461
|
for (let s of incomingDep.usedSymbolsDown) {
|
|
482
462
|
if (
|
|
483
463
|
assetSymbols == null || // Assume everything could be provided if symbols are cleared
|
|
484
464
|
assetNode.value.bundleBehavior === BundleBehavior.isolated ||
|
|
485
465
|
assetNode.value.bundleBehavior === BundleBehavior.inline ||
|
|
486
|
-
// @ts-expect-error TS2367
|
|
487
466
|
s === '*' ||
|
|
488
467
|
assetNode.usedSymbols.has(s)
|
|
489
468
|
) {
|
|
@@ -850,7 +829,7 @@ function equalMap<K>(
|
|
|
850
829
|
K,
|
|
851
830
|
| {
|
|
852
831
|
asset: ContentKey;
|
|
853
|
-
symbol:
|
|
832
|
+
symbol: Symbol | null | undefined;
|
|
854
833
|
}
|
|
855
834
|
| null
|
|
856
835
|
| undefined
|
|
@@ -859,7 +838,7 @@ function equalMap<K>(
|
|
|
859
838
|
K,
|
|
860
839
|
| {
|
|
861
840
|
asset: ContentKey;
|
|
862
|
-
symbol:
|
|
841
|
+
symbol: Symbol | null | undefined;
|
|
863
842
|
}
|
|
864
843
|
| null
|
|
865
844
|
| undefined
|