@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.
Files changed (51) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/lib/AssetGraph.js +9 -0
  3. package/lib/Atlaspack.js +5 -2
  4. package/lib/AtlaspackConfig.schema.js +7 -1
  5. package/lib/BundleGraph.js +3 -4
  6. package/lib/PackagerRunner.js +2 -5
  7. package/lib/RequestTracker.js +48 -39
  8. package/lib/Transformation.js +2 -2
  9. package/lib/atlaspack-v3/AtlaspackV3.js +1 -44
  10. package/lib/atlaspack-v3/NapiWorkerPool.js +1 -1
  11. package/lib/atlaspack-v3/worker/compat/environment.js +2 -2
  12. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +6 -6
  13. package/lib/atlaspack-v3/worker/compat/plugin-config.js +5 -5
  14. package/lib/atlaspack-v3/worker/index.js +6 -0
  15. package/lib/atlaspack-v3/worker/worker.js +4 -11
  16. package/lib/dumpGraphToGraphViz.js +1 -1
  17. package/lib/index.js +24 -4
  18. package/lib/loadAtlaspackPlugin.js +0 -15
  19. package/lib/public/Config.js +1 -8
  20. package/lib/public/PluginOptions.js +0 -3
  21. package/lib/requests/AtlaspackConfigRequest.js +29 -44
  22. package/lib/requests/DevDepRequest.js +22 -1
  23. package/lib/requests/PathRequest.js +10 -0
  24. package/lib/resolveOptions.js +4 -5
  25. package/lib/worker.js +26 -9
  26. package/package.json +17 -31
  27. package/src/AssetGraph.js +13 -0
  28. package/src/Atlaspack.js +7 -8
  29. package/src/BundleGraph.js +1 -8
  30. package/src/PackagerRunner.js +0 -5
  31. package/src/RequestTracker.js +8 -6
  32. package/src/atlaspack-v3/AtlaspackV3.js +2 -53
  33. package/src/atlaspack-v3/NapiWorkerPool.js +1 -5
  34. package/src/atlaspack-v3/worker/worker.js +4 -11
  35. package/src/index.js +5 -3
  36. package/src/loadAtlaspackPlugin.js +1 -23
  37. package/src/public/Config.js +1 -2
  38. package/src/public/PluginOptions.js +0 -4
  39. package/src/requests/AtlaspackConfigRequest.js +31 -77
  40. package/src/requests/DevDepRequest.js +44 -12
  41. package/src/requests/PathRequest.js +4 -0
  42. package/src/resolveOptions.js +0 -2
  43. package/src/types.js +1 -1
  44. package/src/worker.js +7 -8
  45. package/_empty.js +0 -0
  46. package/lib/atlaspack-v3/worker/napi-worker.js +0 -3
  47. package/lib/internal-plugins.js +0 -9
  48. package/lib/isSuperPackage.js +0 -23
  49. package/src/internal-plugins.js +0 -4
  50. package/src/isSuperPackage.js +0 -28
  51. /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.
@@ -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: getFeatureFlag('granularTsConfigInvalidation'),
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 json5 from 'json5';
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
- let config, extendedFiles;
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
- // Load the super package default config
174
- let result: AtlaspackConfigChain = await processConfigChain(
175
- atlaspackInternalPlugins['@atlaspack/config-default'](),
176
- // $FlowFixMe
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
- let contents;
196
- try {
197
- contents = await options.inputFS.readFile(configPath, 'utf8');
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
- let result: AtlaspackConfigChain = await parseAndProcessConfig(
211
- configPath,
212
- contents,
213
- options,
214
- );
215
- config = result.config;
216
- extendedFiles = result.extendedFiles;
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 = json5.parse(contents);
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
- let nextConfig;
479
- if (atlaspackInternalPlugins[ext]) {
480
- nextConfig = (
481
- await processConfigChain(
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
- let previousDevDepRequests: Map<string, DevDepRequestResult> = new Map(
120
- await Promise.all(
121
- api
122
- .getSubRequests()
123
- .filter((req) => req.requestType === requestTypes.dev_dep_request)
124
- .map(async (req) => [
125
- req.id,
126
- nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
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) {
@@ -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
- // if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
38
- // /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
39
- // require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
40
- // // $FlowFixMe
41
- // require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
42
- // /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
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
@@ -1,3 +0,0 @@
1
- "use strict";
2
-
3
- require('./worker');
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- // This file is overridden in super package builds
8
- // $FlowFixMe
9
- var _default = exports.default = {};
@@ -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
- };
@@ -1,4 +0,0 @@
1
- // @flow
2
- // This file is overridden in super package builds
3
- // $FlowFixMe
4
- export default {};
@@ -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
- };