@atlaspack/core 2.12.1-canary.3354
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 +201 -0
- package/index.d.ts +22 -0
- package/lib/AssetGraph.js +518 -0
- package/lib/Atlaspack.js +587 -0
- package/lib/AtlaspackConfig.js +298 -0
- package/lib/AtlaspackConfig.schema.js +125 -0
- package/lib/BundleGraph.js +1445 -0
- package/lib/CommittedAsset.js +133 -0
- package/lib/Dependency.js +88 -0
- package/lib/Environment.js +128 -0
- package/lib/InternalConfig.js +48 -0
- package/lib/PackagerRunner.js +519 -0
- package/lib/ReporterRunner.js +151 -0
- package/lib/RequestTracker.js +1089 -0
- package/lib/SymbolPropagation.js +625 -0
- package/lib/TargetDescriptor.schema.js +115 -0
- package/lib/Transformation.js +536 -0
- package/lib/UncommittedAsset.js +342 -0
- package/lib/Validation.js +215 -0
- package/lib/applyRuntimes.js +279 -0
- package/lib/assetUtils.js +189 -0
- package/lib/atlaspack-v3/AtlaspackV3.js +74 -0
- package/lib/atlaspack-v3/fs.js +30 -0
- package/lib/atlaspack-v3/index.js +19 -0
- package/lib/atlaspack-v3/jsCallable.js +15 -0
- package/lib/atlaspack-v3/plugins/Resolver.js +12 -0
- package/lib/atlaspack-v3/plugins/index.js +16 -0
- package/lib/atlaspack-v3/worker/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +30 -0
- package/lib/buildCache.js +18 -0
- package/lib/constants.js +21 -0
- package/lib/dumpGraphToGraphViz.js +206 -0
- package/lib/index.js +106 -0
- package/lib/loadAtlaspackPlugin.js +148 -0
- package/lib/loadDotEnv.js +54 -0
- package/lib/projectPath.js +86 -0
- package/lib/public/Asset.js +259 -0
- package/lib/public/Bundle.js +231 -0
- package/lib/public/BundleGraph.js +193 -0
- package/lib/public/BundleGroup.js +44 -0
- package/lib/public/Config.js +202 -0
- package/lib/public/Dependency.js +131 -0
- package/lib/public/Environment.js +244 -0
- package/lib/public/MutableBundleGraph.js +184 -0
- package/lib/public/PluginOptions.js +71 -0
- package/lib/public/Symbols.js +247 -0
- package/lib/public/Target.js +64 -0
- package/lib/registerCoreWithSerializer.js +45 -0
- package/lib/requests/AssetGraphRequest.js +427 -0
- package/lib/requests/AssetGraphRequestRust.js +187 -0
- package/lib/requests/AssetRequest.js +137 -0
- package/lib/requests/AtlaspackBuildRequest.js +78 -0
- package/lib/requests/AtlaspackConfigRequest.js +473 -0
- package/lib/requests/BundleGraphRequest.js +419 -0
- package/lib/requests/ConfigRequest.js +198 -0
- package/lib/requests/DevDepRequest.js +166 -0
- package/lib/requests/EntryRequest.js +295 -0
- package/lib/requests/PackageRequest.js +88 -0
- package/lib/requests/PathRequest.js +349 -0
- package/lib/requests/TargetRequest.js +1177 -0
- package/lib/requests/ValidationRequest.js +66 -0
- package/lib/requests/WriteBundleRequest.js +252 -0
- package/lib/requests/WriteBundlesRequest.js +153 -0
- package/lib/resolveOptions.js +234 -0
- package/lib/serializer.js +216 -0
- package/lib/serializerCore.browser.js +29 -0
- package/lib/serializerCore.js +16 -0
- package/lib/summarizeRequest.js +55 -0
- package/lib/types.js +35 -0
- package/lib/utils.js +160 -0
- package/lib/worker.js +170 -0
- package/package.json +59 -0
- package/src/AssetGraph.js +646 -0
- package/src/Atlaspack.js +632 -0
- package/src/AtlaspackConfig.js +490 -0
- package/src/AtlaspackConfig.schema.js +141 -0
- package/src/BundleGraph.js +2193 -0
- package/src/CommittedAsset.js +143 -0
- package/src/Dependency.js +142 -0
- package/src/Environment.js +151 -0
- package/src/InternalConfig.js +72 -0
- package/src/PackagerRunner.js +790 -0
- package/src/ReporterRunner.js +158 -0
- package/src/RequestTracker.js +1697 -0
- package/src/SymbolPropagation.js +794 -0
- package/src/TargetDescriptor.schema.js +136 -0
- package/src/Transformation.js +752 -0
- package/src/UncommittedAsset.js +426 -0
- package/src/Validation.js +223 -0
- package/src/applyRuntimes.js +341 -0
- package/src/assetUtils.js +254 -0
- package/src/atlaspack-v3/AtlaspackV3.js +73 -0
- package/src/atlaspack-v3/fs.js +36 -0
- package/src/atlaspack-v3/index.js +5 -0
- package/src/atlaspack-v3/jsCallable.js +13 -0
- package/src/atlaspack-v3/plugins/Resolver.js +9 -0
- package/src/atlaspack-v3/plugins/index.js +3 -0
- package/src/atlaspack-v3/worker/index.js +8 -0
- package/src/atlaspack-v3/worker/worker.js +14 -0
- package/src/buildCache.js +15 -0
- package/src/constants.js +22 -0
- package/src/dumpGraphToGraphViz.js +244 -0
- package/src/index.js +22 -0
- package/src/loadAtlaspackPlugin.js +239 -0
- package/src/loadDotEnv.js +56 -0
- package/src/projectPath.js +87 -0
- package/src/public/Asset.js +359 -0
- package/src/public/Bundle.js +337 -0
- package/src/public/BundleGraph.js +335 -0
- package/src/public/BundleGroup.js +55 -0
- package/src/public/Config.js +261 -0
- package/src/public/Dependency.js +176 -0
- package/src/public/Environment.js +316 -0
- package/src/public/MutableBundleGraph.js +320 -0
- package/src/public/PluginOptions.js +99 -0
- package/src/public/Symbols.js +315 -0
- package/src/public/Target.js +71 -0
- package/src/registerCoreWithSerializer.js +34 -0
- package/src/requests/AssetGraphRequest.js +577 -0
- package/src/requests/AssetGraphRequestRust.js +222 -0
- package/src/requests/AssetRequest.js +179 -0
- package/src/requests/AtlaspackBuildRequest.js +109 -0
- package/src/requests/AtlaspackConfigRequest.js +709 -0
- package/src/requests/BundleGraphRequest.js +547 -0
- package/src/requests/ConfigRequest.js +287 -0
- package/src/requests/DevDepRequest.js +246 -0
- package/src/requests/EntryRequest.js +385 -0
- package/src/requests/PackageRequest.js +105 -0
- package/src/requests/PathRequest.js +454 -0
- package/src/requests/TargetRequest.js +1632 -0
- package/src/requests/ValidationRequest.js +79 -0
- package/src/requests/WriteBundleRequest.js +362 -0
- package/src/requests/WriteBundlesRequest.js +209 -0
- package/src/resolveOptions.js +278 -0
- package/src/serializer.js +255 -0
- package/src/serializerCore.browser.js +8 -0
- package/src/serializerCore.js +5 -0
- package/src/summarizeRequest.js +47 -0
- package/src/types.js +581 -0
- package/src/utils.js +211 -0
- package/src/worker.js +189 -0
- package/test/AssetGraph.test.js +679 -0
- package/test/Atlaspack.test.js +142 -0
- package/test/AtlaspackConfig.test.js +405 -0
- package/test/AtlaspackConfigRequest.test.js +993 -0
- package/test/BundleGraph.test.js +121 -0
- package/test/EntryRequest.test.js +215 -0
- package/test/Environment.test.js +99 -0
- package/test/InternalAsset.test.js +76 -0
- package/test/PackagerRunner.test.js +27 -0
- package/test/PublicAsset.test.js +40 -0
- package/test/PublicBundle.test.js +68 -0
- package/test/PublicDependency.test.js +22 -0
- package/test/PublicEnvironment.test.js +27 -0
- package/test/PublicMutableBundleGraph.test.js +192 -0
- package/test/RequestTracker.test.js +448 -0
- package/test/SymbolPropagation.test.js +716 -0
- package/test/TargetRequest.test.js +1715 -0
- package/test/fixtures/application-targets/package.json +3 -0
- package/test/fixtures/atlaspack/index.js +1 -0
- package/test/fixtures/atlaspack/other.js +3 -0
- package/test/fixtures/atlaspack/package.json +1 -0
- package/test/fixtures/atlaspack/yarn.lock +0 -0
- package/test/fixtures/bundle.js +10 -0
- package/test/fixtures/common-targets/package.json +24 -0
- package/test/fixtures/common-targets-ignore/package.json +13 -0
- package/test/fixtures/config/.atlaspackrc +6 -0
- package/test/fixtures/config/subfolder/.atlaspackrc +6 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-json5 +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-multiple +3 -0
- package/test/fixtures/config-extends-not-found/.atlaspackrc-node-modules +3 -0
- package/test/fixtures/config-malformed/.atlaspackrc +3 -0
- package/test/fixtures/config-node-pipeline/.atlaspackrc +6 -0
- package/test/fixtures/config-plugin-not-found/.atlaspackrc +6 -0
- package/test/fixtures/context/package.json +8 -0
- package/test/fixtures/custom-format-infer-ext/package.json +6 -0
- package/test/fixtures/custom-format-infer-type/package.json +7 -0
- package/test/fixtures/custom-format-mismatch/package.json +8 -0
- package/test/fixtures/custom-targets/package.json +20 -0
- package/test/fixtures/custom-targets-distdir/package.json +11 -0
- package/test/fixtures/duplicate-targets/package.json +4 -0
- package/test/fixtures/glob-like/[entry].js +0 -0
- package/test/fixtures/invalid-distpath/package.json +11 -0
- package/test/fixtures/invalid-engines/package.json +12 -0
- package/test/fixtures/invalid-source-missing/package.json +5 -0
- package/test/fixtures/invalid-source-not-file/package.json +5 -0
- package/test/fixtures/invalid-source-not-file/src/index.js +1 -0
- package/test/fixtures/invalid-target-source-missing/package.json +9 -0
- package/test/fixtures/invalid-target-source-not-file/package.json +9 -0
- package/test/fixtures/invalid-target-source-not-file/src/index.js +1 -0
- package/test/fixtures/invalid-targets/package.json +19 -0
- package/test/fixtures/library-custom-scopehoist/package.json +9 -0
- package/test/fixtures/library-scopehoist/package.json +8 -0
- package/test/fixtures/local-plugin-config-pkg/.atlaspackrc +3 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/index.json +8 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/local-plugin.js +7 -0
- package/test/fixtures/local-plugin-config-pkg/node_modules/atlaspack-config-local/package.json +7 -0
- package/test/fixtures/main-format-mismatch/package.json +8 -0
- package/test/fixtures/main-global/package.json +8 -0
- package/test/fixtures/main-mjs/package.json +8 -0
- package/test/fixtures/module-a.js +1 -0
- package/test/fixtures/module-b.js +1 -0
- package/test/fixtures/plugins/local-plugin.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/index.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-bad-engines/package.json +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/index.js +7 -0
- package/test/fixtures/plugins/node_modules/atlaspack-transformer-no-engines/package.json +4 -0
- package/test/fixtures/targets-default-distdir-none/package.json +5 -0
- package/test/fixtures/targets-default-distdir-one/package.json +8 -0
- package/test/fixtures/targets-default-distdir-two/package.json +18 -0
- package/test/requests/ConfigRequest.test.js +254 -0
- package/test/serializer.test.js +302 -0
- package/test/test-utils.js +80 -0
- package/test/utils.test.js +43 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
3
|
+
import type {ReporterEvent, Reporter} from '@atlaspack/types';
|
|
4
|
+
import type {WorkerApi} from '@atlaspack/workers';
|
|
5
|
+
import type {Bundle as InternalBundle, AtlaspackOptions} from './types';
|
|
6
|
+
import type {LoadedPlugin} from './AtlaspackConfig';
|
|
7
|
+
|
|
8
|
+
import invariant from 'assert';
|
|
9
|
+
import {
|
|
10
|
+
bundleToInternalBundle,
|
|
11
|
+
bundleToInternalBundleGraph,
|
|
12
|
+
NamedBundle,
|
|
13
|
+
} from './public/Bundle';
|
|
14
|
+
import WorkerFarm, {bus} from '@atlaspack/workers';
|
|
15
|
+
import logger, {
|
|
16
|
+
patchConsole,
|
|
17
|
+
unpatchConsole,
|
|
18
|
+
PluginLogger,
|
|
19
|
+
INTERNAL_ORIGINAL_CONSOLE,
|
|
20
|
+
} from '@atlaspack/logger';
|
|
21
|
+
import PluginOptions from './public/PluginOptions';
|
|
22
|
+
import BundleGraph from './BundleGraph';
|
|
23
|
+
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
24
|
+
import {anyToDiagnostic} from '@atlaspack/diagnostic';
|
|
25
|
+
|
|
26
|
+
type Opts = {|
|
|
27
|
+
options: AtlaspackOptions,
|
|
28
|
+
reporters: Array<LoadedPlugin<Reporter>>,
|
|
29
|
+
workerFarm: WorkerFarm,
|
|
30
|
+
|};
|
|
31
|
+
|
|
32
|
+
const instances: Set<ReporterRunner> = new Set();
|
|
33
|
+
|
|
34
|
+
export default class ReporterRunner {
|
|
35
|
+
workerFarm: WorkerFarm;
|
|
36
|
+
errors: Error[];
|
|
37
|
+
options: AtlaspackOptions;
|
|
38
|
+
pluginOptions: PluginOptions;
|
|
39
|
+
reporters: Array<LoadedPlugin<Reporter>>;
|
|
40
|
+
|
|
41
|
+
constructor(opts: Opts) {
|
|
42
|
+
this.errors = [];
|
|
43
|
+
this.options = opts.options;
|
|
44
|
+
this.reporters = opts.reporters;
|
|
45
|
+
this.workerFarm = opts.workerFarm;
|
|
46
|
+
this.pluginOptions = new PluginOptions(this.options);
|
|
47
|
+
|
|
48
|
+
logger.onLog(event => this.report(event));
|
|
49
|
+
tracer.onTrace(event => this.report(event));
|
|
50
|
+
|
|
51
|
+
bus.on('reporterEvent', this.eventHandler);
|
|
52
|
+
instances.add(this);
|
|
53
|
+
|
|
54
|
+
if (this.options.shouldPatchConsole) {
|
|
55
|
+
patchConsole();
|
|
56
|
+
} else {
|
|
57
|
+
unpatchConsole();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
eventHandler: ReporterEvent => void = (event): void => {
|
|
62
|
+
if (
|
|
63
|
+
event.type === 'buildProgress' &&
|
|
64
|
+
(event.phase === 'optimizing' || event.phase === 'packaging') &&
|
|
65
|
+
!(event.bundle instanceof NamedBundle)
|
|
66
|
+
) {
|
|
67
|
+
// $FlowFixMe[prop-missing]
|
|
68
|
+
let bundleGraphRef = event.bundleGraphRef;
|
|
69
|
+
// $FlowFixMe[incompatible-exact]
|
|
70
|
+
let bundle: InternalBundle = event.bundle;
|
|
71
|
+
// Convert any internal bundles back to their public equivalents as reporting
|
|
72
|
+
// is public api
|
|
73
|
+
let bundleGraph = this.workerFarm.workerApi.getSharedReference(
|
|
74
|
+
// $FlowFixMe
|
|
75
|
+
bundleGraphRef,
|
|
76
|
+
);
|
|
77
|
+
invariant(bundleGraph instanceof BundleGraph);
|
|
78
|
+
// $FlowFixMe[incompatible-call]
|
|
79
|
+
this.report({
|
|
80
|
+
...event,
|
|
81
|
+
bundle: NamedBundle.get(bundle, bundleGraph, this.options),
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.report(event);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
async report(unsanitisedEvent: ReporterEvent) {
|
|
90
|
+
let event: ReporterEvent = unsanitisedEvent;
|
|
91
|
+
if (event.diagnostics) {
|
|
92
|
+
// Sanitise input before passing to reporters
|
|
93
|
+
// $FlowFixMe too complex to narrow down by type
|
|
94
|
+
event = {
|
|
95
|
+
...event,
|
|
96
|
+
diagnostics: anyToDiagnostic(event.diagnostics),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
for (let reporter of this.reporters) {
|
|
100
|
+
let measurement;
|
|
101
|
+
try {
|
|
102
|
+
// To avoid an infinite loop we don't measure trace events, as they'll
|
|
103
|
+
// result in another trace!
|
|
104
|
+
if (event.type !== 'trace') {
|
|
105
|
+
measurement = tracer.createMeasurement(reporter.name, 'reporter');
|
|
106
|
+
}
|
|
107
|
+
await reporter.plugin.report({
|
|
108
|
+
// $FlowFixMe
|
|
109
|
+
event,
|
|
110
|
+
options: this.pluginOptions,
|
|
111
|
+
logger: new PluginLogger({origin: reporter.name}),
|
|
112
|
+
tracer: new PluginTracer({
|
|
113
|
+
origin: reporter.name,
|
|
114
|
+
category: 'reporter',
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
} catch (reportError) {
|
|
118
|
+
if (event.type !== 'buildSuccess') {
|
|
119
|
+
// This will be captured by consumers
|
|
120
|
+
INTERNAL_ORIGINAL_CONSOLE.error(reportError);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
this.errors.push(reportError);
|
|
124
|
+
} finally {
|
|
125
|
+
measurement && measurement.end();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
dispose() {
|
|
131
|
+
bus.off('reporterEvent', this.eventHandler);
|
|
132
|
+
instances.delete(this);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function reportWorker(workerApi: WorkerApi, event: ReporterEvent) {
|
|
137
|
+
if (
|
|
138
|
+
event.type === 'buildProgress' &&
|
|
139
|
+
(event.phase === 'optimizing' || event.phase === 'packaging')
|
|
140
|
+
) {
|
|
141
|
+
// Convert any public api bundles to their internal equivalents for
|
|
142
|
+
// easy serialization
|
|
143
|
+
bus.emit('reporterEvent', {
|
|
144
|
+
...event,
|
|
145
|
+
bundle: bundleToInternalBundle(event.bundle),
|
|
146
|
+
bundleGraphRef: workerApi.resolveSharedReference(
|
|
147
|
+
bundleToInternalBundleGraph(event.bundle),
|
|
148
|
+
),
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
bus.emit('reporterEvent', event);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function report(event: ReporterEvent): Promise<void> {
|
|
157
|
+
await Promise.all([...instances].map(instance => instance.report(event)));
|
|
158
|
+
}
|