@atlaspack/packager-js 2.14.5-canary.97 → 2.14.5-canary.99

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.
@@ -60,6 +60,13 @@ function _featureFlags() {
60
60
  };
61
61
  return data;
62
62
  }
63
+ function _outdent() {
64
+ const data = require("outdent");
65
+ _outdent = function () {
66
+ return data;
67
+ };
68
+ return data;
69
+ }
63
70
  var _ESMOutputFormat = require("./ESMOutputFormat");
64
71
  var _CJSOutputFormat = require("./CJSOutputFormat");
65
72
  var _GlobalOutputFormat = require("./GlobalOutputFormat");
@@ -431,6 +438,9 @@ class ScopeHoistingPackager {
431
438
  } = (0, _nullthrows().default)(this.assetOutputs.get(asset.id));
432
439
  return this.buildAsset(asset, code, map);
433
440
  }
441
+ getAssetFilePath(asset) {
442
+ return _path().default.relative(this.options.projectRoot, asset.filePath);
443
+ }
434
444
  buildAsset(asset, code, map) {
435
445
  let shouldWrap = this.wrappedAssets.has(asset.id);
436
446
  let deps = this.bundleGraph.getDependencies(asset);
@@ -528,8 +538,19 @@ class ScopeHoistingPackager {
528
538
  if ((0, _featureFlags().getFeatureFlag)('applyScopeHoistingImprovement')) {
529
539
  if (!resolved.meta.isConstantModule && !this.wrappedAssets.has(resolved.id)) {
530
540
  let [depCode, depMap, depLines] = this.visitAsset(resolved);
531
- res = depCode + '\n' + res;
532
- lines += 1 + depLines;
541
+ if (_utils().debugTools['asset-file-names-in-output']) {
542
+ let resolvedPath = this.getAssetFilePath(resolved);
543
+ res = (0, _outdent().outdent)`
544
+ /* Scope hoisted asset: ${resolvedPath} */
545
+ ${depCode}
546
+ /* End: ${resolvedPath} */
547
+ ${res}
548
+ `;
549
+ lines += 3 + depLines;
550
+ } else {
551
+ res = depCode + '\n' + res;
552
+ lines += 1 + depLines;
553
+ }
533
554
  map = depMap;
534
555
  }
535
556
  } else {
@@ -587,6 +608,10 @@ ${code}
587
608
  });
588
609
  `;
589
610
  lineCount += 2;
611
+ if (_utils().debugTools['asset-file-names-in-output']) {
612
+ code = `/* ${this.getAssetFilePath(asset)} */\n` + code;
613
+ lineCount += 1;
614
+ }
590
615
  for (let [depCode, map, lines] of depContent) {
591
616
  if (!depCode) continue;
592
617
  code += depCode + '\n';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-js",
3
- "version": "2.14.5-canary.97+c843081cc",
3
+ "version": "2.14.5-canary.99+30ee2cfcd",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,16 +15,17 @@
15
15
  "node": ">= 16.0.0"
16
16
  },
17
17
  "dependencies": {
18
- "@atlaspack/diagnostic": "2.14.1-canary.165+c843081cc",
19
- "@atlaspack/feature-flags": "2.14.1-canary.165+c843081cc",
20
- "@atlaspack/plugin": "2.14.5-canary.97+c843081cc",
21
- "@atlaspack/rust": "3.2.1-canary.97+c843081cc",
22
- "@atlaspack/types": "2.14.5-canary.97+c843081cc",
23
- "@atlaspack/utils": "2.14.5-canary.97+c843081cc",
18
+ "@atlaspack/diagnostic": "2.14.1-canary.167+30ee2cfcd",
19
+ "@atlaspack/feature-flags": "2.14.1-canary.167+30ee2cfcd",
20
+ "@atlaspack/plugin": "2.14.5-canary.99+30ee2cfcd",
21
+ "@atlaspack/rust": "3.2.1-canary.99+30ee2cfcd",
22
+ "@atlaspack/types": "2.14.5-canary.99+30ee2cfcd",
23
+ "@atlaspack/utils": "2.14.5-canary.99+30ee2cfcd",
24
24
  "@parcel/source-map": "^2.1.1",
25
25
  "globals": "^13.2.0",
26
- "nullthrows": "^1.1.1"
26
+ "nullthrows": "^1.1.1",
27
+ "outdent": "^0.8.0"
27
28
  },
28
29
  "type": "commonjs",
29
- "gitHead": "c843081cc495d8870e4b047fa827817eef71727c"
30
+ "gitHead": "30ee2cfcd34cf2646ded0eda13fdb80a2a5de529"
30
31
  }
@@ -15,6 +15,7 @@ import {
15
15
  relativeBundlePath,
16
16
  countLines,
17
17
  normalizeSeparators,
18
+ debugTools,
18
19
  } from '@atlaspack/utils';
19
20
  import SourceMap from '@parcel/source-map';
20
21
  import nullthrows from 'nullthrows';
@@ -25,6 +26,7 @@ import ThrowableDiagnostic, {
25
26
  import globals from 'globals';
26
27
  import path from 'path';
27
28
  import {getFeatureFlag} from '@atlaspack/feature-flags';
29
+ import {outdent} from 'outdent';
28
30
 
29
31
  import {ESMOutputFormat} from './ESMOutputFormat';
30
32
  import {CJSOutputFormat} from './CJSOutputFormat';
@@ -579,6 +581,10 @@ export class ScopeHoistingPackager {
579
581
  return this.buildAsset(asset, code, map);
580
582
  }
581
583
 
584
+ getAssetFilePath(asset: Asset): string {
585
+ return path.relative(this.options.projectRoot, asset.filePath);
586
+ }
587
+
582
588
  buildAsset(
583
589
  asset: Asset,
584
590
  code: string,
@@ -720,8 +726,19 @@ export class ScopeHoistingPackager {
720
726
  ) {
721
727
  let [depCode, depMap, depLines] =
722
728
  this.visitAsset(resolved);
723
- res = depCode + '\n' + res;
724
- lines += 1 + depLines;
729
+ if (debugTools['asset-file-names-in-output']) {
730
+ let resolvedPath = this.getAssetFilePath(resolved);
731
+ res = outdent`
732
+ /* Scope hoisted asset: ${resolvedPath} */
733
+ ${depCode}
734
+ /* End: ${resolvedPath} */
735
+ ${res}
736
+ `;
737
+ lines += 3 + depLines;
738
+ } else {
739
+ res = depCode + '\n' + res;
740
+ lines += 1 + depLines;
741
+ }
725
742
  map = depMap;
726
743
  }
727
744
  } else {
@@ -792,6 +809,11 @@ ${code}
792
809
 
793
810
  lineCount += 2;
794
811
 
812
+ if (debugTools['asset-file-names-in-output']) {
813
+ code = `/* ${this.getAssetFilePath(asset)} */\n` + code;
814
+ lineCount += 1;
815
+ }
816
+
795
817
  for (let [depCode, map, lines] of depContent) {
796
818
  if (!depCode) continue;
797
819
  code += depCode + '\n';