@atlaspack/core 2.23.5 → 2.23.6-dev-export-func-opt-67f87c28a.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 ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2024 Atlassian US., Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -34,7 +34,8 @@ function createEnvironment({
34
34
  shouldScopeHoist = false,
35
35
  sourceMap,
36
36
  unstableSingleFileOutput = false,
37
- loc
37
+ loc,
38
+ customEnv
38
39
  } = {
39
40
  /*::...null*/
40
41
  }) {
@@ -111,7 +112,8 @@ function createEnvironment({
111
112
  shouldScopeHoist,
112
113
  sourceMap,
113
114
  unstableSingleFileOutput,
114
- loc
115
+ loc,
116
+ customEnv
115
117
  };
116
118
  res.id = getEnvironmentHash(res);
117
119
  return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
@@ -140,7 +142,8 @@ function getEnvironmentHash(env) {
140
142
  isLibrary: env.isLibrary,
141
143
  shouldOptimize: env.shouldOptimize,
142
144
  shouldScopeHoist: env.shouldScopeHoist,
143
- sourceMap: env.sourceMap
145
+ sourceMap: env.sourceMap,
146
+ customEnv: env.customEnv
144
147
  };
145
148
  const id = (0, _rust().createEnvironmentId)(data);
146
149
  _IdentifierRegistry.identifierRegistry.addIdentifier('environment', id, data);
@@ -98,6 +98,12 @@ const PACKAGE_DESCRIPTOR_SCHEMA = exports.PACKAGE_DESCRIPTOR_SCHEMA = {
98
98
  },
99
99
  __unstable_singleFileOutput: {
100
100
  type: 'boolean'
101
+ },
102
+ env: {
103
+ type: 'object',
104
+ additionalProperties: {
105
+ type: 'string'
106
+ }
101
107
  }
102
108
  },
103
109
  additionalProperties: false
@@ -21,6 +21,7 @@ class Environment {
21
21
  this.sourceMap = inner.sourceMap;
22
22
  this.loc = inner.loc;
23
23
  this.unstableSingleFileOutput = false;
24
+ this.customEnv = inner.customEnv;
24
25
  }
25
26
  isBrowser() {
26
27
  return this.context === 'browser' || this.isWorker() || this.isTesseract() || this.isWorklet() || this.context === 'electron-renderer';
@@ -269,6 +269,13 @@ class AtlaspackWorker {
269
269
  }
270
270
  (0, _assert().default)(result.length === 1, '[V3] Unimplemented: Multiple asset return from Node transformer');
271
271
  (0, _assert().default)(result[0] === mutableAsset, '[V3] Unimplemented: New asset returned from Node transformer');
272
+ let assetBuffer = await mutableAsset.getBuffer();
273
+
274
+ // If the asset has no code, we set the buffer to null, which we can
275
+ // detect in Rust, to avoid passing back an empty buffer, which we can't.
276
+ if (assetBuffer.length === 0) {
277
+ assetBuffer = null;
278
+ }
272
279
  return [{
273
280
  id: mutableAsset.id,
274
281
  bundleBehavior: _compat.bundleBehaviorMap.intoNullable(mutableAsset.bundleBehavior),
@@ -284,7 +291,7 @@ class AtlaspackWorker {
284
291
  symbols: mutableAsset.symbols.intoNapi(),
285
292
  type: mutableAsset.type,
286
293
  uniqueKey: mutableAsset.uniqueKey
287
- }, await mutableAsset.getBuffer(),
294
+ }, assetBuffer,
288
295
  // Only send back the map if it has changed
289
296
  mutableAsset.isMapDirty ?
290
297
  // @ts-expect-error TS2533
@@ -178,6 +178,9 @@ class Environment {
178
178
  get unstableSingleFileOutput() {
179
179
  return this.#environment.unstableSingleFileOutput;
180
180
  }
181
+ get customEnv() {
182
+ return this.#environment.customEnv;
183
+ }
181
184
  [inspect]() {
182
185
  return `Env(${this.#environment.context})`;
183
186
  }
@@ -99,19 +99,16 @@ function getAssetGraph(serializedGraph) {
99
99
  let jsSymbol = {
100
100
  local: symbol.local ?? undefined,
101
101
  loc: symbol.loc ?? undefined,
102
- meta: undefined,
103
- isWeak: symbol.isWeak
102
+ isWeak: symbol.isWeak,
103
+ meta: {
104
+ isEsm: symbol.isEsmExport,
105
+ isStaticBindingSafe: symbol.isStaticBindingSafe
106
+ }
104
107
  };
105
108
  if (symbol.exported) {
106
109
  // @ts-expect-error TS2339
107
110
  jsSymbol.exported = symbol.exported;
108
111
  }
109
- if (symbol.isEsmExport) {
110
- // @ts-expect-error TS2322
111
- jsSymbol.meta = {
112
- isEsm: true
113
- };
114
- }
115
112
  return [exported, jsSymbol];
116
113
  }
117
114
 
@@ -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.
@@ -226,7 +256,8 @@ class TargetResolver {
226
256
  shouldOptimize: this.options.defaultTargetOptions.shouldOptimize && descriptor.optimize !== false,
227
257
  shouldScopeHoist: this.options.defaultTargetOptions.shouldScopeHoist && descriptor.scopeHoist !== false,
228
258
  sourceMap: normalizeSourceMap(this.options, descriptor.sourceMap),
229
- unstableSingleFileOutput: descriptor.__unstable_singleFileOutput
259
+ unstableSingleFileOutput: descriptor.__unstable_singleFileOutput,
260
+ customEnv: descriptor.env
230
261
  })
231
262
  };
232
263
  if (descriptor.distEntry != null) {
@@ -236,7 +267,17 @@ class TargetResolver {
236
267
  target.source = descriptor.source;
237
268
  }
238
269
  return target;
239
- }).filter(target => !skipTarget(target.name, exclusiveTarget, target.source));
270
+ }).filter(target => (0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries') && this.options.entries.length !== 0 || !skipTarget(target.name, exclusiveTarget, target.source));
271
+
272
+ // Apply allowExplicitTargetEntries filtering logic
273
+ if ((0, _featureFlags().getFeatureFlag)('allowExplicitTargetEntries')) {
274
+ // Check if ALL targets have sources - only apply new behavior if they do
275
+ const allTargetsHaveSources = targets.every(t => t.source);
276
+ if (!allTargetsHaveSources) {
277
+ // If not all targets have sources, fall back to old behavior (skip targets with sources)
278
+ targets = targets.filter(target => !target.source);
279
+ }
280
+ }
240
281
  }
241
282
  let serve = this.options.serveOptions;
242
283
  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()) {
@@ -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;
@@ -1,10 +1,11 @@
1
- import type { EnvironmentOptions, Environment as IEnvironment, FilePath } from '@atlaspack/types';
1
+ import type { EnvironmentOptions, Environment as IEnvironment, FilePath, EnvMap } from '@atlaspack/types';
2
2
  import type { Environment, InternalSourceLocation } from './types';
3
3
  import type { EnvironmentRef } from './EnvironmentManager';
4
4
  type EnvironmentOpts = EnvironmentOptions & {
5
5
  loc?: InternalSourceLocation | null | undefined;
6
+ customEnv?: EnvMap | null | undefined;
6
7
  };
7
- export declare function createEnvironment({ context, engines, includeNodeModules, outputFormat, sourceType, shouldOptimize, isLibrary, shouldScopeHoist, sourceMap, unstableSingleFileOutput, loc, }?: EnvironmentOpts): EnvironmentRef;
8
+ export declare function createEnvironment({ context, engines, includeNodeModules, outputFormat, sourceType, shouldOptimize, isLibrary, shouldScopeHoist, sourceMap, unstableSingleFileOutput, loc, customEnv, }?: EnvironmentOpts): EnvironmentRef;
8
9
  export declare function mergeEnvironments(projectRoot: FilePath, a: Environment, b?: EnvironmentOptions | IEnvironment | null): EnvironmentRef;
9
10
  export declare function getEnvironmentHash(env: Environment): string;
10
11
  export {};
@@ -1,5 +1,5 @@
1
1
  import type { Environment as NapiEnvironment } from '@atlaspack/rust';
2
- import type { Environment as IEnvironment, EnvironmentContext, Engines, PackageName, OutputFormat, SourceType, TargetSourceMapOptions, SourceLocation, VersionMap, EnvironmentFeature } from '@atlaspack/types';
2
+ import type { Environment as IEnvironment, EnvironmentContext, Engines, PackageName, OutputFormat, SourceType, TargetSourceMapOptions, SourceLocation, VersionMap, EnvironmentFeature, EnvMap } from '@atlaspack/types';
3
3
  export declare class Environment implements IEnvironment {
4
4
  id: string;
5
5
  includeNodeModules: boolean | Array<PackageName> | Partial<Record<PackageName, boolean>>;
@@ -13,6 +13,7 @@ export declare class Environment implements IEnvironment {
13
13
  sourceMap: TargetSourceMapOptions | null | undefined;
14
14
  loc: SourceLocation | null | undefined;
15
15
  unstableSingleFileOutput: boolean;
16
+ customEnv: EnvMap | null | undefined;
16
17
  constructor(inner: NapiEnvironment);
17
18
  isBrowser(): boolean;
18
19
  isNode(): boolean;
@@ -1,4 +1,4 @@
1
- import type { Environment as IEnvironment, EnvironmentContext, EnvironmentFeature, Engines, OutputFormat, PackageName, VersionMap, SourceLocation, SourceType, TargetSourceMapOptions } from '@atlaspack/types';
1
+ import type { Environment as IEnvironment, EnvironmentContext, EnvironmentFeature, Engines, OutputFormat, PackageName, VersionMap, SourceLocation, SourceType, TargetSourceMapOptions, EnvMap } from '@atlaspack/types';
2
2
  import type { Environment as InternalEnvironment, AtlaspackOptions } from '../types';
3
3
  declare const inspect: unique symbol;
4
4
  export declare const BROWSER_ENVS: Set<string>;
@@ -19,6 +19,7 @@ export default class Environment implements IEnvironment {
19
19
  get sourceMap(): TargetSourceMapOptions | null | undefined;
20
20
  get loc(): SourceLocation | null | undefined;
21
21
  get unstableSingleFileOutput(): boolean;
22
+ get customEnv(): EnvMap | null | undefined;
22
23
  [inspect](): string;
23
24
  isBrowser(): boolean;
24
25
  isNode(): boolean;
@@ -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 { PackagedBundleInfo } from '../types';
6
+ import { type PackagedBundleInfo } from '../types';
7
7
  import type BundleGraph from '../BundleGraph';
8
8
  type WriteBundlesRequestInput = {
9
9
  bundleGraph: BundleGraph;
@@ -46,6 +46,7 @@ export type Environment = {
46
46
  sourceMap: TargetSourceMapOptions | null | undefined;
47
47
  loc: InternalSourceLocation | null | undefined;
48
48
  unstableSingleFileOutput: boolean;
49
+ customEnv: EnvMap | null | undefined;
49
50
  };
50
51
  export type InternalSourceLocation = {
51
52
  readonly filePath: ProjectPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.23.5",
3
+ "version": "2.23.6-dev-export-func-opt-67f87c28a.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "main": "./lib/index.js",
13
13
  "source": "./src/index.ts",
14
- "types": "./lib/types/index.d.ts",
14
+ "types": "./lib/index.d.ts",
15
15
  "engines": {
16
16
  "node": ">= 16.0.0"
17
17
  },
@@ -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",
26
41
  "@mischnic/json-sourcemap": "^0.1.0",
27
- "@atlaspack/build-cache": "2.13.5",
28
- "@atlaspack/cache": "3.2.24",
29
- "@atlaspack/diagnostic": "2.14.3",
30
- "@atlaspack/events": "2.14.3",
31
- "@atlaspack/feature-flags": "2.24.1",
32
- "@atlaspack/fs": "2.15.24",
33
- "@atlaspack/graph": "3.5.18",
34
- "@atlaspack/logger": "2.14.21",
35
- "@atlaspack/package-manager": "2.14.29",
36
- "@atlaspack/plugin": "2.14.29",
37
- "@atlaspack/profiler": "2.14.26",
38
- "@atlaspack/rust": "3.7.0",
39
- "@atlaspack/types": "2.15.19",
40
- "@atlaspack/utils": "2.19.1",
41
- "@atlaspack/workers": "2.14.29",
42
42
  "@parcel/source-map": "^2.1.1",
43
43
  "base-x": "^3.0.8",
44
44
  "browserslist": "^4.6.6",
@@ -51,15 +51,16 @@
51
51
  "semver": "^7.5.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@atlaspack/babel-register": "2.14.3",
54
+ "@atlaspack/babel-register": "2.14.4-dev-export-func-opt-67f87c28a.0",
55
55
  "@types/node": ">= 18",
56
- "rfdc": "1",
57
- "jest-diff": "*",
58
56
  "graphviz": "^0.0.9",
57
+ "jest-diff": "*",
58
+ "rfdc": "1",
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
- }
64
+ "type": "commonjs",
65
+ "gitHead": "67f87c28a23fcf285d88a1c969de4e35956cb500"
66
+ }
@@ -2,6 +2,7 @@ import type {
2
2
  EnvironmentOptions,
3
3
  Environment as IEnvironment,
4
4
  FilePath,
5
+ EnvMap,
5
6
  } from '@atlaspack/types';
6
7
  import type {Environment, InternalSourceLocation} from './types';
7
8
  import {createEnvironmentId} from '@atlaspack/rust';
@@ -19,6 +20,7 @@ const DEFAULT_ENGINES = {
19
20
 
20
21
  type EnvironmentOpts = EnvironmentOptions & {
21
22
  loc?: InternalSourceLocation | null | undefined;
23
+ customEnv?: EnvMap | null | undefined;
22
24
  };
23
25
 
24
26
  export function createEnvironment({
@@ -33,6 +35,7 @@ export function createEnvironment({
33
35
  sourceMap,
34
36
  unstableSingleFileOutput = false,
35
37
  loc,
38
+ customEnv,
36
39
  }: EnvironmentOpts = {
37
40
  /*::...null*/
38
41
  }): EnvironmentRef {
@@ -113,6 +116,7 @@ export function createEnvironment({
113
116
  sourceMap,
114
117
  unstableSingleFileOutput,
115
118
  loc,
119
+ customEnv,
116
120
  };
117
121
 
118
122
  res.id = getEnvironmentHash(res);
@@ -152,6 +156,7 @@ export function getEnvironmentHash(env: Environment): string {
152
156
  shouldOptimize: env.shouldOptimize,
153
157
  shouldScopeHoist: env.shouldScopeHoist,
154
158
  sourceMap: env.sourceMap,
159
+ customEnv: env.customEnv,
155
160
  } as const;
156
161
  const id = createEnvironmentId(data);
157
162
  identifierRegistry.addIdentifier('environment', id, data);
@@ -115,6 +115,12 @@ export const PACKAGE_DESCRIPTOR_SCHEMA: SchemaObject = {
115
115
  __unstable_singleFileOutput: {
116
116
  type: 'boolean',
117
117
  },
118
+ env: {
119
+ type: 'object',
120
+ additionalProperties: {
121
+ type: 'string',
122
+ },
123
+ },
118
124
  },
119
125
  additionalProperties: false,
120
126
  };
@@ -46,6 +46,7 @@ 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';
49
50
  import {optionsProxy} from './utils';
50
51
  import {createConfig} from './InternalConfig';
51
52
  import {
@@ -11,6 +11,7 @@ import type {
11
11
  SourceLocation,
12
12
  VersionMap,
13
13
  EnvironmentFeature,
14
+ EnvMap,
14
15
  } from '@atlaspack/types';
15
16
 
16
17
  export class Environment implements IEnvironment {
@@ -29,6 +30,7 @@ export class Environment implements IEnvironment {
29
30
  sourceMap: TargetSourceMapOptions | null | undefined;
30
31
  loc: SourceLocation | null | undefined;
31
32
  unstableSingleFileOutput: boolean;
33
+ customEnv: EnvMap | null | undefined;
32
34
 
33
35
  constructor(inner: NapiEnvironment) {
34
36
  // TODO
@@ -44,6 +46,7 @@ export class Environment implements IEnvironment {
44
46
  this.sourceMap = inner.sourceMap;
45
47
  this.loc = inner.loc;
46
48
  this.unstableSingleFileOutput = false;
49
+ this.customEnv = inner.customEnv;
47
50
  }
48
51
 
49
52
  isBrowser(): boolean {
@@ -282,6 +282,14 @@ export class AtlaspackWorker {
282
282
  '[V3] Unimplemented: New asset returned from Node transformer',
283
283
  );
284
284
 
285
+ let assetBuffer: Buffer | null = await mutableAsset.getBuffer();
286
+
287
+ // If the asset has no code, we set the buffer to null, which we can
288
+ // detect in Rust, to avoid passing back an empty buffer, which we can't.
289
+ if (assetBuffer.length === 0) {
290
+ assetBuffer = null;
291
+ }
292
+
285
293
  return [
286
294
  {
287
295
  id: mutableAsset.id,
@@ -301,7 +309,7 @@ export class AtlaspackWorker {
301
309
  type: mutableAsset.type,
302
310
  uniqueKey: mutableAsset.uniqueKey,
303
311
  },
304
- await mutableAsset.getBuffer(),
312
+ assetBuffer,
305
313
  // Only send back the map if it has changed
306
314
  mutableAsset.isMapDirty
307
315
  ? // @ts-expect-error TS2533
@@ -9,6 +9,7 @@ import type {
9
9
  SourceLocation,
10
10
  SourceType,
11
11
  TargetSourceMapOptions,
12
+ EnvMap,
12
13
  } from '@atlaspack/types';
13
14
  import type {
14
15
  Environment as InternalEnvironment,
@@ -232,6 +233,10 @@ export default class Environment implements IEnvironment {
232
233
  return this.#environment.unstableSingleFileOutput;
233
234
  }
234
235
 
236
+ get customEnv(): EnvMap | null | undefined {
237
+ return this.#environment.customEnv;
238
+ }
239
+
235
240
  [inspect](): string {
236
241
  return `Env(${this.#environment.context})`;
237
242
  }
@@ -96,8 +96,11 @@ export function getAssetGraph(serializedGraph: any): {
96
96
  let jsSymbol = {
97
97
  local: symbol.local ?? undefined,
98
98
  loc: symbol.loc ?? undefined,
99
- meta: undefined,
100
99
  isWeak: symbol.isWeak,
100
+ meta: {
101
+ isEsm: symbol.isEsmExport,
102
+ isStaticBindingSafe: symbol.isStaticBindingSafe,
103
+ },
101
104
  };
102
105
 
103
106
  if (symbol.exported) {
@@ -105,13 +108,6 @@ export function getAssetGraph(serializedGraph: any): {
105
108
  jsSymbol.exported = symbol.exported;
106
109
  }
107
110
 
108
- if (symbol.isEsmExport) {
109
- // @ts-expect-error TS2322
110
- jsSymbol.meta = {
111
- isEsm: true,
112
- };
113
- }
114
-
115
111
  return [exported, jsSymbol];
116
112
  }
117
113
 
@@ -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
- // @ts-expect-error TS7031
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
  ),
@@ -314,6 +354,7 @@ export class TargetResolver {
314
354
  ),
315
355
  unstableSingleFileOutput:
316
356
  descriptor.__unstable_singleFileOutput,
357
+ customEnv: descriptor.env,
317
358
  }),
318
359
  };
319
360
 
@@ -329,8 +370,21 @@ export class TargetResolver {
329
370
  })
330
371
  .filter(
331
372
  (target) =>
373
+ (getFeatureFlag('allowExplicitTargetEntries') &&
374
+ this.options.entries.length !== 0) ||
332
375
  !skipTarget(target.name, exclusiveTarget, target.source),
333
376
  );
377
+
378
+ // Apply allowExplicitTargetEntries filtering logic
379
+ if (getFeatureFlag('allowExplicitTargetEntries')) {
380
+ // Check if ALL targets have sources - only apply new behavior if they do
381
+ const allTargetsHaveSources = targets.every((t) => t.source);
382
+
383
+ if (!allTargetsHaveSources) {
384
+ // If not all targets have sources, fall back to old behavior (skip targets with sources)
385
+ targets = targets.filter((target) => !target.source);
386
+ }
387
+ }
334
388
  }
335
389
 
336
390
  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 type {PackagedBundleInfo} from '../types';
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
- // @ts-expect-error TS7031
70
- async function run({input, api, farm, options}) {
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, any> = {};
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 !== 'inline' &&
93
- bundle.bundleBehavior !== 'inline-isolated',
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 ?? []) {
@@ -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;
package/src/types.ts CHANGED
@@ -84,6 +84,7 @@ export type Environment = {
84
84
  sourceMap: TargetSourceMapOptions | null | undefined;
85
85
  loc: InternalSourceLocation | null | undefined;
86
86
  unstableSingleFileOutput: boolean;
87
+ customEnv: EnvMap | null | undefined;
87
88
  };
88
89
 
89
90
  export type InternalSourceLocation = {
@@ -9,6 +9,7 @@ describe('Environment', () => {
9
9
  assert.deepEqual(fromEnvironmentId(createEnvironment()), {
10
10
  id: 'd821e85f6b50315e',
11
11
  context: 'browser',
12
+ customEnv: undefined,
12
13
  engines: {
13
14
  browsers: ['> 0.25%'],
14
15
  },
@@ -17,8 +18,8 @@ describe('Environment', () => {
17
18
  isLibrary: false,
18
19
  shouldOptimize: false,
19
20
  shouldScopeHoist: false,
20
- sourceMap: null,
21
- loc: null,
21
+ sourceMap: undefined,
22
+ loc: undefined,
22
23
  sourceType: 'module',
23
24
  unstableSingleFileOutput: false,
24
25
  });
@@ -30,6 +31,7 @@ describe('Environment', () => {
30
31
  {
31
32
  id: '2320af923a717577',
32
33
  context: 'node',
34
+ customEnv: undefined,
33
35
  engines: {
34
36
  node: '>= 10.0.0',
35
37
  },
@@ -54,6 +56,7 @@ describe('Environment', () => {
54
56
  {
55
57
  id: '75603271034eff15',
56
58
  context: 'browser',
59
+ customEnv: undefined,
57
60
  engines: {
58
61
  browsers: ['last 1 version'],
59
62
  },
@@ -62,8 +65,8 @@ describe('Environment', () => {
62
65
  isLibrary: false,
63
66
  shouldOptimize: false,
64
67
  shouldScopeHoist: false,
65
- sourceMap: null,
66
- loc: null,
68
+ sourceMap: undefined,
69
+ loc: undefined,
67
70
  sourceType: 'module',
68
71
  unstableSingleFileOutput: false,
69
72
  },
@@ -74,6 +77,7 @@ describe('Environment', () => {
74
77
  assert.deepEqual(fromEnvironmentId(createEnvironment({context: 'node'})), {
75
78
  id: 'e45cc12216f7857d',
76
79
  context: 'node',
80
+ customEnv: undefined,
77
81
  engines: {
78
82
  node: '>= 8.0.0',
79
83
  },
@@ -95,6 +99,7 @@ describe('Environment', () => {
95
99
  {
96
100
  id: 'd821e85f6b50315e',
97
101
  context: 'browser',
102
+ customEnv: undefined,
98
103
  engines: {
99
104
  browsers: ['> 0.25%'],
100
105
  },
@@ -103,8 +108,8 @@ describe('Environment', () => {
103
108
  isLibrary: false,
104
109
  shouldOptimize: false,
105
110
  shouldScopeHoist: false,
106
- sourceMap: null,
107
- loc: null,
111
+ sourceMap: undefined,
112
+ loc: undefined,
108
113
  sourceType: 'module',
109
114
  unstableSingleFileOutput: false,
110
115
  },
@@ -117,6 +122,7 @@ describe('Environment', () => {
117
122
  {
118
123
  id: '9917be65326c5de9',
119
124
  context: 'tesseract',
125
+ customEnv: undefined,
120
126
  engines: {
121
127
  browsers: ['> 0.25%'],
122
128
  },
@@ -125,8 +131,8 @@ describe('Environment', () => {
125
131
  isLibrary: false,
126
132
  shouldOptimize: false,
127
133
  shouldScopeHoist: false,
128
- sourceMap: null,
129
- loc: null,
134
+ sourceMap: undefined,
135
+ loc: undefined,
130
136
  sourceType: 'module',
131
137
  unstableSingleFileOutput: false,
132
138
  },