@atlaspack/core 2.16.2-dev.72 → 2.16.2-dev.93
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 +61 -0
- package/lib/AssetGraph.js +9 -0
- package/lib/Atlaspack.js +5 -2
- package/lib/AtlaspackConfig.schema.js +7 -1
- package/lib/BundleGraph.js +3 -4
- package/lib/PackagerRunner.js +2 -5
- package/lib/RequestTracker.js +48 -39
- package/lib/Transformation.js +2 -2
- package/lib/atlaspack-v3/AtlaspackV3.js +1 -44
- package/lib/atlaspack-v3/NapiWorkerPool.js +1 -1
- package/lib/atlaspack-v3/worker/compat/environment.js +2 -2
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +6 -6
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +5 -5
- package/lib/atlaspack-v3/worker/index.js +6 -0
- package/lib/atlaspack-v3/worker/worker.js +4 -11
- package/lib/dumpGraphToGraphViz.js +1 -1
- package/lib/index.js +24 -4
- package/lib/loadAtlaspackPlugin.js +0 -15
- package/lib/public/Config.js +1 -8
- package/lib/public/PluginOptions.js +0 -3
- package/lib/requests/AtlaspackConfigRequest.js +29 -44
- package/lib/requests/DevDepRequest.js +22 -1
- package/lib/requests/PathRequest.js +10 -0
- package/lib/resolveOptions.js +4 -5
- package/lib/worker.js +26 -9
- package/package.json +17 -31
- package/src/AssetGraph.js +13 -0
- package/src/Atlaspack.js +7 -8
- package/src/BundleGraph.js +1 -8
- package/src/PackagerRunner.js +0 -5
- package/src/RequestTracker.js +8 -6
- package/src/atlaspack-v3/AtlaspackV3.js +2 -53
- package/src/atlaspack-v3/NapiWorkerPool.js +1 -5
- package/src/atlaspack-v3/worker/worker.js +4 -11
- package/src/index.js +5 -3
- package/src/loadAtlaspackPlugin.js +1 -23
- package/src/public/Config.js +1 -2
- package/src/public/PluginOptions.js +0 -4
- package/src/requests/AtlaspackConfigRequest.js +31 -77
- package/src/requests/DevDepRequest.js +44 -12
- package/src/requests/PathRequest.js +4 -0
- package/src/resolveOptions.js +0 -2
- package/src/types.js +1 -1
- package/src/worker.js +7 -8
- package/_empty.js +0 -0
- package/lib/atlaspack-v3/worker/napi-worker.js +0 -3
- package/lib/internal-plugins.js +0 -9
- package/lib/isSuperPackage.js +0 -23
- package/src/internal-plugins.js +0 -4
- package/src/isSuperPackage.js +0 -28
- /package/src/atlaspack-v3/worker/{napi-worker.js → index.js} +0 -0
|
@@ -8,14 +8,8 @@ import ThrowableDiagnostic, {
|
|
|
8
8
|
generateJSONCodeHighlights,
|
|
9
9
|
md,
|
|
10
10
|
} from '@atlaspack/diagnostic';
|
|
11
|
-
import {version as ATLASPACK_VERSION} from '../package.json';
|
|
12
|
-
import atlaspackInternalPlugins from './internal-plugins';
|
|
13
11
|
import {findAlternativeNodeModules} from '@atlaspack/utils';
|
|
14
|
-
import {
|
|
15
|
-
type ProjectPath,
|
|
16
|
-
toProjectPath,
|
|
17
|
-
toProjectPathUnsafe,
|
|
18
|
-
} from './projectPath';
|
|
12
|
+
import {type ProjectPath, toProjectPath} from './projectPath';
|
|
19
13
|
|
|
20
14
|
const NODE_MODULES = `${path.sep}node_modules${path.sep}`;
|
|
21
15
|
const CONFIG = Symbol.for('parcel-plugin-config');
|
|
@@ -30,22 +24,6 @@ export default async function loadPlugin<T>(
|
|
|
30
24
|
version: Semver,
|
|
31
25
|
resolveFrom: ProjectPath,
|
|
32
26
|
|}> {
|
|
33
|
-
if (atlaspackInternalPlugins && atlaspackInternalPlugins[pluginName]) {
|
|
34
|
-
let plugin = atlaspackInternalPlugins[pluginName]();
|
|
35
|
-
plugin = plugin.default || plugin;
|
|
36
|
-
plugin = plugin[CONFIG];
|
|
37
|
-
if (!plugin) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`,
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
plugin,
|
|
44
|
-
version: ATLASPACK_VERSION,
|
|
45
|
-
resolveFrom: toProjectPathUnsafe(options.projectRoot),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
27
|
let resolveFrom = configPath;
|
|
50
28
|
|
|
51
29
|
// Config packages can reference plugins, but cannot contain other plugins within them.
|
package/src/public/Config.js
CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
} from '@atlaspack/utils';
|
|
21
21
|
import Environment from './Environment';
|
|
22
22
|
import {fromProjectPath, toProjectPath} from '../projectPath';
|
|
23
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
24
23
|
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
25
24
|
|
|
26
25
|
const internalConfigToConfig: DefaultWeakMap<
|
|
@@ -362,7 +361,7 @@ export default class PublicConfig implements IConfig {
|
|
|
362
361
|
}
|
|
363
362
|
|
|
364
363
|
let pkgConfig = await this.getConfig<PackageJSON>(['package.json'], {
|
|
365
|
-
readTracking:
|
|
364
|
+
readTracking: true,
|
|
366
365
|
});
|
|
367
366
|
if (!pkgConfig) {
|
|
368
367
|
return null;
|
|
@@ -47,10 +47,6 @@ export default class PluginOptions implements IPluginOptions {
|
|
|
47
47
|
return this.#options.parcelVersion;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
get isAtlaspackSuper(): boolean {
|
|
51
|
-
return Boolean(this.#options.isAtlaspackSuper);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
50
|
get hmrOptions(): ?HMROptions {
|
|
55
51
|
return this.#options.hmrOptions;
|
|
56
52
|
}
|
|
@@ -30,17 +30,15 @@ import ThrowableDiagnostic, {
|
|
|
30
30
|
md,
|
|
31
31
|
errorToDiagnostic,
|
|
32
32
|
} from '@atlaspack/diagnostic';
|
|
33
|
-
import
|
|
33
|
+
import {parse} from 'json5';
|
|
34
34
|
import path from 'path';
|
|
35
35
|
import invariant from 'assert';
|
|
36
36
|
|
|
37
|
-
import atlaspackInternalPlugins from '../internal-plugins';
|
|
38
37
|
import {AtlaspackConfig} from '../AtlaspackConfig';
|
|
39
38
|
import AtlaspackConfigSchema from '../AtlaspackConfig.schema';
|
|
40
39
|
import {toProjectPath} from '../projectPath';
|
|
41
40
|
import {requestTypes} from '../RequestTracker';
|
|
42
41
|
import {optionsProxy} from '../utils';
|
|
43
|
-
import {isSuperPackage} from '../isSuperPackage';
|
|
44
42
|
|
|
45
43
|
type ConfigMap<K, V> = {[K]: V, ...};
|
|
46
44
|
|
|
@@ -161,61 +159,35 @@ export async function resolveAtlaspackConfig(
|
|
|
161
159
|
);
|
|
162
160
|
|
|
163
161
|
let usedDefault = false;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (
|
|
167
|
-
configPath == null &&
|
|
168
|
-
options.defaultConfig != null &&
|
|
169
|
-
isSuperPackage() &&
|
|
170
|
-
options.defaultConfig.endsWith('.js')
|
|
171
|
-
) {
|
|
162
|
+
if (configPath == null && options.defaultConfig != null) {
|
|
172
163
|
usedDefault = true;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
options.defaultConfig,
|
|
178
|
-
options,
|
|
179
|
-
);
|
|
180
|
-
config = result.config;
|
|
181
|
-
extendedFiles = result.extendedFiles;
|
|
182
|
-
} else {
|
|
183
|
-
if (configPath == null && options.defaultConfig != null) {
|
|
184
|
-
usedDefault = true;
|
|
185
|
-
|
|
186
|
-
configPath = (
|
|
187
|
-
await options.packageManager.resolve(options.defaultConfig, resolveFrom)
|
|
188
|
-
).resolved;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (configPath == null) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
164
|
+
configPath = (
|
|
165
|
+
await options.packageManager.resolve(options.defaultConfig, resolveFrom)
|
|
166
|
+
).resolved;
|
|
167
|
+
}
|
|
194
168
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
} catch (e) {
|
|
199
|
-
throw new ThrowableDiagnostic({
|
|
200
|
-
diagnostic: {
|
|
201
|
-
message: md`Could not find parcel config at ${path.relative(
|
|
202
|
-
options.projectRoot,
|
|
203
|
-
configPath,
|
|
204
|
-
)}`,
|
|
205
|
-
origin: '@atlaspack/core',
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
}
|
|
169
|
+
if (configPath == null) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
209
172
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
173
|
+
let contents;
|
|
174
|
+
try {
|
|
175
|
+
contents = await options.inputFS.readFile(configPath, 'utf8');
|
|
176
|
+
} catch (e) {
|
|
177
|
+
throw new ThrowableDiagnostic({
|
|
178
|
+
diagnostic: {
|
|
179
|
+
message: md`Could not find parcel config at ${path.relative(
|
|
180
|
+
options.projectRoot,
|
|
181
|
+
configPath,
|
|
182
|
+
)}`,
|
|
183
|
+
origin: '@atlaspack/core',
|
|
184
|
+
},
|
|
185
|
+
});
|
|
217
186
|
}
|
|
218
187
|
|
|
188
|
+
let {config, extendedFiles}: AtlaspackConfigChain =
|
|
189
|
+
await parseAndProcessConfig(configPath, contents, options);
|
|
190
|
+
|
|
219
191
|
if (options.additionalReporters.length > 0) {
|
|
220
192
|
config.reporters = [
|
|
221
193
|
...options.additionalReporters.map(({packageName, resolveFrom}) => ({
|
|
@@ -244,7 +216,7 @@ export async function parseAndProcessConfig(
|
|
|
244
216
|
): Promise<AtlaspackConfigChain> {
|
|
245
217
|
let config: RawAtlaspackConfig;
|
|
246
218
|
try {
|
|
247
|
-
config =
|
|
219
|
+
config = parse(contents);
|
|
248
220
|
} catch (e) {
|
|
249
221
|
let pos = {
|
|
250
222
|
line: e.lineNumber,
|
|
@@ -474,29 +446,11 @@ export async function processConfigChain(
|
|
|
474
446
|
let key = Array.isArray(configFile.extends)
|
|
475
447
|
? `/extends/${i}`
|
|
476
448
|
: '/extends';
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
atlaspackInternalPlugins[ext](),
|
|
483
|
-
/*#__ATLASPACK_IGNORE__*/ __dirname,
|
|
484
|
-
options,
|
|
485
|
-
)
|
|
486
|
-
).config;
|
|
487
|
-
} else {
|
|
488
|
-
let resolved = await resolveExtends(ext, filePath, key, options);
|
|
489
|
-
extendedFiles.push(resolved);
|
|
490
|
-
let result = await processExtendedConfig(
|
|
491
|
-
filePath,
|
|
492
|
-
key,
|
|
493
|
-
ext,
|
|
494
|
-
resolved,
|
|
495
|
-
options,
|
|
496
|
-
);
|
|
497
|
-
extendedFiles = extendedFiles.concat(result.extendedFiles);
|
|
498
|
-
nextConfig = result.config;
|
|
499
|
-
}
|
|
449
|
+
let resolved = await resolveExtends(ext, filePath, key, options);
|
|
450
|
+
extendedFiles.push(resolved);
|
|
451
|
+
let {extendedFiles: moreExtendedFiles, config: nextConfig} =
|
|
452
|
+
await processExtendedConfig(filePath, key, ext, resolved, options);
|
|
453
|
+
extendedFiles = extendedFiles.concat(moreExtendedFiles);
|
|
500
454
|
extStartConfig = extStartConfig
|
|
501
455
|
? mergeConfigs(extStartConfig, nextConfig)
|
|
502
456
|
: nextConfig;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// @flow
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
2
3
|
import type {
|
|
3
4
|
DependencySpecifier,
|
|
4
5
|
SemverRange,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
toProjectPath,
|
|
25
26
|
} from '../projectPath';
|
|
26
27
|
import {requestTypes} from '../RequestTracker';
|
|
28
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
27
29
|
|
|
28
30
|
// A cache of dev dep requests keyed by invalidations.
|
|
29
31
|
// If the package manager returns the same invalidation object, then
|
|
@@ -116,17 +118,47 @@ type DevDepRequests = {|
|
|
|
116
118
|
export async function getDevDepRequests<TResult: RequestResult>(
|
|
117
119
|
api: RunAPI<TResult>,
|
|
118
120
|
): Promise<DevDepRequests> {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
async function getPreviousDevDepRequests() {
|
|
122
|
+
if (getFeatureFlag('fixBuildAbortCorruption')) {
|
|
123
|
+
const allDevDepRequests = await Promise.all(
|
|
124
|
+
api
|
|
125
|
+
.getSubRequests()
|
|
126
|
+
.filter((req) => req.requestType === requestTypes.dev_dep_request)
|
|
127
|
+
.map(
|
|
128
|
+
async (
|
|
129
|
+
req,
|
|
130
|
+
): Promise<[string, DevDepRequestResult | null | void]> => [
|
|
131
|
+
req.id,
|
|
132
|
+
await api.getRequestResult<DevDepRequestResult>(req.id),
|
|
133
|
+
],
|
|
134
|
+
),
|
|
135
|
+
);
|
|
136
|
+
const nonNullDevDepRequests = [];
|
|
137
|
+
for (const [id, result] of allDevDepRequests) {
|
|
138
|
+
if (result != null) {
|
|
139
|
+
nonNullDevDepRequests.push([id, result]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return new Map(nonNullDevDepRequests);
|
|
144
|
+
} else {
|
|
145
|
+
return new Map(
|
|
146
|
+
await Promise.all(
|
|
147
|
+
api
|
|
148
|
+
.getSubRequests()
|
|
149
|
+
.filter((req) => req.requestType === requestTypes.dev_dep_request)
|
|
150
|
+
.map(async (req) => [
|
|
151
|
+
req.id,
|
|
152
|
+
nullthrows(
|
|
153
|
+
await api.getRequestResult<DevDepRequestResult>(req.id),
|
|
154
|
+
),
|
|
155
|
+
]),
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const previousDevDepRequests = await getPreviousDevDepRequests();
|
|
130
162
|
|
|
131
163
|
return {
|
|
132
164
|
devDeps: new Map(
|
|
@@ -24,6 +24,7 @@ import ThrowableDiagnostic, {
|
|
|
24
24
|
md,
|
|
25
25
|
} from '@atlaspack/diagnostic';
|
|
26
26
|
import {PluginLogger} from '@atlaspack/logger';
|
|
27
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
27
28
|
import nullthrows from 'nullthrows';
|
|
28
29
|
import path from 'path';
|
|
29
30
|
import {normalizePath} from '@atlaspack/utils';
|
|
@@ -320,6 +321,9 @@ export class ResolverRunner {
|
|
|
320
321
|
|
|
321
322
|
if (result.priority != null) {
|
|
322
323
|
dependency.priority = Priority[result.priority];
|
|
324
|
+
if (getFeatureFlag('hmrImprovements')) {
|
|
325
|
+
dependency.resolverPriority = dependency.priority;
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
if (result.invalidateOnEnvChange) {
|
package/src/resolveOptions.js
CHANGED
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
import loadDotEnv from './loadDotEnv';
|
|
26
26
|
import {toProjectPath} from './projectPath';
|
|
27
27
|
import {getResolveFrom} from './requests/AtlaspackConfigRequest';
|
|
28
|
-
import {isSuperPackage} from './isSuperPackage';
|
|
29
28
|
|
|
30
29
|
import {DEFAULT_FEATURE_FLAGS} from '@atlaspack/feature-flags';
|
|
31
30
|
import {ATLASPACK_VERSION} from './constants';
|
|
@@ -278,7 +277,6 @@ export default async function resolveOptions(
|
|
|
278
277
|
// feature-flags
|
|
279
278
|
featureFlags: {...DEFAULT_FEATURE_FLAGS, ...initialOptions?.featureFlags},
|
|
280
279
|
parcelVersion: ATLASPACK_VERSION,
|
|
281
|
-
isAtlaspackSuper: isSuperPackage(),
|
|
282
280
|
};
|
|
283
281
|
}
|
|
284
282
|
|
package/src/types.js
CHANGED
|
@@ -145,6 +145,7 @@ export type Dependency = {|
|
|
|
145
145
|
customPackageConditions?: Array<string>,
|
|
146
146
|
meta: Meta,
|
|
147
147
|
resolverMeta?: ?Meta,
|
|
148
|
+
resolverPriority?: $Values<typeof Priority>,
|
|
148
149
|
target: ?Target,
|
|
149
150
|
sourceAssetId: ?string,
|
|
150
151
|
sourcePath: ?ProjectPath,
|
|
@@ -285,7 +286,6 @@ export type AtlaspackOptions = {|
|
|
|
285
286
|
defaultConfig?: DependencySpecifier,
|
|
286
287
|
env: EnvMap,
|
|
287
288
|
parcelVersion: string,
|
|
288
|
-
isAtlaspackSuper?: boolean,
|
|
289
289
|
targets: ?(Array<string> | {+[string]: TargetDescriptor, ...}),
|
|
290
290
|
shouldDisableCache: boolean,
|
|
291
291
|
cacheDir: FilePath,
|
package/src/worker.js
CHANGED
|
@@ -32,15 +32,14 @@ import '@atlaspack/cache'; // register with serializer
|
|
|
32
32
|
import '@atlaspack/package-manager';
|
|
33
33
|
import '@atlaspack/fs';
|
|
34
34
|
|
|
35
|
-
// Repl builds are currently not enabled
|
|
36
35
|
// $FlowFixMe
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
|
|
37
|
+
/* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
38
|
+
require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
|
|
39
|
+
// $FlowFixMe
|
|
40
|
+
require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
|
|
41
|
+
/* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
|
|
42
|
+
}
|
|
44
43
|
|
|
45
44
|
registerCoreWithSerializer();
|
|
46
45
|
|
package/_empty.js
DELETED
|
File without changes
|
package/lib/internal-plugins.js
DELETED
package/lib/isSuperPackage.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
let fs = require('fs');
|
|
4
|
-
let {
|
|
5
|
-
findAncestorFile
|
|
6
|
-
} = require('@atlaspack/rust');
|
|
7
|
-
let dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
|
|
8
|
-
function isSuperPackage() {
|
|
9
|
-
if (!dirname) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
let packageJson = JSON.parse(
|
|
13
|
-
// $FlowFixMe
|
|
14
|
-
fs.readFileSync(findAncestorFile(['package.json'], dirname, '/'), 'utf8'));
|
|
15
|
-
return packageJson.name === 'atlaspack';
|
|
16
|
-
}
|
|
17
|
-
let result;
|
|
18
|
-
module.exports.isSuperPackage = () => {
|
|
19
|
-
if (result == null) {
|
|
20
|
-
result = isSuperPackage();
|
|
21
|
-
}
|
|
22
|
-
return result;
|
|
23
|
-
};
|
package/src/internal-plugins.js
DELETED
package/src/isSuperPackage.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
let fs = require('fs');
|
|
3
|
-
let {findAncestorFile} = require('@atlaspack/rust');
|
|
4
|
-
|
|
5
|
-
let dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
|
|
6
|
-
|
|
7
|
-
function isSuperPackage(): boolean {
|
|
8
|
-
if (!dirname) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
let packageJson = JSON.parse(
|
|
13
|
-
// $FlowFixMe
|
|
14
|
-
fs.readFileSync(findAncestorFile(['package.json'], dirname, '/'), 'utf8'),
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
return packageJson.name === 'atlaspack';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let result;
|
|
21
|
-
|
|
22
|
-
module.exports.isSuperPackage = (): boolean => {
|
|
23
|
-
if (result == null) {
|
|
24
|
-
result = isSuperPackage();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
File without changes
|