@atlaspack/core 2.16.2-canary.182 → 2.16.2-canary.184
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/lib/requests/TargetRequest.js +46 -6
- package/lib/requests/WriteBundlesRequest.js +7 -26
- package/lib/resolveOptions.js +15 -0
- package/lib/types/requests/WriteBundlesRequest.d.ts +1 -1
- package/package.json +17 -17
- package/src/requests/TargetRequest.ts +56 -3
- package/src/requests/WriteBundlesRequest.ts +16 -16
- package/src/resolveOptions.ts +23 -0
|
@@ -70,6 +70,13 @@ var _utils2 = require("../utils");
|
|
|
70
70
|
var _projectPath = require("../projectPath");
|
|
71
71
|
var _RequestTracker = require("../RequestTracker");
|
|
72
72
|
var _EnvironmentManager = require("../EnvironmentManager");
|
|
73
|
+
function _featureFlags() {
|
|
74
|
+
const data = require("@atlaspack/feature-flags");
|
|
75
|
+
_featureFlags = function () {
|
|
76
|
+
return data;
|
|
77
|
+
};
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
73
80
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
74
81
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
75
82
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -115,8 +122,6 @@ function skipTarget(targetName, exclusiveTarget, descriptorSource) {
|
|
|
115
122
|
|
|
116
123
|
return exclusiveTarget == null ? descriptorSource != null : targetName !== exclusiveTarget;
|
|
117
124
|
}
|
|
118
|
-
|
|
119
|
-
// @ts-expect-error TS7031
|
|
120
125
|
async function run({
|
|
121
126
|
input,
|
|
122
127
|
api,
|
|
@@ -124,10 +129,35 @@ async function run({
|
|
|
124
129
|
}) {
|
|
125
130
|
let targetResolver = new TargetResolver(api, (0, _utils2.optionsProxy)(options, api.invalidateOnOptionChange));
|
|
126
131
|
let targets = await targetResolver.resolve((0, _projectPath.fromProjectPath)(options.projectRoot, input.packagePath), input.target);
|
|
132
|
+
|
|
133
|
+
// Filter targets based on allowExplicitTargetEntries feature flag
|
|
134
|
+
if ((0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries') && options.targets &&
|
|
135
|
+
// Only explicit targets are allowed (i.e. an object of targets)
|
|
136
|
+
!Array.isArray(options.targets)) {
|
|
137
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
138
|
+
const allTargetsHaveSources = targets.every(t => t.source);
|
|
139
|
+
if (allTargetsHaveSources) {
|
|
140
|
+
// Get the current entry file path relative to project root
|
|
141
|
+
const currentEntryPath = input.filePath;
|
|
142
|
+
|
|
143
|
+
// Filter targets to only include those whose source matches the current entry
|
|
144
|
+
targets = targets.filter(target => {
|
|
145
|
+
// Handle both string and array sources
|
|
146
|
+
const sources = Array.isArray(target.source) ? target.source : [target.source];
|
|
147
|
+
|
|
148
|
+
// Check if current entry matches any of the target sources
|
|
149
|
+
return sources.some(source => {
|
|
150
|
+
const targetSourcePath = (0, _projectPath.toProjectPath)(options.projectRoot, _path().default.resolve((0, _projectPath.fromProjectPath)(options.projectRoot, input.packagePath), (0, _nullthrows().default)(source, 'Source must be not be undefined when specified')));
|
|
151
|
+
return targetSourcePath === currentEntryPath;
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
156
|
+
targets = targets.filter(target => !target.source);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
127
159
|
assertTargetsAreNotEntries(targets, input, options);
|
|
128
|
-
let configResult = (0, _nullthrows().default)(
|
|
129
|
-
// @ts-expect-error TS2347
|
|
130
|
-
await api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
160
|
+
let configResult = (0, _nullthrows().default)(await api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
131
161
|
let atlaspackConfig = (0, _AtlaspackConfigRequest.getCachedAtlaspackConfig)(configResult, options);
|
|
132
162
|
|
|
133
163
|
// Find named pipelines for each target.
|
|
@@ -236,7 +266,17 @@ class TargetResolver {
|
|
|
236
266
|
target.source = descriptor.source;
|
|
237
267
|
}
|
|
238
268
|
return target;
|
|
239
|
-
}).filter(target => !skipTarget(target.name, exclusiveTarget, target.source));
|
|
269
|
+
}).filter(target => (0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries') && this.options.entries.length !== 0 || !skipTarget(target.name, exclusiveTarget, target.source));
|
|
270
|
+
|
|
271
|
+
// Apply allowExplicitTargetEntries filtering logic
|
|
272
|
+
if ((0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries')) {
|
|
273
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
274
|
+
const allTargetsHaveSources = targets.every(t => t.source);
|
|
275
|
+
if (!allTargetsHaveSources) {
|
|
276
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
277
|
+
targets = targets.filter(target => !target.source);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
240
280
|
}
|
|
241
281
|
let serve = this.options.serveOptions;
|
|
242
282
|
if (serve && targets.length > 0) {
|
|
@@ -12,6 +12,7 @@ function _featureFlags() {
|
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
14
|
var _RequestTracker = require("../RequestTracker");
|
|
15
|
+
var _types = require("../types");
|
|
15
16
|
var _ReporterRunner = require("../ReporterRunner");
|
|
16
17
|
var _constants = require("../constants");
|
|
17
18
|
var _projectPath = require("../projectPath");
|
|
@@ -55,8 +56,6 @@ function createWriteBundlesRequest(input) {
|
|
|
55
56
|
input
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
// @ts-expect-error TS7031
|
|
60
59
|
async function run({
|
|
61
60
|
input,
|
|
62
61
|
api,
|
|
@@ -82,11 +81,7 @@ async function run({
|
|
|
82
81
|
const allBundles = bundleGraph.getBundles({
|
|
83
82
|
includeInline: (0, _featureFlags().getFeatureFlag)('inlineBundlesSourceMapFixes')
|
|
84
83
|
});
|
|
85
|
-
const bundles = allBundles.filter(
|
|
86
|
-
// @ts-expect-error TS7006
|
|
87
|
-
bundle => bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inline-isolated')
|
|
88
|
-
// @ts-expect-error TS7006
|
|
89
|
-
.filter(bundle => {
|
|
84
|
+
const bundles = allBundles.filter(bundle => bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated).filter(bundle => {
|
|
90
85
|
// Do not package and write placeholder bundles to disk. We just
|
|
91
86
|
// need to update the name so other bundles can reference it.
|
|
92
87
|
if (bundle.isPlaceholder) {
|
|
@@ -107,9 +102,7 @@ async function run({
|
|
|
107
102
|
}
|
|
108
103
|
return true;
|
|
109
104
|
});
|
|
110
|
-
let cachedBundles = new Set(
|
|
111
|
-
// @ts-expect-error TS7006
|
|
112
|
-
bundles.filter(b => api.canSkipSubrequest(bundleGraph.getHash(b))));
|
|
105
|
+
let cachedBundles = new Set(bundles.filter(b => api.canSkipSubrequest(bundleGraph.getHash(b))));
|
|
113
106
|
|
|
114
107
|
// Package on the main thread if there is only one bundle to package.
|
|
115
108
|
// This avoids the cost of serializing the bundle graph for single file change builds.
|
|
@@ -117,9 +110,7 @@ async function run({
|
|
|
117
110
|
try {
|
|
118
111
|
let completeBundles = cachedBundles.size;
|
|
119
112
|
reportPackagingProgress(completeBundles, bundles.length);
|
|
120
|
-
await Promise.all(
|
|
121
|
-
// @ts-expect-error TS7006
|
|
122
|
-
bundles.map(async bundle => {
|
|
113
|
+
await Promise.all(bundles.map(async bundle => {
|
|
123
114
|
let request = (0, _PackageRequest.createPackageRequest)({
|
|
124
115
|
bundle,
|
|
125
116
|
bundleGraph,
|
|
@@ -159,17 +150,13 @@ async function run({
|
|
|
159
150
|
}
|
|
160
151
|
}));
|
|
161
152
|
assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, options);
|
|
162
|
-
await Promise.all(
|
|
163
|
-
// @ts-expect-error TS7006
|
|
164
|
-
bundles.map(bundle => {
|
|
153
|
+
await Promise.all(bundles.map(bundle => {
|
|
165
154
|
let promise = writeEarlyPromises[bundle.id] ?? api.runRequest((0, _WriteBundleRequest.default)({
|
|
166
155
|
bundle,
|
|
167
156
|
info: bundleInfoMap[bundle.id],
|
|
168
157
|
hashRefToNameHash,
|
|
169
158
|
bundleGraph
|
|
170
159
|
}));
|
|
171
|
-
|
|
172
|
-
// @ts-expect-error TS7006
|
|
173
160
|
return promise.then(r => res.set(bundle.id, r));
|
|
174
161
|
}));
|
|
175
162
|
api.storeResult(res);
|
|
@@ -178,18 +165,12 @@ async function run({
|
|
|
178
165
|
await dispose();
|
|
179
166
|
}
|
|
180
167
|
}
|
|
181
|
-
function assignComplexNameHashes(hashRefToNameHash,
|
|
182
|
-
// @ts-expect-error TS2304
|
|
183
|
-
bundles, bundleInfoMap,
|
|
184
|
-
// @ts-expect-error TS2304
|
|
185
|
-
options) {
|
|
168
|
+
function assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, options) {
|
|
186
169
|
for (let bundle of bundles) {
|
|
187
170
|
if (hashRefToNameHash.get(bundle.hashReference) != null) {
|
|
188
171
|
continue;
|
|
189
172
|
}
|
|
190
|
-
hashRefToNameHash.set(bundle.hashReference, options.shouldContentHash ? (0, _rust().hashString)([...getBundlesIncludedInHash(bundle.id, bundleInfoMap)]
|
|
191
|
-
// @ts-expect-error TS2538
|
|
192
|
-
.map(bundleId => bundleInfoMap[bundleId].hash).join(':')).slice(-8) : bundle.id.slice(-8));
|
|
173
|
+
hashRefToNameHash.set(bundle.hashReference, options.shouldContentHash ? (0, _rust().hashString)([...getBundlesIncludedInHash(bundle.id, bundleInfoMap)].map(bundleId => bundleInfoMap[bundleId].hash).join(':')).slice(-8) : bundle.id.slice(-8));
|
|
193
174
|
}
|
|
194
175
|
}
|
|
195
176
|
function getBundlesIncludedInHash(bundleId, bundleInfoMap, included = new Set()) {
|
package/lib/resolveOptions.js
CHANGED
|
@@ -106,6 +106,21 @@ async function resolveOptions(initialOptions) {
|
|
|
106
106
|
} else {
|
|
107
107
|
entries = [_path().default.resolve(inputCwd, initialOptions.entries)];
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
// When allowExplicitTargetEntries is enabled and no entries are provided,
|
|
111
|
+
// automatically derive entries from target sources
|
|
112
|
+
if ((0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries') && initialOptions.targets && !Array.isArray(initialOptions.targets) && entries.length === 0) {
|
|
113
|
+
const targetSources = new Set();
|
|
114
|
+
for (const [, target] of Object.entries(initialOptions.targets)) {
|
|
115
|
+
if (target.source) {
|
|
116
|
+
const sources = Array.isArray(target.source) ? target.source : [target.source];
|
|
117
|
+
for (const source of sources) {
|
|
118
|
+
targetSources.add(source);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
entries = Array.from(targetSources);
|
|
123
|
+
}
|
|
109
124
|
let shouldMakeEntryReferFolder = false;
|
|
110
125
|
if (entries.length === 1 && !(0, _utils().isGlob)(entries[0])) {
|
|
111
126
|
let [entry] = entries;
|
|
@@ -3,7 +3,7 @@ import type { Async } from '@atlaspack/types';
|
|
|
3
3
|
import type { SharedReference } from '@atlaspack/workers';
|
|
4
4
|
import type { StaticRunOpts } from '../RequestTracker';
|
|
5
5
|
import { requestTypes } from '../RequestTracker';
|
|
6
|
-
import type
|
|
6
|
+
import { type PackagedBundleInfo } from '../types';
|
|
7
7
|
import type BundleGraph from '../BundleGraph';
|
|
8
8
|
type WriteBundlesRequestInput = {
|
|
9
9
|
bundleGraph: BundleGraph;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.16.2-canary.
|
|
3
|
+
"version": "2.16.2-canary.184+038e87a78",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,21 +23,21 @@
|
|
|
23
23
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@atlaspack/build-cache": "2.13.3-canary.
|
|
27
|
-
"@atlaspack/cache": "3.1.1-canary.
|
|
28
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
29
|
-
"@atlaspack/events": "2.14.1-canary.
|
|
30
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
31
|
-
"@atlaspack/fs": "2.14.5-canary.
|
|
32
|
-
"@atlaspack/graph": "3.4.1-canary.
|
|
33
|
-
"@atlaspack/logger": "2.14.5-canary.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.5-canary.
|
|
35
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
36
|
-
"@atlaspack/profiler": "2.14.1-canary.
|
|
37
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
38
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
39
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
40
|
-
"@atlaspack/workers": "2.14.5-canary.
|
|
26
|
+
"@atlaspack/build-cache": "2.13.3-canary.252+038e87a78",
|
|
27
|
+
"@atlaspack/cache": "3.1.1-canary.184+038e87a78",
|
|
28
|
+
"@atlaspack/diagnostic": "2.14.1-canary.252+038e87a78",
|
|
29
|
+
"@atlaspack/events": "2.14.1-canary.252+038e87a78",
|
|
30
|
+
"@atlaspack/feature-flags": "2.14.1-canary.252+038e87a78",
|
|
31
|
+
"@atlaspack/fs": "2.14.5-canary.184+038e87a78",
|
|
32
|
+
"@atlaspack/graph": "3.4.1-canary.252+038e87a78",
|
|
33
|
+
"@atlaspack/logger": "2.14.5-canary.184+038e87a78",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.5-canary.184+038e87a78",
|
|
35
|
+
"@atlaspack/plugin": "2.14.5-canary.184+038e87a78",
|
|
36
|
+
"@atlaspack/profiler": "2.14.1-canary.252+038e87a78",
|
|
37
|
+
"@atlaspack/rust": "3.2.1-canary.184+038e87a78",
|
|
38
|
+
"@atlaspack/types": "2.14.5-canary.184+038e87a78",
|
|
39
|
+
"@atlaspack/utils": "2.14.5-canary.184+038e87a78",
|
|
40
|
+
"@atlaspack/workers": "2.14.5-canary.184+038e87a78",
|
|
41
41
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
42
42
|
"@parcel/source-map": "^2.1.1",
|
|
43
43
|
"base-x": "^3.0.8",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
63
63
|
},
|
|
64
64
|
"type": "commonjs",
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "038e87a7858d39556d59d3a2d17db534d45f62c6"
|
|
66
66
|
}
|
|
@@ -47,6 +47,7 @@ import {optionsProxy, toInternalSourceLocation} from '../utils';
|
|
|
47
47
|
import {fromProjectPath, toProjectPath, joinProjectPath} from '../projectPath';
|
|
48
48
|
import {requestTypes} from '../RequestTracker';
|
|
49
49
|
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
50
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
50
51
|
|
|
51
52
|
type RunOpts<TResult> = {
|
|
52
53
|
input: Entry;
|
|
@@ -119,8 +120,7 @@ export function skipTarget(
|
|
|
119
120
|
: targetName !== exclusiveTarget;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
async function run({input, api, options}) {
|
|
123
|
+
async function run({input, api, options}: RunOpts<TargetRequestResult>) {
|
|
124
124
|
let targetResolver = new TargetResolver(
|
|
125
125
|
api,
|
|
126
126
|
optionsProxy(options, api.invalidateOnOptionChange),
|
|
@@ -130,10 +130,50 @@ async function run({input, api, options}) {
|
|
|
130
130
|
input.target,
|
|
131
131
|
);
|
|
132
132
|
|
|
133
|
+
// Filter targets based on allowExplicitTargetEntries feature flag
|
|
134
|
+
if (
|
|
135
|
+
getFeatureFlag('allowExplicitTargetEntries') &&
|
|
136
|
+
options.targets &&
|
|
137
|
+
// Only explicit targets are allowed (i.e. an object of targets)
|
|
138
|
+
!Array.isArray(options.targets)
|
|
139
|
+
) {
|
|
140
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
141
|
+
const allTargetsHaveSources = targets.every((t) => t.source);
|
|
142
|
+
if (allTargetsHaveSources) {
|
|
143
|
+
// Get the current entry file path relative to project root
|
|
144
|
+
const currentEntryPath = input.filePath;
|
|
145
|
+
|
|
146
|
+
// Filter targets to only include those whose source matches the current entry
|
|
147
|
+
targets = targets.filter((target) => {
|
|
148
|
+
// Handle both string and array sources
|
|
149
|
+
const sources = Array.isArray(target.source)
|
|
150
|
+
? target.source
|
|
151
|
+
: [target.source];
|
|
152
|
+
|
|
153
|
+
// Check if current entry matches any of the target sources
|
|
154
|
+
return sources.some((source) => {
|
|
155
|
+
const targetSourcePath = toProjectPath(
|
|
156
|
+
options.projectRoot,
|
|
157
|
+
path.resolve(
|
|
158
|
+
fromProjectPath(options.projectRoot, input.packagePath),
|
|
159
|
+
nullthrows(
|
|
160
|
+
source,
|
|
161
|
+
'Source must be not be undefined when specified',
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
return targetSourcePath === currentEntryPath;
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
170
|
+
targets = targets.filter((target) => !target.source);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
133
174
|
assertTargetsAreNotEntries(targets, input, options);
|
|
134
175
|
|
|
135
176
|
let configResult = nullthrows(
|
|
136
|
-
// @ts-expect-error TS2347
|
|
137
177
|
await api.runRequest<null, ConfigAndCachePath>(
|
|
138
178
|
createAtlaspackConfigRequest(),
|
|
139
179
|
),
|
|
@@ -329,8 +369,21 @@ export class TargetResolver {
|
|
|
329
369
|
})
|
|
330
370
|
.filter(
|
|
331
371
|
(target) =>
|
|
372
|
+
(getFeatureFlag('allowExplicitTargetEntries') &&
|
|
373
|
+
this.options.entries.length !== 0) ||
|
|
332
374
|
!skipTarget(target.name, exclusiveTarget, target.source),
|
|
333
375
|
);
|
|
376
|
+
|
|
377
|
+
// Apply allowExplicitTargetEntries filtering logic
|
|
378
|
+
if (getFeatureFlag('allowExplicitTargetEntries')) {
|
|
379
|
+
// Check if ALL targets have sources - only apply new behavior if they do
|
|
380
|
+
const allTargetsHaveSources = targets.every((t) => t.source);
|
|
381
|
+
|
|
382
|
+
if (!allTargetsHaveSources) {
|
|
383
|
+
// If not all targets have sources, fall back to old behavior (skip targets with sources)
|
|
384
|
+
targets = targets.filter((target) => !target.source);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
334
387
|
}
|
|
335
388
|
|
|
336
389
|
let serve = this.options.serveOptions;
|
|
@@ -4,7 +4,12 @@ import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
|
4
4
|
import type {SharedReference} from '@atlaspack/workers';
|
|
5
5
|
import type {StaticRunOpts} from '../RequestTracker';
|
|
6
6
|
import {requestTypes} from '../RequestTracker';
|
|
7
|
-
import
|
|
7
|
+
import {
|
|
8
|
+
BundleBehavior,
|
|
9
|
+
type PackagedBundleInfo,
|
|
10
|
+
type Bundle,
|
|
11
|
+
type AtlaspackOptions,
|
|
12
|
+
} from '../types';
|
|
8
13
|
import type BundleGraph from '../BundleGraph';
|
|
9
14
|
import type {BundleInfo} from '../PackagerRunner';
|
|
10
15
|
import {report} from '../ReporterRunner';
|
|
@@ -66,8 +71,12 @@ export default function createWriteBundlesRequest(
|
|
|
66
71
|
};
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
async function run({
|
|
75
|
+
input,
|
|
76
|
+
api,
|
|
77
|
+
farm,
|
|
78
|
+
options,
|
|
79
|
+
}: RunInput<WriteBundlesRequestResult>) {
|
|
71
80
|
let {bundleGraph, optionsRef} = input;
|
|
72
81
|
let {ref, dispose} = await farm.createSharedReference(bundleGraph);
|
|
73
82
|
|
|
@@ -77,7 +86,7 @@ async function run({input, api, farm, options}) {
|
|
|
77
86
|
let bundleInfoMap: {
|
|
78
87
|
[key: string]: BundleInfo;
|
|
79
88
|
} = {};
|
|
80
|
-
let writeEarlyPromises: Record<string,
|
|
89
|
+
let writeEarlyPromises: Record<string, Promise<PackagedBundleInfo>> = {};
|
|
81
90
|
let hashRefToNameHash = new Map();
|
|
82
91
|
|
|
83
92
|
// Include inline bundles so that non-inline bundles referenced from inline bundles are written to
|
|
@@ -87,12 +96,10 @@ async function run({input, api, farm, options}) {
|
|
|
87
96
|
});
|
|
88
97
|
const bundles = allBundles
|
|
89
98
|
.filter(
|
|
90
|
-
// @ts-expect-error TS7006
|
|
91
99
|
(bundle) =>
|
|
92
|
-
bundle.bundleBehavior !==
|
|
93
|
-
bundle.bundleBehavior !==
|
|
100
|
+
bundle.bundleBehavior !== BundleBehavior.inline &&
|
|
101
|
+
bundle.bundleBehavior !== BundleBehavior.inlineIsolated,
|
|
94
102
|
)
|
|
95
|
-
// @ts-expect-error TS7006
|
|
96
103
|
.filter((bundle) => {
|
|
97
104
|
// Do not package and write placeholder bundles to disk. We just
|
|
98
105
|
// need to update the name so other bundles can reference it.
|
|
@@ -119,7 +126,6 @@ async function run({input, api, farm, options}) {
|
|
|
119
126
|
});
|
|
120
127
|
|
|
121
128
|
let cachedBundles = new Set(
|
|
122
|
-
// @ts-expect-error TS7006
|
|
123
129
|
bundles.filter((b) => api.canSkipSubrequest(bundleGraph.getHash(b))),
|
|
124
130
|
);
|
|
125
131
|
|
|
@@ -133,7 +139,6 @@ async function run({input, api, farm, options}) {
|
|
|
133
139
|
reportPackagingProgress(completeBundles, bundles.length);
|
|
134
140
|
|
|
135
141
|
await Promise.all(
|
|
136
|
-
// @ts-expect-error TS7006
|
|
137
142
|
bundles.map(async (bundle) => {
|
|
138
143
|
let request = createPackageRequest({
|
|
139
144
|
bundle,
|
|
@@ -185,7 +190,6 @@ async function run({input, api, farm, options}) {
|
|
|
185
190
|
);
|
|
186
191
|
assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, options);
|
|
187
192
|
await Promise.all(
|
|
188
|
-
// @ts-expect-error TS7006
|
|
189
193
|
bundles.map((bundle) => {
|
|
190
194
|
let promise =
|
|
191
195
|
writeEarlyPromises[bundle.id] ??
|
|
@@ -198,7 +202,6 @@ async function run({input, api, farm, options}) {
|
|
|
198
202
|
}),
|
|
199
203
|
);
|
|
200
204
|
|
|
201
|
-
// @ts-expect-error TS7006
|
|
202
205
|
return promise.then((r) => res.set(bundle.id, r));
|
|
203
206
|
}),
|
|
204
207
|
);
|
|
@@ -212,12 +215,10 @@ async function run({input, api, farm, options}) {
|
|
|
212
215
|
|
|
213
216
|
function assignComplexNameHashes(
|
|
214
217
|
hashRefToNameHash: Map<string, string>,
|
|
215
|
-
// @ts-expect-error TS2304
|
|
216
218
|
bundles: Array<Bundle>,
|
|
217
219
|
bundleInfoMap: {
|
|
218
220
|
[key: string]: BundleInfo;
|
|
219
221
|
},
|
|
220
|
-
// @ts-expect-error TS2304
|
|
221
222
|
options: AtlaspackOptions,
|
|
222
223
|
) {
|
|
223
224
|
for (let bundle of bundles) {
|
|
@@ -229,7 +230,6 @@ function assignComplexNameHashes(
|
|
|
229
230
|
options.shouldContentHash
|
|
230
231
|
? hashString(
|
|
231
232
|
[...getBundlesIncludedInHash(bundle.id, bundleInfoMap)]
|
|
232
|
-
// @ts-expect-error TS2538
|
|
233
233
|
.map((bundleId) => bundleInfoMap[bundleId].hash)
|
|
234
234
|
.join(':'),
|
|
235
235
|
).slice(-8)
|
|
@@ -243,7 +243,7 @@ function getBundlesIncludedInHash(
|
|
|
243
243
|
bundleInfoMap: {
|
|
244
244
|
[key: string]: BundleInfo;
|
|
245
245
|
},
|
|
246
|
-
included = new Set(),
|
|
246
|
+
included = new Set<string>(),
|
|
247
247
|
) {
|
|
248
248
|
included.add(bundleId);
|
|
249
249
|
for (let hashRef of bundleInfoMap[bundleId]?.hashReferences ?? []) {
|
package/src/resolveOptions.ts
CHANGED
|
@@ -91,6 +91,29 @@ export default async function resolveOptions(
|
|
|
91
91
|
entries = [path.resolve(inputCwd, initialOptions.entries)];
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
// When allowExplicitTargetEntries is enabled and no entries are provided,
|
|
95
|
+
// automatically derive entries from target sources
|
|
96
|
+
if (
|
|
97
|
+
getFeatureFlag('allowExplicitTargetEntries') &&
|
|
98
|
+
initialOptions.targets &&
|
|
99
|
+
!Array.isArray(initialOptions.targets) &&
|
|
100
|
+
entries.length === 0
|
|
101
|
+
) {
|
|
102
|
+
const targetSources = new Set<string>();
|
|
103
|
+
|
|
104
|
+
for (const [, target] of Object.entries(initialOptions.targets)) {
|
|
105
|
+
if (target.source) {
|
|
106
|
+
const sources = Array.isArray(target.source)
|
|
107
|
+
? target.source
|
|
108
|
+
: [target.source];
|
|
109
|
+
for (const source of sources) {
|
|
110
|
+
targetSources.add(source);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
entries = Array.from(targetSources);
|
|
115
|
+
}
|
|
116
|
+
|
|
94
117
|
let shouldMakeEntryReferFolder = false;
|
|
95
118
|
if (entries.length === 1 && !isGlob(entries[0])) {
|
|
96
119
|
let [entry] = entries;
|