@atlaspack/core 2.16.2-canary.183 → 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.
@@ -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) {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-canary.183+8604d2a49",
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.251+8604d2a49",
27
- "@atlaspack/cache": "3.1.1-canary.183+8604d2a49",
28
- "@atlaspack/diagnostic": "2.14.1-canary.251+8604d2a49",
29
- "@atlaspack/events": "2.14.1-canary.251+8604d2a49",
30
- "@atlaspack/feature-flags": "2.14.1-canary.251+8604d2a49",
31
- "@atlaspack/fs": "2.14.5-canary.183+8604d2a49",
32
- "@atlaspack/graph": "3.4.1-canary.251+8604d2a49",
33
- "@atlaspack/logger": "2.14.5-canary.183+8604d2a49",
34
- "@atlaspack/package-manager": "2.14.5-canary.183+8604d2a49",
35
- "@atlaspack/plugin": "2.14.5-canary.183+8604d2a49",
36
- "@atlaspack/profiler": "2.14.1-canary.251+8604d2a49",
37
- "@atlaspack/rust": "3.2.1-canary.183+8604d2a49",
38
- "@atlaspack/types": "2.14.5-canary.183+8604d2a49",
39
- "@atlaspack/utils": "2.14.5-canary.183+8604d2a49",
40
- "@atlaspack/workers": "2.14.5-canary.183+8604d2a49",
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": "8604d2a49ace5e9194ec4f76e71f06b93610f6b4"
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
- // @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
  ),
@@ -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;
@@ -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;