@atlaspack/core 2.25.2-dev-native-compiled-test-712d92d32.0 → 2.26.1-dev-yarn-8750a7d2e.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 +32 -0
- package/dist/CommittedAsset.js +0 -3
- package/dist/UncommittedAsset.js +0 -9
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +0 -4
- package/dist/loadDotEnv.js +1 -0
- package/dist/public/Asset.js +0 -6
- package/dist/requests/AssetGraphRequestRust.js +1 -2
- package/dist/requests/AtlaspackConfigRequest.js +21 -7
- package/dist/requests/BundleGraphRequest.js +5 -1
- package/dist/requests/TargetRequest.js +1 -0
- package/dist/requests/asset-graph-diff.js +6 -4
- package/lib/CommittedAsset.js +0 -3
- package/lib/UncommittedAsset.js +0 -9
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +0 -4
- package/lib/loadDotEnv.js +2 -0
- package/lib/public/Asset.js +0 -6
- package/lib/requests/AssetGraphRequestRust.js +4 -2
- package/lib/requests/AtlaspackConfigRequest.js +27 -7
- package/lib/requests/BundleGraphRequest.js +5 -1
- package/lib/requests/TargetRequest.js +2 -1
- package/lib/requests/asset-graph-diff.js +4 -4
- package/lib/types/CommittedAsset.d.ts +0 -1
- package/lib/types/UncommittedAsset.d.ts +0 -2
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +0 -2
- package/lib/types/public/Asset.d.ts +0 -2
- package/lib/types/types.d.ts +0 -1
- package/package.json +18 -18
- package/src/CommittedAsset.ts +0 -4
- package/src/UncommittedAsset.ts +0 -11
- package/src/atlaspack-v3/worker/compat/mutable-asset.ts +0 -6
- package/src/atlaspack-v3/worker/worker.ts +1 -1
- package/src/loadDotEnv.ts +1 -0
- package/src/public/Asset.ts +0 -8
- package/src/requests/AssetGraphRequestRust.ts +1 -2
- package/src/requests/AtlaspackConfigRequest.ts +24 -7
- package/src/requests/BundleGraphRequest.ts +5 -1
- package/src/requests/TargetRequest.ts +1 -0
- package/src/requests/asset-graph-diff.ts +11 -7
- package/src/types.ts +0 -1
- package/test/AtlaspackConfigRequest.test.ts +72 -0
- package/test/TargetRequest.test.ts +12 -0
- package/test/fixtures/config-with-reporters/.parcelrc +7 -0
- package/test/fixtures/custom-targets/package.json +6 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
PureAtlaspackConfigPipeline,
|
|
13
13
|
AtlaspackOptions,
|
|
14
14
|
ProcessedAtlaspackConfig,
|
|
15
|
+
AtlaspackPluginNode,
|
|
15
16
|
} from '../types';
|
|
16
17
|
|
|
17
18
|
import {createBuildCache} from '@atlaspack/build-cache';
|
|
@@ -197,13 +198,29 @@ export async function resolveAtlaspackConfig(
|
|
|
197
198
|
await parseAndProcessConfig(configPath, contents, options);
|
|
198
199
|
|
|
199
200
|
if (options.additionalReporters.length > 0) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
if (options.featureFlags.deduplicateReporters) {
|
|
202
|
+
const reporterMap = new Map<PackageName, AtlaspackPluginNode>();
|
|
203
|
+
|
|
204
|
+
options.additionalReporters.forEach(({packageName, resolveFrom}) => {
|
|
205
|
+
reporterMap.set(packageName, {packageName, resolveFrom});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
config.reporters?.forEach((reporter) => {
|
|
209
|
+
if (!reporterMap.has(reporter.packageName)) {
|
|
210
|
+
reporterMap.set(reporter.packageName, reporter);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
config.reporters = Array.from(reporterMap.values());
|
|
215
|
+
} else {
|
|
216
|
+
config.reporters = [
|
|
217
|
+
...options.additionalReporters.map(({packageName, resolveFrom}) => ({
|
|
218
|
+
packageName,
|
|
219
|
+
resolveFrom,
|
|
220
|
+
})),
|
|
221
|
+
...(config.reporters ?? []),
|
|
222
|
+
];
|
|
223
|
+
}
|
|
207
224
|
}
|
|
208
225
|
|
|
209
226
|
return {config, extendedFiles, usedDefault};
|
|
@@ -192,7 +192,11 @@ export default function createBundleGraphRequest(
|
|
|
192
192
|
// force: true,
|
|
193
193
|
// },
|
|
194
194
|
// );
|
|
195
|
-
// require('./asset-graph-diff.
|
|
195
|
+
// require('./asset-graph-diff.ts')(
|
|
196
|
+
// jsAssetGraph,
|
|
197
|
+
// assetGraph,
|
|
198
|
+
// options.projectRoot,
|
|
199
|
+
// );
|
|
196
200
|
// }
|
|
197
201
|
|
|
198
202
|
measurement && measurement.end();
|
|
@@ -1151,6 +1151,7 @@ export class TargetResolver {
|
|
|
1151
1151
|
shouldScopeHoist:
|
|
1152
1152
|
shouldScopeHoist && descriptor.scopeHoist !== false,
|
|
1153
1153
|
sourceMap: normalizeSourceMap(this.options, descriptor.sourceMap),
|
|
1154
|
+
customEnv: descriptor.env,
|
|
1154
1155
|
}),
|
|
1155
1156
|
loc: toInternalSourceLocation(this.options.projectRoot, loc),
|
|
1156
1157
|
});
|
|
@@ -4,7 +4,7 @@ import deepClone from 'rfdc/default';
|
|
|
4
4
|
import {diff} from 'jest-diff';
|
|
5
5
|
import AssetGraph from '../AssetGraph';
|
|
6
6
|
import type {AssetGraphNode} from '../types';
|
|
7
|
-
import {
|
|
7
|
+
import {toProjectPath} from '../projectPath';
|
|
8
8
|
|
|
9
9
|
function filterNode(node: any) {
|
|
10
10
|
let clone = deepClone(node);
|
|
@@ -71,7 +71,11 @@ function compactDeep(
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function assetGraphDiff(
|
|
74
|
+
function assetGraphDiff(
|
|
75
|
+
jsAssetGraph: AssetGraph,
|
|
76
|
+
rustAssetGraph: AssetGraph,
|
|
77
|
+
projectRoot: string,
|
|
78
|
+
) {
|
|
75
79
|
const getNodes = (graph: any) => {
|
|
76
80
|
let nodes: Record<string, any> = {};
|
|
77
81
|
|
|
@@ -81,12 +85,12 @@ function assetGraphDiff(jsAssetGraph: AssetGraph, rustAssetGraph: AssetGraph) {
|
|
|
81
85
|
if (!node) return;
|
|
82
86
|
|
|
83
87
|
if (node.type === 'dependency') {
|
|
84
|
-
let sourcePath = node.value.sourcePath
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
] = filterNode(node);
|
|
88
|
+
let sourcePath = node.value.sourcePath
|
|
89
|
+
? toProjectPath(projectRoot, node.value.sourcePath)
|
|
90
|
+
: toProjectPath(projectRoot, 'entry');
|
|
91
|
+
nodes[`dep:${sourcePath}:${node.value.specifier}`] = filterNode(node);
|
|
88
92
|
} else if (node.type === 'asset') {
|
|
89
|
-
nodes[`asset:${
|
|
93
|
+
nodes[`asset:${toProjectPath(projectRoot, node.value.filePath)}`] =
|
|
90
94
|
filterNode(node);
|
|
91
95
|
}
|
|
92
96
|
});
|
package/src/types.ts
CHANGED
|
@@ -801,6 +801,78 @@ describe('AtlaspackConfigRequest', () => {
|
|
|
801
801
|
});
|
|
802
802
|
});
|
|
803
803
|
|
|
804
|
+
describe('additionalReporters', () => {
|
|
805
|
+
it('should deduplicate reporters by packageName', async () => {
|
|
806
|
+
const configPath = path.join(
|
|
807
|
+
__dirname,
|
|
808
|
+
'fixtures',
|
|
809
|
+
'config-with-reporters',
|
|
810
|
+
'.parcelrc',
|
|
811
|
+
);
|
|
812
|
+
|
|
813
|
+
const options = {
|
|
814
|
+
...DEFAULT_OPTIONS,
|
|
815
|
+
projectRoot: path.join(__dirname, 'fixtures', 'config-with-reporters'),
|
|
816
|
+
config: configPath,
|
|
817
|
+
additionalReporters: [
|
|
818
|
+
{
|
|
819
|
+
packageName: '@atlaspack/reporter-cli',
|
|
820
|
+
resolveFrom: '/custom/path',
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
packageName: '@atlaspack/reporter-dev-server',
|
|
824
|
+
resolveFrom: '/another/path',
|
|
825
|
+
},
|
|
826
|
+
],
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
const result = await resolveAtlaspackConfig(options);
|
|
830
|
+
assert(result !== null && result !== undefined);
|
|
831
|
+
|
|
832
|
+
const {config} = result;
|
|
833
|
+
|
|
834
|
+
// With feature flag enabled, should have 3 reporters (with deduplication)
|
|
835
|
+
assert(
|
|
836
|
+
config.reporters && config.reporters.length === 3,
|
|
837
|
+
'Should have exactly 3 reporters with deduplication',
|
|
838
|
+
);
|
|
839
|
+
|
|
840
|
+
const cliReporter = config.reporters?.find(
|
|
841
|
+
(r) => r.packageName === '@atlaspack/reporter-cli',
|
|
842
|
+
);
|
|
843
|
+
const bundleAnalyzerReporter = config.reporters?.find(
|
|
844
|
+
(r) => r.packageName === '@atlaspack/reporter-bundle-analyzer',
|
|
845
|
+
);
|
|
846
|
+
const devServerReporter = config.reporters?.find(
|
|
847
|
+
(r) => r.packageName === '@atlaspack/reporter-dev-server',
|
|
848
|
+
);
|
|
849
|
+
|
|
850
|
+
assert(cliReporter, 'CLI reporter should exist');
|
|
851
|
+
assert.equal(
|
|
852
|
+
cliReporter.resolveFrom,
|
|
853
|
+
'/custom/path',
|
|
854
|
+
'CLI reporter should use additional reporter resolveFrom',
|
|
855
|
+
);
|
|
856
|
+
|
|
857
|
+
assert(
|
|
858
|
+
bundleAnalyzerReporter,
|
|
859
|
+
'Bundle analyzer reporter should exist from original config',
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
assert(devServerReporter, 'Dev server reporter should exist');
|
|
863
|
+
assert.equal(devServerReporter.resolveFrom, '/another/path');
|
|
864
|
+
|
|
865
|
+
const cliReporters = config.reporters?.filter(
|
|
866
|
+
(r) => r.packageName === '@atlaspack/reporter-cli',
|
|
867
|
+
);
|
|
868
|
+
assert.equal(
|
|
869
|
+
cliReporters?.length,
|
|
870
|
+
1,
|
|
871
|
+
'Should have exactly one CLI reporter after deduplication',
|
|
872
|
+
);
|
|
873
|
+
});
|
|
874
|
+
});
|
|
875
|
+
|
|
804
876
|
describe('resolve', () => {
|
|
805
877
|
it('should return null if there is no .parcelrc file found', async () => {
|
|
806
878
|
let resolved = await resolveAtlaspackConfig(DEFAULT_OPTIONS);
|
|
@@ -382,6 +382,9 @@ describe('TargetResolver', () => {
|
|
|
382
382
|
loc: undefined,
|
|
383
383
|
sourceType: 'module',
|
|
384
384
|
unstableSingleFileOutput: false,
|
|
385
|
+
customEnv: {
|
|
386
|
+
useFlag: 'false',
|
|
387
|
+
},
|
|
385
388
|
}),
|
|
386
389
|
loc: {
|
|
387
390
|
filePath: relative(
|
|
@@ -416,6 +419,9 @@ describe('TargetResolver', () => {
|
|
|
416
419
|
loc: undefined,
|
|
417
420
|
sourceType: 'module',
|
|
418
421
|
unstableSingleFileOutput: false,
|
|
422
|
+
customEnv: {
|
|
423
|
+
useFlag: 'true',
|
|
424
|
+
},
|
|
419
425
|
}),
|
|
420
426
|
loc: {
|
|
421
427
|
filePath: relative(
|
|
@@ -501,6 +507,9 @@ describe('TargetResolver', () => {
|
|
|
501
507
|
loc: undefined,
|
|
502
508
|
sourceType: 'module',
|
|
503
509
|
unstableSingleFileOutput: false,
|
|
510
|
+
customEnv: {
|
|
511
|
+
useFlag: 'false',
|
|
512
|
+
},
|
|
504
513
|
}),
|
|
505
514
|
loc: {
|
|
506
515
|
filePath: relative(
|
|
@@ -535,6 +544,9 @@ describe('TargetResolver', () => {
|
|
|
535
544
|
loc: undefined,
|
|
536
545
|
sourceType: 'module',
|
|
537
546
|
unstableSingleFileOutput: false,
|
|
547
|
+
customEnv: {
|
|
548
|
+
useFlag: 'true',
|
|
549
|
+
},
|
|
538
550
|
}),
|
|
539
551
|
loc: {
|
|
540
552
|
filePath: relative(
|