@atlaspack/core 2.16.2-dev.1c70d50f9.99 → 2.16.2-dev.69

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 (50) hide show
  1. package/CHANGELOG.md +0 -77
  2. package/_empty.js +0 -0
  3. package/lib/AssetGraph.js +1 -10
  4. package/lib/Atlaspack.js +2 -5
  5. package/lib/BundleGraph.js +4 -1
  6. package/lib/Environment.js +0 -1
  7. package/lib/PackagerRunner.js +4 -0
  8. package/lib/RequestTracker.js +3 -7
  9. package/lib/atlaspack-v3/AtlaspackV3.js +44 -1
  10. package/lib/atlaspack-v3/NapiWorkerPool.js +1 -1
  11. package/lib/atlaspack-v3/worker/worker.js +11 -4
  12. package/lib/index.js +4 -24
  13. package/lib/internal-plugins.js +9 -0
  14. package/lib/isSuperPackage.js +23 -0
  15. package/lib/loadAtlaspackPlugin.js +15 -0
  16. package/lib/public/Config.js +8 -1
  17. package/lib/public/PluginOptions.js +3 -0
  18. package/lib/requests/AssetGraphRequestRust.js +2 -17
  19. package/lib/requests/AtlaspackConfigRequest.js +44 -29
  20. package/lib/requests/DevDepRequest.js +1 -21
  21. package/lib/requests/PathRequest.js +0 -10
  22. package/lib/resolveOptions.js +3 -1
  23. package/lib/worker.js +8 -8
  24. package/package.json +31 -17
  25. package/src/AssetGraph.js +2 -19
  26. package/src/Atlaspack.js +8 -7
  27. package/src/BundleGraph.js +8 -1
  28. package/src/Environment.js +1 -1
  29. package/src/EnvironmentManager.js +1 -1
  30. package/src/PackagerRunner.js +5 -0
  31. package/src/RequestTracker.js +6 -8
  32. package/src/atlaspack-v3/AtlaspackV3.js +53 -2
  33. package/src/atlaspack-v3/NapiWorkerPool.js +5 -1
  34. package/src/atlaspack-v3/worker/worker.js +11 -4
  35. package/src/index.js +3 -5
  36. package/src/internal-plugins.js +4 -0
  37. package/src/isSuperPackage.js +28 -0
  38. package/src/loadAtlaspackPlugin.js +23 -1
  39. package/src/public/Config.js +2 -1
  40. package/src/public/MutableBundleGraph.js +1 -3
  41. package/src/public/PluginOptions.js +4 -0
  42. package/src/requests/AssetGraphRequestRust.js +2 -14
  43. package/src/requests/AtlaspackConfigRequest.js +77 -31
  44. package/src/requests/DevDepRequest.js +12 -44
  45. package/src/requests/PathRequest.js +0 -4
  46. package/src/resolveOptions.js +2 -0
  47. package/src/types.js +1 -1
  48. package/src/worker.js +8 -7
  49. /package/lib/atlaspack-v3/worker/{index.js → napi-worker.js} +0 -0
  50. /package/src/atlaspack-v3/worker/{index.js → napi-worker.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,82 +1,5 @@
1
1
  # @atlaspack/core
2
2
 
3
- ## 2.18.5
4
-
5
- ### Patch Changes
6
-
7
- - [#652](https://github.com/atlassian-labs/atlaspack/pull/652) [`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix bugs related to build aborts. Builds and cache writes will no longer be aborted.
8
-
9
- - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
10
- - @atlaspack/feature-flags@2.18.2
11
- - @atlaspack/cache@3.2.9
12
- - @atlaspack/fs@2.15.9
13
- - @atlaspack/graph@3.5.4
14
- - @atlaspack/utils@2.15.2
15
- - @atlaspack/package-manager@2.14.14
16
- - @atlaspack/profiler@2.14.12
17
- - @atlaspack/types@2.15.4
18
- - @atlaspack/workers@2.14.14
19
- - @atlaspack/plugin@2.14.14
20
-
21
- ## 2.18.4
22
-
23
- ### Patch Changes
24
-
25
- - [#650](https://github.com/atlassian-labs/atlaspack/pull/650) [`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb) Thanks [@alshdavid](https://github.com/alshdavid)! - Remove package.json#exports
26
-
27
- - [#646](https://github.com/atlassian-labs/atlaspack/pull/646) [`6b1f5ff`](https://github.com/atlassian-labs/atlaspack/commit/6b1f5fff68d7131fae075e14f4d2c02606dc6058) Thanks [@alshdavid](https://github.com/alshdavid)! - Export WORKER_PATH from @atlaspack/core
28
-
29
- - [#633](https://github.com/atlassian-labs/atlaspack/pull/633) [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b) Thanks [@sbhuiyan-atlassian](https://github.com/sbhuiyan-atlassian)! - Ported various HMR changes from Parcel
30
-
31
- - [#648](https://github.com/atlassian-labs/atlaspack/pull/648) [`c8f7df4`](https://github.com/atlassian-labs/atlaspack/commit/c8f7df4eadfc4718040fceb065dae6e96a4051e7) Thanks [@alshdavid](https://github.com/alshdavid)! - Export ATLASPACK_VERSION and other internals
32
-
33
- - [#626](https://github.com/atlassian-labs/atlaspack/pull/626) [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca) Thanks [@yamadapc](https://github.com/yamadapc)! - Clean-up tsconfig invalidation improvements feature-flag
34
-
35
- - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb), [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
36
- - @atlaspack/workers@2.14.13
37
- - @atlaspack/logger@2.14.11
38
- - @atlaspack/feature-flags@2.18.1
39
- - @atlaspack/fs@2.15.8
40
- - @atlaspack/package-manager@2.14.13
41
- - @atlaspack/types@2.15.3
42
- - @atlaspack/cache@3.2.8
43
- - @atlaspack/utils@2.15.1
44
- - @atlaspack/graph@3.5.3
45
- - @atlaspack/plugin@2.14.13
46
- - @atlaspack/profiler@2.14.11
47
-
48
- ## 2.18.3
49
-
50
- ### Patch Changes
51
-
52
- - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
53
- - @atlaspack/feature-flags@2.18.0
54
- - @atlaspack/utils@2.15.0
55
- - @atlaspack/cache@3.2.7
56
- - @atlaspack/fs@2.15.7
57
- - @atlaspack/graph@3.5.2
58
- - @atlaspack/package-manager@2.14.12
59
- - @atlaspack/workers@2.14.12
60
- - @atlaspack/profiler@2.14.10
61
- - @atlaspack/types@2.15.2
62
- - @atlaspack/plugin@2.14.12
63
-
64
- ## 2.18.2
65
-
66
- ### Patch Changes
67
-
68
- - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
69
- - @atlaspack/feature-flags@2.17.0
70
- - @atlaspack/cache@3.2.6
71
- - @atlaspack/fs@2.15.6
72
- - @atlaspack/graph@3.5.1
73
- - @atlaspack/utils@2.14.11
74
- - @atlaspack/package-manager@2.14.11
75
- - @atlaspack/profiler@2.14.9
76
- - @atlaspack/types@2.15.1
77
- - @atlaspack/workers@2.14.11
78
- - @atlaspack/plugin@2.14.11
79
-
80
3
  ## 2.18.1
81
4
 
82
5
  ### Patch Changes
package/_empty.js ADDED
File without changes
package/lib/AssetGraph.js CHANGED
@@ -148,7 +148,7 @@ class AssetGraph extends _graph().ContentGraph {
148
148
  let idAndContext = `${id}-${context}`;
149
149
  let env = this.envCache.get(idAndContext);
150
150
  if (env) {
151
- input.env = (0, _EnvironmentManager.toEnvironmentRef)(env);
151
+ input.env = env;
152
152
  } else {
153
153
  this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
154
154
  }
@@ -443,15 +443,6 @@ class AssetGraph extends _graph().ContentGraph {
443
443
  ...depNode.value.meta,
444
444
  ...existing.value.resolverMeta
445
445
  };
446
- if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
447
- depNode.value.resolverMeta = existing.value.resolverMeta;
448
- }
449
- }
450
- if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
451
- if ((existing === null || existing === void 0 ? void 0 : existing.type) === 'dependency' && existing.value.resolverPriority != null) {
452
- depNode.value.priority = existing.value.resolverPriority;
453
- depNode.value.resolverPriority = existing.value.resolverPriority;
454
- }
455
446
  }
456
447
  let dependentAsset = dependentAssets.find(a => a.uniqueKey === dep.specifier);
457
448
  if (dependentAsset) {
package/lib/Atlaspack.js CHANGED
@@ -126,7 +126,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
126
126
  (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
127
127
  const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
128
128
  const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
129
- const WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
129
+ const WORKER_PATH = exports.WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker.js');
130
130
  class Atlaspack {
131
131
  #requestTracker /*: RequestTracker*/;
132
132
  #config /*: AtlaspackConfig*/;
@@ -215,7 +215,6 @@ class Atlaspack {
215
215
  }
216
216
  rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
217
217
  ...options,
218
- corePath: _path().default.join(__dirname, '..'),
219
218
  threads,
220
219
  entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
221
220
  env: resolvedOptions.env,
@@ -510,9 +509,7 @@ class Atlaspack {
510
509
  if (this.rustAtlaspack) {
511
510
  nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
512
511
  }
513
- let {
514
- didInvalidate: isInvalid
515
- } = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
512
+ let isInvalid = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
516
513
  if ((nativeInvalid || isInvalid) && this.#watchQueue.getNumWaiting() === 0) {
517
514
  if (this.#watchAbortController) {
518
515
  this.#watchAbortController.abort();
@@ -833,7 +833,10 @@ class BundleGraph {
833
833
  // If this asset is referenced by any async dependency, it's referenced.
834
834
  return true;
835
835
  }
836
- let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
836
+ let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId,
837
+ // TODO: This seems like bug with library builds when assets are present
838
+ // in other files. Guarding the fix for now exclusively for super builds
839
+ process.env.ATLASPACK_SUPER_BUILD === 'true' ? _graph().ALL_EDGE_TYPES : undefined).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
837
840
  (0, _assert().default)(node.type === 'dependency');
838
841
  return node.value;
839
842
  });
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createEnvironment = createEnvironment;
7
- exports.getEnvironmentHash = getEnvironmentHash;
8
7
  exports.mergeEnvironments = mergeEnvironments;
9
8
  function _rust() {
10
9
  const data = require("@atlaspack/rust");
@@ -413,6 +413,10 @@ class PackagerRunner {
413
413
  inlineSources = this.options.mode === 'production';
414
414
  }
415
415
  }
416
+ if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
417
+ // Set source root to 'atlaspack' so stack traces are clean in Sentry
418
+ sourceRoot = 'atlaspack';
419
+ }
416
420
  let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
417
421
  let stringified = await map.stringify({
418
422
  file: _path().default.basename(fullPath + '.map'),
@@ -703,7 +703,8 @@ class RequestGraph extends _graph().ContentGraph {
703
703
  //
704
704
  // Currently create events can invalidate a large number of nodes due to
705
705
  // "create above" invalidations.
706
- if (configKeyNodes) {
706
+ const isConfigKeyChange = (0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation') || type === 'delete' || type === 'update';
707
+ if (configKeyNodes && isConfigKeyChange) {
707
708
  for (let nodeId of configKeyNodes) {
708
709
  let isInvalid = type === 'delete';
709
710
  if (type !== 'delete') {
@@ -779,9 +780,6 @@ class RequestTracker {
779
780
 
780
781
  // TODO: refactor (abortcontroller should be created by RequestTracker)
781
782
  setSignal(signal) {
782
- if ((0, _featureFlags().getFeatureFlag)('fixBuildAbortCorruption')) {
783
- return;
784
- }
785
783
  this.signal = signal;
786
784
  }
787
785
  startRequest(request) {
@@ -922,9 +920,7 @@ class RequestTracker {
922
920
  options: this.options,
923
921
  rustAtlaspack: this.rustAtlaspack
924
922
  });
925
- if (!(0, _featureFlags().getFeatureFlag)('fixBuildAbortCorruption')) {
926
- (0, _utils2.assertSignalNotAborted)(this.signal);
927
- }
923
+ (0, _utils2.assertSignalNotAborted)(this.signal);
928
924
  this.completeRequest(requestNodeId);
929
925
  deferred.resolve(true);
930
926
  return result;
@@ -19,7 +19,46 @@ function _diagnostic() {
19
19
  };
20
20
  return data;
21
21
  }
22
+ var _isSuperPackage = require("../isSuperPackage");
23
+ function _path() {
24
+ const data = _interopRequireDefault(require("path"));
25
+ _path = function () {
26
+ return data;
27
+ };
28
+ return data;
29
+ }
22
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+ function getJsPaths() {
32
+ const dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
33
+ if ((0, _isSuperPackage.isSuperPackage)()) {
34
+ // dirname: atlaspack/lib/core/core/atlaspack-v3
35
+ // core: atlaspack/lib/core/core/index.js
36
+ const corePath = _path().default.join(dirname, '..');
37
+ // esmodule helpers: atlaspack/lib/transformers/js/esmodule-helpers.js
38
+ const esmoduleHelpersPath = _path().default.join(dirname, '../../../transformers/js/esmodule-helpers.js');
39
+
40
+ // empty file: atlaspack/lib/core/core/_empty.js
41
+ const emptyFile = _path().default.join(dirname, '_empty.js');
42
+ return {
43
+ corePath,
44
+ esmoduleHelpersSpecifier: _path().default.relative(corePath, esmoduleHelpersPath),
45
+ esmoduleHelpersIncludeNodeModules: 'atlaspack',
46
+ emptyFile
47
+ };
48
+ }
49
+
50
+ // dirname: @atlaspack/core/lib/atlaspack-v3
51
+ // core: @atlaspack/core
52
+ const corePath = _path().default.join(dirname, '../..');
53
+ // empty file: atlaspack/lib/core/core/_empty.js
54
+ const emptyFile = _path().default.join(dirname, '_empty.js');
55
+ return {
56
+ corePath,
57
+ esmoduleHelpersSpecifier: '@atlaspack/transformer-js/src/esmodule-helpers.js',
58
+ esmoduleHelpersIncludeNodeModules: '@atlaspack/transformer-js',
59
+ emptyFile
60
+ };
61
+ }
23
62
  class AtlaspackV3 {
24
63
  constructor(atlaspack_napi) {
25
64
  this._atlaspack_napi = atlaspack_napi;
@@ -40,7 +79,11 @@ class AtlaspackV3 {
40
79
  fs,
41
80
  packageManager,
42
81
  threads,
43
- options,
82
+ options: {
83
+ ...options,
84
+ jsPaths: getJsPaths(),
85
+ useBuiltinConfigs: (0, _isSuperPackage.isSuperPackage)()
86
+ },
44
87
  napiWorkerPool
45
88
  }, lmdb);
46
89
  if (error !== null) {
@@ -33,7 +33,7 @@ function _rust() {
33
33
  return data;
34
34
  }
35
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
- const WORKER_PATH = _path().default.join(__dirname, 'worker', 'index.js');
36
+ const WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker', 'napi-worker.js');
37
37
  const ATLASPACK_NAPI_WORKERS = _process().default.env.ATLASPACK_NAPI_WORKERS && parseInt(_process().default.env.ATLASPACK_NAPI_WORKERS, 10);
38
38
  class NapiWorkerPool {
39
39
  #workers;
@@ -48,6 +48,7 @@ function _module() {
48
48
  }
49
49
  var _jsCallable = require("../jsCallable");
50
50
  var _compat = require("./compat");
51
+ var _internalPlugins = _interopRequireDefault(require("../../internal-plugins"));
51
52
  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); }
52
53
  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; }
53
54
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -66,10 +67,16 @@ class AtlaspackWorker {
66
67
  specifier,
67
68
  resolveFrom
68
69
  }) => {
69
- let customRequire = _module().createRequire(resolveFrom);
70
- let resolvedPath = customRequire.resolve(specifier);
71
- // $FlowFixMe
72
- let resolvedModule = await import(resolvedPath);
70
+ let resolvedModule;
71
+ if (_internalPlugins.default && _internalPlugins.default[specifier]) {
72
+ // If the plugin is available inside the package then use it
73
+ resolvedModule = _internalPlugins.default[specifier]();
74
+ } else {
75
+ let customRequire = _module().createRequire(resolveFrom);
76
+ let resolvedPath = customRequire.resolve(specifier);
77
+ // $FlowFixMe
78
+ resolvedModule = await import(resolvedPath);
79
+ }
73
80
  let instance = undefined;
74
81
  if (resolvedModule.default && resolvedModule.default[CONFIG]) {
75
82
  instance = resolvedModule.default[CONFIG];
package/lib/index.js CHANGED
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- EnvironmentManager: true,
8
7
  Atlaspack: true,
9
8
  Parcel: true,
10
9
  BuildError: true,
11
10
  createWorkerFarm: true,
12
11
  INTERNAL_RESOLVE: true,
13
12
  INTERNAL_TRANSFORM: true,
14
- WORKER_PATH: true,
15
- ATLASPACK_VERSION: true,
16
- resolveOptions: true
13
+ isSuperPackage: true
17
14
  };
18
- Object.defineProperty(exports, "ATLASPACK_VERSION", {
19
- enumerable: true,
20
- get: function () {
21
- return _constants.ATLASPACK_VERSION;
22
- }
23
- });
24
15
  Object.defineProperty(exports, "Atlaspack", {
25
16
  enumerable: true,
26
17
  get: function () {
@@ -33,7 +24,6 @@ Object.defineProperty(exports, "BuildError", {
33
24
  return _Atlaspack.BuildError;
34
25
  }
35
26
  });
36
- exports.EnvironmentManager = void 0;
37
27
  Object.defineProperty(exports, "INTERNAL_RESOLVE", {
38
28
  enumerable: true,
39
29
  get: function () {
@@ -52,12 +42,6 @@ Object.defineProperty(exports, "Parcel", {
52
42
  return _Atlaspack.default;
53
43
  }
54
44
  });
55
- Object.defineProperty(exports, "WORKER_PATH", {
56
- enumerable: true,
57
- get: function () {
58
- return _Atlaspack.WORKER_PATH;
59
- }
60
- });
61
45
  Object.defineProperty(exports, "createWorkerFarm", {
62
46
  enumerable: true,
63
47
  get: function () {
@@ -70,17 +54,14 @@ Object.defineProperty(exports, "default", {
70
54
  return _Atlaspack.default;
71
55
  }
72
56
  });
73
- Object.defineProperty(exports, "resolveOptions", {
57
+ Object.defineProperty(exports, "isSuperPackage", {
74
58
  enumerable: true,
75
59
  get: function () {
76
- return _resolveOptions.default;
60
+ return _isSuperPackage.isSuperPackage;
77
61
  }
78
62
  });
79
- var EnvironmentManager = _interopRequireWildcard(require("./EnvironmentManager"));
80
- exports.EnvironmentManager = EnvironmentManager;
81
63
  var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
82
- var _constants = require("./constants");
83
- var _resolveOptions = _interopRequireDefault(require("./resolveOptions"));
64
+ var _isSuperPackage = require("./isSuperPackage");
84
65
  var _atlaspackV = require("./atlaspack-v3");
85
66
  Object.keys(_atlaspackV).forEach(function (key) {
86
67
  if (key === "default" || key === "__esModule") return;
@@ -93,6 +74,5 @@ Object.keys(_atlaspackV).forEach(function (key) {
93
74
  }
94
75
  });
95
76
  });
96
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
97
77
  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); }
98
78
  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; }
@@ -0,0 +1,9 @@
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 = {};
@@ -0,0 +1,23 @@
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
+ };
@@ -25,6 +25,8 @@ function _diagnostic() {
25
25
  };
26
26
  return data;
27
27
  }
28
+ var _package = require("../package.json");
29
+ var _internalPlugins = _interopRequireDefault(require("./internal-plugins"));
28
30
  function _utils() {
29
31
  const data = require("@atlaspack/utils");
30
32
  _utils = function () {
@@ -39,6 +41,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
39
41
  const NODE_MODULES = `${_path().default.sep}node_modules${_path().default.sep}`;
40
42
  const CONFIG = Symbol.for('parcel-plugin-config');
41
43
  async function loadPlugin(pluginName, configPath, keyPath, options) {
44
+ if (_internalPlugins.default && _internalPlugins.default[pluginName]) {
45
+ let plugin = _internalPlugins.default[pluginName]();
46
+ plugin = plugin.default || plugin;
47
+ plugin = plugin[CONFIG];
48
+ if (!plugin) {
49
+ throw new Error(`Plugin ${pluginName} is not a valid Atlaspack plugin, should export an instance of a Atlaspack plugin ex. "export default new Reporter({ ... })".`);
50
+ }
51
+ return {
52
+ plugin,
53
+ version: _package.version,
54
+ resolveFrom: (0, _projectPath.toProjectPathUnsafe)(options.projectRoot)
55
+ };
56
+ }
42
57
  let resolveFrom = configPath;
43
58
 
44
59
  // Config packages can reference plugins, but cannot contain other plugins within them.
@@ -28,6 +28,13 @@ function _utils() {
28
28
  }
29
29
  var _Environment = _interopRequireDefault(require("./Environment"));
30
30
  var _projectPath = require("../projectPath");
31
+ function _featureFlags() {
32
+ const data = require("@atlaspack/feature-flags");
33
+ _featureFlags = function () {
34
+ return data;
35
+ };
36
+ return data;
37
+ }
31
38
  var _EnvironmentManager = require("../EnvironmentManager");
32
39
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
40
  const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
@@ -277,7 +284,7 @@ class PublicConfig {
277
284
  return this.#pkg;
278
285
  }
279
286
  let pkgConfig = await this.getConfig(['package.json'], {
280
- readTracking: true
287
+ readTracking: (0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation')
281
288
  });
282
289
  if (!pkgConfig) {
283
290
  return null;
@@ -29,6 +29,9 @@ class PluginOptions {
29
29
  get parcelVersion() {
30
30
  return this.#options.parcelVersion;
31
31
  }
32
+ get isAtlaspackSuper() {
33
+ return Boolean(this.#options.isAtlaspackSuper);
34
+ }
32
35
  get hmrOptions() {
33
36
  return this.#options.hmrOptions;
34
37
  }
@@ -26,18 +26,9 @@ function _logger() {
26
26
  };
27
27
  return data;
28
28
  }
29
- function _featureFlags() {
30
- const data = require("@atlaspack/feature-flags");
31
- _featureFlags = function () {
32
- return data;
33
- };
34
- return data;
35
- }
36
29
  var _AssetGraph = _interopRequireWildcard(require("../AssetGraph"));
37
30
  var _RequestTracker = require("../RequestTracker");
38
31
  var _SymbolPropagation = require("../SymbolPropagation");
39
- var _EnvironmentManager = require("../EnvironmentManager");
40
- var _Environment = require("../Environment");
41
32
  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); }
42
33
  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; }
43
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -146,11 +137,8 @@ function getAssetGraph(serializedGraph) {
146
137
  let id = asset.id;
147
138
  asset.committed = true;
148
139
  asset.contentKey = id;
149
- asset.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
150
- // TODO: Rust can do this and avoid copying a significant amount of data over
151
- (0, _Environment.getEnvironmentHash)(asset.env) : getEnvId(asset.env);
140
+ asset.env.id = getEnvId(asset.env);
152
141
  asset.mapKey = `map:${asset.id}`;
153
- asset.env = (0, _EnvironmentManager.toEnvironmentRef)(asset.env);
154
142
 
155
143
  // This is populated later when we map the edges between assets and dependencies
156
144
  asset.dependencies = new Map();
@@ -174,10 +162,7 @@ function getAssetGraph(serializedGraph) {
174
162
  let id = node.value.id;
175
163
  let dependency = node.value.dependency;
176
164
  dependency.id = id;
177
- dependency.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
178
- // TODO: Rust can do this and avoid copying a significant amount of data over
179
- (0, _Environment.getEnvironmentHash)(dependency.env) : getEnvId(dependency.env);
180
- dependency.env = (0, _EnvironmentManager.toEnvironmentRef)(dependency.env);
165
+ dependency.env.id = getEnvId(dependency.env);
181
166
  if (dependency.symbols != null) {
182
167
  var _dependency$symbols;
183
168
  dependency.symbols = new Map((_dependency$symbols = dependency.symbols) === null || _dependency$symbols === void 0 ? void 0 : _dependency$symbols.map(mapSymbols));
@@ -40,7 +40,7 @@ function _diagnostic() {
40
40
  return data;
41
41
  }
42
42
  function _json() {
43
- const data = require("json5");
43
+ const data = _interopRequireDefault(require("json5"));
44
44
  _json = function () {
45
45
  return data;
46
46
  };
@@ -60,11 +60,13 @@ function _assert() {
60
60
  };
61
61
  return data;
62
62
  }
63
+ var _internalPlugins = _interopRequireDefault(require("../internal-plugins"));
63
64
  var _AtlaspackConfig = require("../AtlaspackConfig");
64
65
  var _AtlaspackConfig2 = _interopRequireDefault(require("../AtlaspackConfig.schema"));
65
66
  var _projectPath = require("../projectPath");
66
67
  var _RequestTracker = require("../RequestTracker");
67
68
  var _utils2 = require("../utils");
69
+ var _isSuperPackage = require("../isSuperPackage");
68
70
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
69
71
  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); }
70
72
  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; }
@@ -134,28 +136,38 @@ async function resolveAtlaspackConfig(options) {
134
136
  let resolveFrom = getResolveFrom(options.inputFS, options.projectRoot);
135
137
  let configPath = options.config != null ? (await options.packageManager.resolve(options.config, resolveFrom)).resolved : await (0, _utils().resolveConfig)(options.inputFS, resolveFrom, ['.parcelrc'], options.projectRoot);
136
138
  let usedDefault = false;
137
- if (configPath == null && options.defaultConfig != null) {
139
+ let config, extendedFiles;
140
+ if (configPath == null && options.defaultConfig != null && (0, _isSuperPackage.isSuperPackage)() && options.defaultConfig.endsWith('.js')) {
138
141
  usedDefault = true;
139
- configPath = (await options.packageManager.resolve(options.defaultConfig, resolveFrom)).resolved;
140
- }
141
- if (configPath == null) {
142
- return null;
143
- }
144
- let contents;
145
- try {
146
- contents = await options.inputFS.readFile(configPath, 'utf8');
147
- } catch (e) {
148
- throw new (_diagnostic().default)({
149
- diagnostic: {
150
- message: (0, _diagnostic().md)`Could not find parcel config at ${_path().default.relative(options.projectRoot, configPath)}`,
151
- origin: '@atlaspack/core'
152
- }
153
- });
142
+ // Load the super package default config
143
+ let result = await processConfigChain(_internalPlugins.default['@atlaspack/config-default'](),
144
+ // $FlowFixMe
145
+ options.defaultConfig, options);
146
+ config = result.config;
147
+ extendedFiles = result.extendedFiles;
148
+ } else {
149
+ if (configPath == null && options.defaultConfig != null) {
150
+ usedDefault = true;
151
+ configPath = (await options.packageManager.resolve(options.defaultConfig, resolveFrom)).resolved;
152
+ }
153
+ if (configPath == null) {
154
+ return null;
155
+ }
156
+ let contents;
157
+ try {
158
+ contents = await options.inputFS.readFile(configPath, 'utf8');
159
+ } catch (e) {
160
+ throw new (_diagnostic().default)({
161
+ diagnostic: {
162
+ message: (0, _diagnostic().md)`Could not find parcel config at ${_path().default.relative(options.projectRoot, configPath)}`,
163
+ origin: '@atlaspack/core'
164
+ }
165
+ });
166
+ }
167
+ let result = await parseAndProcessConfig(configPath, contents, options);
168
+ config = result.config;
169
+ extendedFiles = result.extendedFiles;
154
170
  }
155
- let {
156
- config,
157
- extendedFiles
158
- } = await parseAndProcessConfig(configPath, contents, options);
159
171
  if (options.additionalReporters.length > 0) {
160
172
  config.reporters = [...options.additionalReporters.map(({
161
173
  packageName,
@@ -179,7 +191,7 @@ function create(config, options) {
179
191
  async function parseAndProcessConfig(configPath, contents, options) {
180
192
  let config;
181
193
  try {
182
- config = (0, _json().parse)(contents);
194
+ config = _json().default.parse(contents);
183
195
  } catch (e) {
184
196
  let pos = {
185
197
  line: e.lineNumber,
@@ -304,13 +316,16 @@ async function processConfigChain(configFile, filePath, options) {
304
316
  for (let ext of exts) {
305
317
  try {
306
318
  let key = Array.isArray(configFile.extends) ? `/extends/${i}` : '/extends';
307
- let resolved = await resolveExtends(ext, filePath, key, options);
308
- extendedFiles.push(resolved);
309
- let {
310
- extendedFiles: moreExtendedFiles,
311
- config: nextConfig
312
- } = await processExtendedConfig(filePath, key, ext, resolved, options);
313
- extendedFiles = extendedFiles.concat(moreExtendedFiles);
319
+ let nextConfig;
320
+ if (_internalPlugins.default[ext]) {
321
+ nextConfig = (await processConfigChain(_internalPlugins.default[ext](), /*#__ATLASPACK_IGNORE__*/__dirname, options)).config;
322
+ } else {
323
+ let resolved = await resolveExtends(ext, filePath, key, options);
324
+ extendedFiles.push(resolved);
325
+ let result = await processExtendedConfig(filePath, key, ext, resolved, options);
326
+ extendedFiles = extendedFiles.concat(result.extendedFiles);
327
+ nextConfig = result.config;
328
+ }
314
329
  extStartConfig = extStartConfig ? mergeConfigs(extStartConfig, nextConfig) : nextConfig;
315
330
  } catch (err) {
316
331
  errors.push(err);